source: libcaca/trunk/caca-php/examples/www/colors.php @ 4148

Last change on this file since 4148 was 4148, checked in by Sam Hocevar, 10 years ago

Update my e-mail address everywhere.

  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1<?php
2header('Content-Type: text/html; charset=UTF-8');
3?>
4<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
7<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
8<?php
9  /*
10   *  colors        display all possible libcaca colour pairs
11   *  Copyright (c) 2008 Benjamin C. Wiley Sittler <bsittler@gmail.com>
12   *
13   *  This file is a Php port of "examples/colors.c"
14   *  Copyright (c) 2003-2004 Sam Hocevar <sam@hocevar.net>
15   *                All Rights Reserved
16   *
17   *  $Id: colors.php 4148 2009-12-19 14:38:38Z sam $
18   *
19   *  This program is free software. It comes without any warranty, to
20   *  the extent permitted by applicable law. You can redistribute it
21   *  and/or modify it under the terms of the Do What The Fuck You Want
22   *  To Public License, Version 2, as published by Sam Hocevar. See
23   *  http://sam.zoy.org/wtfpl/COPYING for more details.
24   */
25?>
26<head>
27<title>display all possible libcaca colour pairs</title>
28<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
29</head>
30<body text="silver" bgcolor="black">
31<?php
32
33$cv = caca_create_canvas(80, 24);
34if(!$cv)
35{
36        die("Failed to create canvas\n");
37}
38
39caca_set_color_ansi($cv, CACA_LIGHTGRAY, CACA_BLACK);
40caca_clear_canvas($cv);
41for($i = 0; $i < 16; $i++)
42{
43        caca_set_color_ansi($cv, CACA_LIGHTGRAY, CACA_BLACK);
44        caca_put_str($cv, 3, $i + ($i >= 8 ? 3 : 2), "ANSI " . $i);
45        for($j = 0; $j < 16; $j++)
46        {
47                caca_set_color_ansi($cv, $i, $j);
48                caca_put_str($cv, ($j >= 8 ? 13 : 12) + $j * 4, $i + ($i >= 8 ? 3 : 2),
49                                        "Aaホ");
50        }
51}
52
53caca_set_color_ansi($cv, CACA_LIGHTGRAY, CACA_BLACK);
54caca_put_str($cv, 3, 20, "This is bold    This is blink    This is italics    This is underline");
55caca_set_attr($cv, CACA_BOLD);
56caca_put_str($cv, 3 + 8, 20, "bold");
57caca_set_attr($cv, CACA_BLINK);
58caca_put_str($cv, 3 + 24, 20, "blink");
59caca_set_attr($cv, CACA_ITALICS);
60caca_put_str($cv, 3 + 41, 20, "italics");
61caca_set_attr($cv, CACA_UNDERLINE);
62caca_put_str($cv, 3 + 60, 20, "underline");
63
64echo caca_export_string($cv, "html3");
65
66?>
67</body>
68</html>
Note: See TracBrowser for help on using the repository browser.