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

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

Large source code cleanup, getting rid of spaces, tabs, and svn keywords.

  • Property svn:keywords set to Id
File size: 2.1 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   *  This program is free software. It comes without any warranty, to
18   *  the extent permitted by applicable law. You can redistribute it
19   *  and/or modify it under the terms of the Do What The Fuck You Want
20   *  To Public License, Version 2, as published by Sam Hocevar. See
21   *  http://sam.zoy.org/wtfpl/COPYING for more details.
22   */
23?>
24<head>
25<title>display all possible libcaca colour pairs</title>
26<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
27</head>
28<body text="silver" bgcolor="black">
29<?php
30
31$cv = caca_create_canvas(80, 24);
32if(!$cv)
33{
34    die("Failed to create canvas\n");
35}
36
37caca_set_color_ansi($cv, CACA_LIGHTGRAY, CACA_BLACK);
38caca_clear_canvas($cv);
39for($i = 0; $i < 16; $i++)
40{
41    caca_set_color_ansi($cv, CACA_LIGHTGRAY, CACA_BLACK);
42    caca_put_str($cv, 3, $i + ($i >= 8 ? 3 : 2), "ANSI " . $i);
43    for($j = 0; $j < 16; $j++)
44    {
45        caca_set_color_ansi($cv, $i, $j);
46        caca_put_str($cv, ($j >= 8 ? 13 : 12) + $j * 4, $i + ($i >= 8 ? 3 : 2),
47                    "Aaホ");
48    }
49}
50
51caca_set_color_ansi($cv, CACA_LIGHTGRAY, CACA_BLACK);
52caca_put_str($cv, 3, 20, "This is bold    This is blink    This is italics    This is underline");
53caca_set_attr($cv, CACA_BOLD);
54caca_put_str($cv, 3 + 8, 20, "bold");
55caca_set_attr($cv, CACA_BLINK);
56caca_put_str($cv, 3 + 24, 20, "blink");
57caca_set_attr($cv, CACA_ITALICS);
58caca_put_str($cv, 3 + 41, 20, "italics");
59caca_set_attr($cv, CACA_UNDERLINE);
60caca_put_str($cv, 3 + 60, 20, "underline");
61
62echo caca_export_string($cv, "html3");
63
64?>
65</body>
66</html>
Note: See TracBrowser for help on using the repository browser.