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