[3229] | 1 | #!/usr/bin/php5 |
---|
| 2 | <?php |
---|
| 3 | /* |
---|
| 4 | * colors display all possible libcaca colour pairs |
---|
| 5 | * Copyright (c) 2008 Benjamin C. Wiley Sittler <bsittler@gmail.com> |
---|
| 6 | * |
---|
| 7 | * This file is a Php port of "examples/colors.c" |
---|
| 8 | * Copyright (c) 2003-2004 Sam Hocevar <sam@zoy.org> |
---|
| 9 | * All Rights Reserved |
---|
| 10 | * |
---|
| 11 | * $Id: colors.php 3268 2008-11-04 03:56:18Z bsittler $ |
---|
| 12 | * |
---|
| 13 | * This program is free software. It comes without any warranty, to |
---|
| 14 | * the extent permitted by applicable law. You can redistribute it |
---|
| 15 | * and/or modify it under the terms of the Do What The Fuck You Want |
---|
| 16 | * To Public License, Version 2, as published by Sam Hocevar. See |
---|
| 17 | * http://sam.zoy.org/wtfpl/COPYING for more details. |
---|
| 18 | */ |
---|
[85] | 19 | |
---|
[3268] | 20 | if (php_sapi_name() != "cli") { |
---|
| 21 | die("You have to run this program with php-cli!\n"); |
---|
| 22 | } |
---|
| 23 | |
---|
[3229] | 24 | $cv = caca_create_canvas(80, 24); |
---|
| 25 | if(!$cv) |
---|
| 26 | { |
---|
| 27 | die("Failed to create canvas\n"); |
---|
| 28 | } |
---|
[105] | 29 | |
---|
[3229] | 30 | $dp = caca_create_display($cv); |
---|
| 31 | if(!$dp) |
---|
| 32 | { |
---|
| 33 | die("Failed to create display\n"); |
---|
| 34 | } |
---|
[99] | 35 | |
---|
[3229] | 36 | caca_set_color_ansi($cv, CACA_LIGHTGRAY, CACA_BLACK); |
---|
| 37 | caca_clear_canvas($cv); |
---|
| 38 | for($i = 0; $i < 16; $i++) |
---|
[85] | 39 | { |
---|
[3229] | 40 | caca_set_color_ansi($cv, CACA_LIGHTGRAY, CACA_BLACK); |
---|
| 41 | caca_put_str($cv, 3, $i + ($i >= 8 ? 3 : 2), "ANSI " . $i); |
---|
| 42 | for($j = 0; $j < 16; $j++) |
---|
| 43 | { |
---|
| 44 | caca_set_color_ansi($cv, $i, $j); |
---|
| 45 | caca_put_str($cv, ($j >= 8 ? 13 : 12) + $j * 4, $i + ($i >= 8 ? 3 : 2), |
---|
| 46 | "Aaホ"); |
---|
| 47 | } |
---|
| 48 | } |
---|
[85] | 49 | |
---|
[3229] | 50 | caca_set_color_ansi($cv, CACA_LIGHTGRAY, CACA_BLACK); |
---|
| 51 | caca_put_str($cv, 3, 20, "This is bold This is blink This is italics This is underline"); |
---|
[3260] | 52 | caca_set_attr($cv, CACA_BOLD); |
---|
[3229] | 53 | caca_put_str($cv, 3 + 8, 20, "bold"); |
---|
[3260] | 54 | caca_set_attr($cv, CACA_BLINK); |
---|
[3229] | 55 | caca_put_str($cv, 3 + 24, 20, "blink"); |
---|
[3260] | 56 | caca_set_attr($cv, CACA_ITALICS); |
---|
[3229] | 57 | caca_put_str($cv, 3 + 41, 20, "italics"); |
---|
[3260] | 58 | caca_set_attr($cv, CACA_UNDERLINE); |
---|
[3229] | 59 | caca_put_str($cv, 3 + 60, 20, "underline"); |
---|
[85] | 60 | |
---|
[3229] | 61 | caca_refresh_display($dp); |
---|
| 62 | caca_get_event($dp, CACA_EVENT_KEY_PRESS, -1); |
---|
[524] | 63 | |
---|
[3229] | 64 | ?> |
---|