Debian Codegraph @

caca-php/examples/www/truecolor.php

raw
1 <?php
2 header('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 * truecolor truecolor canvas features
11 * Copyright (c) 2008 Benjamin C. Wiley Sittler <[email protected]>
12 *
13 * This file is a Php port of "examples/truecolor.c"
14 * which is:
15 * Copyright (c) 2006 Sam Hocevar <[email protected]>
16 * All Rights Reserved
17 *
18 * This program is free software. It comes without any warranty, to
19 * the extent permitted by applicable law. You can redistribute it
20 * and/or modify it under the terms of the Do What the Fuck You Want
21 * to Public License, Version 2, as published by Sam Hocevar. See
22 * http://www.wtfpl.net/ for more details.
23 */
24 ?>
25 <head>
26 <title>truecolor canvas features</title>
27 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
28 </head>
29 <body text="silver" bgcolor="black">
30 <?php
31
32 $cv = caca_create_canvas(32, 16);
33 if(!$cv) {
34 die("Failed to create canvas\n");
35 }
36
37 for($y = 0; $y < 16; $y++)
38 for($x = 0; $x < 16; $x++)
39 {
40 $bgcolor = 0xff00 | ($y << 4) | $x;
41 $fgcolor = 0xf000 | ((15 - $y) << 4) | ((15 - $x) << 8);
42
43 caca_set_color_argb($cv, $fgcolor, $bgcolor);
44 caca_put_str($cv, $x * 2, $y, "CA");
45 }
46
47 caca_set_color_ansi($cv, CACA_WHITE, CACA_LIGHTBLUE);
48 caca_put_str($cv, 2, 1, " truecolor libcaca ");
49
50 echo caca_export_string($cv, "html3");
51
52 ?>
53 </body>
54 </html>