[3219] | 1 | <?php |
---|
[3221] | 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 |
---|
[779] | 9 | /* |
---|
[3219] | 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: |
---|
[779] | 15 | * Copyright (c) 2006 Sam Hocevar <sam@zoy.org> |
---|
[3219] | 16 | * All Rights Reserved |
---|
[779] | 17 | * |
---|
| 18 | * $Id: truecolor.php 3221 2008-11-02 20:29:02Z bsittler $ |
---|
| 19 | * |
---|
[1462] | 20 | * This program is free software. It comes without any warranty, to |
---|
[1452] | 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 |
---|
[779] | 24 | * http://sam.zoy.org/wtfpl/COPYING for more details. |
---|
| 25 | */ |
---|
[3221] | 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 |
---|
[779] | 33 | |
---|
[3219] | 34 | $cv = caca_create_canvas(32, 16); |
---|
| 35 | if(!$cv) { |
---|
| 36 | die("Failed to create canvas\n"); |
---|
| 37 | } |
---|
[779] | 38 | |
---|
[3219] | 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 | } |
---|
[779] | 48 | |
---|
[3219] | 49 | caca_set_color_ansi($cv, CACA_WHITE, CACA_LIGHTBLUE); |
---|
| 50 | caca_put_str($cv, 2, 1, " truecolor libcaca "); |
---|
[779] | 51 | |
---|
[3221] | 52 | echo caca_export_string($cv, "html3"); |
---|
[779] | 53 | |
---|
[3219] | 54 | ?> |
---|
[3221] | 55 | </body> |
---|
| 56 | </html> |
---|