[3219] | 1 | #!/usr/bin/php5 |
---|
| 2 | <?php |
---|
[779] | 3 | /* |
---|
[3219] | 4 | * truecolor truecolor canvas features |
---|
| 5 | * Copyright (c) 2008 Benjamin C. Wiley Sittler <bsittler@gmail.com> |
---|
| 6 | * |
---|
| 7 | * This file is a Php port of "examples/truecolor.c" |
---|
| 8 | * which is: |
---|
[779] | 9 | * Copyright (c) 2006 Sam Hocevar <sam@zoy.org> |
---|
[3219] | 10 | * All Rights Reserved |
---|
[779] | 11 | * |
---|
| 12 | * $Id: truecolor.php 3219 2008-11-02 20:17:00Z bsittler $ |
---|
| 13 | * |
---|
[1462] | 14 | * This program is free software. It comes without any warranty, to |
---|
[1452] | 15 | * the extent permitted by applicable law. You can redistribute it |
---|
| 16 | * and/or modify it under the terms of the Do What The Fuck You Want |
---|
| 17 | * To Public License, Version 2, as published by Sam Hocevar. See |
---|
[779] | 18 | * http://sam.zoy.org/wtfpl/COPYING for more details. |
---|
| 19 | */ |
---|
| 20 | |
---|
[3219] | 21 | $cv = caca_create_canvas(32, 16); |
---|
| 22 | if(!$cv) { |
---|
| 23 | die("Failed to create canvas\n"); |
---|
| 24 | } |
---|
[779] | 25 | |
---|
[3219] | 26 | $dp = caca_create_display($cv); |
---|
| 27 | if(!$dp) { |
---|
| 28 | die("Failed to create display\n"); |
---|
| 29 | } |
---|
[779] | 30 | |
---|
[3219] | 31 | for($y = 0; $y < 16; $y++) |
---|
| 32 | for($x = 0; $x < 16; $x++) |
---|
| 33 | { |
---|
| 34 | $bgcolor = 0xff00 | ($y << 4) | $x; |
---|
| 35 | $fgcolor = 0xf000 | ((15 - $y) << 4) | ((15 - $x) << 8); |
---|
| 36 | |
---|
| 37 | caca_set_color_argb($cv, $fgcolor, $bgcolor); |
---|
| 38 | caca_put_str($cv, $x * 2, $y, "CA"); |
---|
| 39 | } |
---|
[779] | 40 | |
---|
[3219] | 41 | caca_set_color_ansi($cv, CACA_WHITE, CACA_LIGHTBLUE); |
---|
| 42 | caca_put_str($cv, 2, 1, " truecolor libcaca "); |
---|
[779] | 43 | |
---|
[3219] | 44 | caca_refresh_display($dp); |
---|
[779] | 45 | |
---|
[3219] | 46 | caca_get_event($dp, CACA_EVENT_KEY_PRESS, -1); |
---|
[1752] | 47 | |
---|
[3219] | 48 | ?> |
---|