From d32095400b392df331bf502f7d6a6f616110d003 Mon Sep 17 00:00:00 2001 From: Ben Wiley Sittler Date: Sun, 2 Nov 2008 22:35:45 +0000 Subject: [PATCH] copy colors.php to www in preparation for htmlizing --- caca-php/examples/www/colors.php | 60 ++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 caca-php/examples/www/colors.php diff --git a/caca-php/examples/www/colors.php b/caca-php/examples/www/colors.php new file mode 100755 index 0000000..b670ee4 --- /dev/null +++ b/caca-php/examples/www/colors.php @@ -0,0 +1,60 @@ +#!/usr/bin/php5 + + * + * This file is a Php port of "examples/colors.c" + * Copyright (c) 2003-2004 Sam Hocevar + * All Rights Reserved + * + * $Id$ + * + * This program is free software. It comes without any warranty, to + * the extent permitted by applicable law. You can redistribute it + * and/or modify it under the terms of the Do What The Fuck You Want + * To Public License, Version 2, as published by Sam Hocevar. See + * http://sam.zoy.org/wtfpl/COPYING for more details. + */ + +$cv = caca_create_canvas(80, 24); +if(!$cv) +{ + die("Failed to create canvas\n"); +} + +$dp = caca_create_display($cv); +if(!$dp) +{ + die("Failed to create display\n"); +} + +caca_set_color_ansi($cv, CACA_LIGHTGRAY, CACA_BLACK); +caca_clear_canvas($cv); +for($i = 0; $i < 16; $i++) +{ + caca_set_color_ansi($cv, CACA_LIGHTGRAY, CACA_BLACK); + caca_put_str($cv, 3, $i + ($i >= 8 ? 3 : 2), "ANSI " . $i); + for($j = 0; $j < 16; $j++) + { + caca_set_color_ansi($cv, $i, $j); + caca_put_str($cv, ($j >= 8 ? 13 : 12) + $j * 4, $i + ($i >= 8 ? 3 : 2), + "Aaホ"); + } +} + +caca_set_color_ansi($cv, CACA_LIGHTGRAY, CACA_BLACK); +caca_put_str($cv, 3, 20, "This is bold This is blink This is italics This is underline"); +caca_set_attr($cv, CACA_BOLD, CACA_DEFAULT); +caca_put_str($cv, 3 + 8, 20, "bold"); +caca_set_attr($cv, CACA_BLINK, CACA_DEFAULT); +caca_put_str($cv, 3 + 24, 20, "blink"); +caca_set_attr($cv, CACA_ITALICS, CACA_DEFAULT); +caca_put_str($cv, 3 + 41, 20, "italics"); +caca_set_attr($cv, CACA_UNDERLINE, CACA_DEFAULT); +caca_put_str($cv, 3 + 60, 20, "underline"); + +caca_refresh_display($dp); +caca_get_event($dp, CACA_EVENT_KEY_PRESS, -1); + +?>