function just_for_fun() { $moo = <<<EOT (__) (oo) /------\\/ / | || * /\\---/\\ ~~ ~~ EOT; $cv = caca_create_canvas(0, 0); caca_set_color_ansi($cv, CACA_LIGHTBLUE, CACA_DEFAULT); caca_import_string($cv, $moo, "text"); for ($j = 0; $j < caca_get_canvas_height($cv); $j++) { for ($i = 0; $i < caca_get_canvas_width($cv); $i += 2) { caca_set_color_ansi($cv, caca_rand(1, 10) > 5 ? CACA_LIGHTBLUE : CACA_WHITE, CACA_DEFAULT); $a = caca_get_attr($cv, -1, -1); caca_put_attr($cv, $i, $j, $a); caca_put_attr($cv, $i + 1, $j, $a); } } caca_set_canvas_size($cv, 18, 6); caca_set_color_ansi($cv, CACA_LIGHTGREEN, CACA_DEFAULT); caca_put_str($cv, 14, 0, "Moo!"); caca_set_color_ansi($cv, CACA_LIGHTRED, CACA_DEFAULT); caca_put_char($cv, 14, 1, hexdec("2765")); //U+2765 caca_put_char($cv, 16, 1, hexdec("2764")); //U+2764 echo caca_export_string($cv, "html3"); }
function pig() { $pig_str = <<<EOT _._ _..._ .-', _.._(`)) '-. ` ' /-._.-' ',/ ) \\ '. / _ _ | \\ | a a / PHP | \\ .-. ; '-('' ).-' ,' ; '-; | .' \\ \\ / | 7 .__ _.-\\ \\ | | | ``/ /` / jgs /,_| | /,_/ / /,_/ '`-' EOT; $canvas = caca_create_canvas(0, 0); caca_set_color_ansi($canvas, CACA_RED, CACA_WHITE); caca_import_string($canvas, $pig_str, "text"); caca_set_color_ansi($canvas, CACA_BLUE, CACA_LIGHTGRAY); caca_put_str($canvas, 0, 0, "Я люблю Либкаку"); return $canvas; }
function show_figlet($str, $font) { $cv = caca_create_canvas(0, 0); if (!caca_canvas_set_figfont($cv, $font)) { return false; } $chars = unistr_to_ords($str); $color = 0; foreach ($chars as $c) { caca_set_color_ansi($cv, 1 + ($color += 1) % 13, CACA_WHITE); caca_put_figchar($cv, $c); } echo caca_export_string($cv, "html3"); }
?> "<?php echo $format == $import_format ? ' selected="selected"' : ''; ?> ><?php echo htmlspecialchars($name . " (" . $import_format . ")"); ?> </option><?php } ?> </select> </form> <?php } if ($file) { $cv = caca_create_canvas(0, 0); if (!$cv) { die("Can't create canvas\n"); } if (caca_import_file($cv, $file, $format == NULL ? "" : $format) < 0) { die("could not import `" . htmlspecialchars($filename) . "'.\n"); } echo caca_export_string($cv, "html3"); } else { ?> See the <a href="export.php">libcaca export test program</a> for an <a href="export.php?format=caca">example file</a>.<?php } ?> </body> </html>
</head> <body> <?php /* * dithering.php sample program for libcaca php binding * Copyright (c) 2008 Nicolas Vion <*****@*****.**> * * 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 F**k You Want * to Public License, Version 2, as published by Sam Hocevar. See * http://www.wtfpl.net/ for more details. */ $src = "logo-caca.png"; $img = imagecreatefrompng(dirname(__FILE__) . "/" . $src); if (!$img) { die("Can not open image.\n"); } $dither = caca_create_dither($img); if (!$dither) { die("Can not create dither. Maybe you compiled caca-php without gd support.\n"); } $canvas = caca_create_canvas(100, 40); caca_dither_bitmap($canvas, 0, 0, caca_get_canvas_width($canvas), caca_get_canvas_height($canvas), $dither, $img); echo caca_export_string($canvas, "html3"); echo "<img src=\"./{$src}\" alt=\"\" />"; ?> </body> </html>
function main() { global $argc, $argv; $cols = 0; $lines = 0; $font_width = 6; $font_height = 10; $format = NULL; $dither = NULL; $gamma = $brightness = $contrast = -1.0; $long_options = array("width:" => 'W', "height:" => 'H', "font-width:" => 'x', "font-height:" => 'y', "format:" => 'f', "dither:" => 'd', "gamma:" => 'g', "brightness:" => 'b', "contrast:" => 'c', "help" => 'h', "version" => 'v'); try { while ($opt_and_arg = mygetopt("W:H:f:d:g:b:c:hvx:y:", array_keys($long_options))) { $opt = $opt_and_arg[0]; $arg = $opt_and_arg[1]; if (substr($opt, 0, 2) == '--' && array_key_exists(substr($opt, strlen('--')) . ($arg !== NULL ? ':' : ''), $long_options)) { $opt = '-' . $long_options[substr($opt, strlen('--')) . ($arg !== NULL ? ':' : '')]; } switch ($opt) { case '-W': /* --width */ $cols = intval($arg); break; case '-H': /* --height */ $lines = intval($arg); break; case '-x': /* --width */ $font_width = intval($arg); break; case '-y': /* --height */ $font_height = intval($arg); break; case '-f': /* --format */ $format = $arg; break; case '-d': /* --dither */ $dither = $arg; break; case '-g': /* --gamma */ $gamma = floatval($arg); break; case '-b': /* --brightness */ $brightness = floatval($arg); break; case '-c': /* --contrast */ $contrast = floatval($arg); break; case '-h': /* --help */ usage($argc, $argv); return 0; case '-v': /* --version */ version(); return 0; default: return 1; } } } catch (MygetoptException $e) { fprintf(STDERR, "%s", $argv[0] . ": " . $e->getMessage() . "\n"); usage($argc, $argv); return 2; } if ($argc != 2) { fprintf(STDERR, "%s: wrong argument count\n", $argv[0]); usage($argc, $argv); return 1; } $cv = caca_create_canvas(0, 0); if (!$cv) { fprintf(STDERR, "%s: unable to initialise libcaca\n", $argv[0]); return 1; } $i_str = file_get_contents($argv[$argc - 1]); $i = $i_str ? imagecreatefromstring($i_str) : NULL; if (!$i) { fprintf(STDERR, "%s: unable to load %s\n", $argv[0], $argv[$argc - 1]); return 1; } /* Assume a 6×10 font */ if (!$cols && !$lines) { $cols = 60; $lines = $cols * imagesy($i) * $font_width / imagesx($i) / $font_height; } else { if ($cols && !$lines) { $lines = $cols * imagesy($i) * $font_width / imagesx($i) / $font_height; } else { if (!$cols && $lines) { $cols = $lines * imagesx($i) * $font_height / imagesy($i) / $font_width; } } } caca_set_canvas_size($cv, $cols, $lines); caca_set_color_ansi($cv, CACA_DEFAULT, CACA_TRANSPARENT); caca_clear_canvas($cv); $i_dither = caca_create_dither($i); if (!caca_set_dither_algorithm($i_dither, $dither ? $dither : "fstein")) { fprintf(STDERR, "%s: Can't dither image with algorithm '%s'\n", $argv[0], $dither ? $dither : "fstein"); return -1; } if ($brightness != -1) { caca_set_dither_brightness($i_dither, $brightness); } if ($contrast != -1) { caca_set_dither_contrast($i_dither, $contrast); } if ($gamma != -1) { caca_set_dither_gamma($i_dither, $gamma); } caca_dither_bitmap($cv, 0, 0, $cols, $lines, $i_dither, $i); $export = caca_export_string($cv, $format ? $format : "ansi"); if (!$export) { fprintf(STDERR, "%s: Can't export to format '%s'\n", $argv[0], $format ? $format : "ansi"); return -1; } else { echo $export; } return 0; }
* All Rights Reserved * * 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 F**k You Want * to Public License, Version 2, as published by Sam Hocevar. See * http://www.wtfpl.net/ for more details. */ ?> <head> <title>libcaca Unicode rendering test program</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> <body text="silver" bgcolor="black"> <?php $cv = caca_create_canvas(80, 25); if (!$cv) { die("Can't created canvas\n"); } caca_set_color_ansi($cv, CACA_WHITE, CACA_BLUE); caca_put_str($cv, 1, 1, "Basic Unicode support"); caca_set_color_ansi($cv, CACA_DEFAULT, CACA_TRANSPARENT); caca_put_str($cv, 1, 2, "This is ASCII: | abc DEF 123 !@# |"); caca_put_str($cv, 1, 3, "This is Unicode: | äßç δεφ ☺♥♀ ╞╬╗ |"); caca_put_str($cv, 1, 4, "And this is, too: | ἀβϛ ΔЗҒ ᚴᛒᛯ ♩♔✈ |"); caca_put_str($cv, 1, 5, "If the three lines do not have the same length, there is a bug somewhere."); caca_set_color_ansi($cv, CACA_WHITE, CACA_BLUE); caca_put_str($cv, 1, 7, "Gradient glyphs"); caca_set_color_ansi($cv, CACA_DEFAULT, CACA_TRANSPARENT); caca_put_str($cv, 31, 8, " 0%"); caca_put_str($cv, 31, 9, " 25%");
function __construct($width = 0, $height = 0) { $this->cv = caca_create_canvas($width, $height); }
function main() { global $file, $filename; global $argc, $argv; global $stderr; $cols = 0; $lines = 0; $font_width = 6; $font_height = 10; $format = NULL; $dither = NULL; $gamma = $brightness = $contrast = -1.0; $long_options = array("width:" => 'W', "height:" => 'H', "font-width:" => 'x', "font-height:" => 'y', "format:" => 'f', "dither:" => 'd', "gamma:" => 'g', "brightness:" => 'b', "contrast:" => 'c', "help" => 'h', "version" => 'v'); try { while ($opt_and_arg = mygetopt("W:H:f:d:g:b:c:hvx:y:", array_keys($long_options))) { $opt = $opt_and_arg[0]; $arg = $opt_and_arg[1]; if (substr($opt, 0, 2) == '--' && array_key_exists(substr($opt, strlen('--')) . ($arg !== NULL ? ':' : ''), $long_options)) { $opt = '-' . $long_options[substr($opt, strlen('--')) . ($arg !== NULL ? ':' : '')]; } switch ($opt) { case '-W': /* --width */ $cols = intval($arg); break; case '-H': /* --height */ $lines = intval($arg); break; case '-x': /* --width */ $font_width = intval($arg); break; case '-y': /* --height */ $font_height = intval($arg); break; case '-f': /* --format */ $format = $arg; break; case '-d': /* --dither */ $dither = $arg; break; case '-g': /* --gamma */ $gamma = floatval($arg); break; case '-b': /* --brightness */ $brightness = floatval($arg); break; case '-c': /* --contrast */ $contrast = floatval($arg); break; case '-h': /* --help */ usage($argc, $argv); return 0; case '-v': /* --version */ version(); return 0; default: return 1; } } } catch (MygetoptException $e) { $stderr .= $argv[0] . ": " . $e->getMessage() . "\n"; usage($argc, $argv); return 2; } if (!$file && $argc == 2 && $argv[1] == 'logo-caca.png') { $file = 'logo-caca.png'; $argc = 1; } else { if ($filename && $file && $argc == 2 && strtolower(basename($argv[1])) == strtolower(basename($filename))) { $argc = 1; } } if ($argc == 2) { $stderr .= sprintf("%s: image not found\n", $argv[1]); return 1; } if ($argc > 2) { $stderr .= sprintf("%s: too many arguments\n", $argv[0]); usage($argc, $argv); return 1; } if (!$file) { $stderr .= sprintf("%s: no image was provided\n", $argv[0]); usage($argc, $argv); return 1; } $cv = caca_create_canvas(0, 0); if (!$cv) { $stderr .= sprintf("%s: unable to initialise libcaca\n", $argv[0]); return 1; } $i_str = $file ? file_get_contents($file) : NULL; $i = $i_str ? imagecreatefromstring($i_str) : NULL; if (!$i) { $stderr .= sprintf("%s: unable to load %s\n", $argv[0], $filename); return 1; } /* Assume a 6×10 font */ if (!$cols && !$lines) { $cols = 60; $lines = $cols * imagesy($i) * $font_width / imagesx($i) / $font_height; } else { if ($cols && !$lines) { $lines = $cols * imagesy($i) * $font_width / imagesx($i) / $font_height; } else { if (!$cols && $lines) { $cols = $lines * imagesx($i) * $font_height / imagesy($i) / $font_width; } } } caca_set_canvas_size($cv, $cols, $lines); caca_set_color_ansi($cv, CACA_DEFAULT, CACA_TRANSPARENT); caca_clear_canvas($cv); $i_dither = caca_create_dither($i); if (!caca_set_dither_algorithm($i_dither, $dither ? $dither : "fstein")) { $stderr .= sprintf("%s: Can't dither image with algorithm '%s'\n", $argv[0], $dither ? $dither : "fstein"); return -1; } if ($brightness != -1) { caca_set_dither_brightness($i_dither, $brightness); } if ($contrast != -1) { caca_set_dither_contrast($i_dither, $contrast); } if ($gamma != -1) { caca_set_dither_gamma($i_dither, $gamma); } caca_dither_bitmap($cv, 0, 0, $cols, $lines, $i_dither, $i); $format = $format ? $format : 'html'; $export = caca_export_string($cv, $format); if (!$export) { $stderr .= sprintf("%s: Can't export to format '%s'\n", $argv[0], $format); return -1; } else { $content_type_map = array('ansi' => 'text/plain; charset=CP437', 'utf8' => 'text/plain; charset=UTF-8', 'utf8cr' => 'text/plain; charset=UTF-8', 'html' => 'text/html; charset=UTF-8', 'html3' => 'text/html; charset=UTF-8', 'bbfr' => 'text/plain; charset=UTF-8', 'irc' => 'text/plain; charset=UTF-8', 'ps' => 'application/postscript', 'svg' => 'image/svg+xml', 'tga' => 'image/x-targa'); $download_extension_map = array('caca' => 'caca', 'ansi' => 'txt', 'utf8' => 'txt', 'utf8cr' => 'txt', 'irc' => 'txt', 'tga' => 'tga'); $inline_extension_map = array('bbfr' => 'txt', 'ps' => 'ps', 'svg' => 'svg'); if (!array_key_exists($format, $content_type_map)) { $content_type = 'application/octet-stream'; } else { $content_type = $content_type_map[$format]; } header('Content-Type: ' . $content_type); if (array_key_exists($format, $download_extension_map)) { header('Content-Disposition: attachment; filename=export.' . $download_extension_map[$format]); } else { if (array_key_exists($format, $inline_extension_map)) { header('Content-Disposition: inline; filename=export.' . $inline_extension_map[$format]); } } echo $export; } return 0; }
* and/or modify it under the terms of the Do What the F**k You Want * to Public License, Version 2, as published by Sam Hocevar. See * http://www.wtfpl.net/ for more details. */ function transform($tbl, $tx, $ty, $sx, $sy) { $result = array(); foreach ($tbl as $pt) { $result[] = array($pt[0] * $sx + $tx, $pt[1] * $sy + $ty); } return $result; } if (php_sapi_name() != "cli") { die("You have to run this program with php-cli!\n"); } $canvas = caca_create_canvas(0, 0); $display = caca_create_display($canvas); if (!$display) { die("Error while attaching canvas to display\n"); } $tbl = array(array(5, 2), array(15, 2), array(20, 4), array(25, 2), array(34, 2), array(37, 4), array(36, 9), array(20, 16), array(3, 9), array(2, 4), array(5, 2)); for ($i = 0; $i < 10; $i++) { caca_set_color_ansi($canvas, 1 + ($color += 4) % 15, CACA_TRANSPARENT); $scale = caca_rand(4, 10) / 10; $translate = array(caca_rand(-5, 55), caca_rand(-2, 25)); $pts = transform($tbl, $translate[0], $translate[1], $scale, $scale); caca_draw_thin_polyline($canvas, $pts); } caca_put_str($canvas, 1, 1, "Caca forever..."); caca_refresh_display($display); caca_get_event($display, CACA_EVENT_KEY_PRESS, 5000000);
<?php $export_php = isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : 'export.php'; ?> <iframe frameborder="0" name="preview" id="preview" width="820" height="620" style="margin: 0; padding: 0; border: none; width: 100%"></iframe> </body> </html> <?php exit(0); } if ($file) { $cv = caca_create_canvas(0, 0); if (caca_import_file($cv, $file, "") < 0) { die("`" . htmlspecialchars($filename) . "' has unknown format\n"); } } else { $cv = caca_create_canvas(WIDTH, HEIGHT); for ($y = 0; $y < 256; $y++) { for ($x = 0; $x < 256; $x++) { $r = $x; $g = (255 - $y + $x) / 2; $b = $y * (255 - $x) / 256; imagesetpixel($pixels, $x, $y, imagecolorallocate($pixels, $r, $g, $b)); } } $dither = caca_create_dither($pixels); if ($format == "ansi" || $format == "utf8") { caca_set_dither_charset($dither, "shades"); } caca_dither_bitmap($cv, 0, 0, caca_get_canvas_width($cv), caca_get_canvas_height($cv), $dither, $pixels); caca_set_color_ansi($cv, CACA_WHITE, CACA_BLACK); caca_draw_thin_box($cv, 0, 0, WIDTH - 1, HEIGHT - 1);
if (php_sapi_name() != "cli") { die("You have to run this program with php-cli!\n"); } $pig = ",--. ,--.\n" . "\\ /-~-\\ /\n" . " )' o O `(\n" . "( ,---. )\n" . " `(_o_o_)'\n" . " )`-'(\n"; $duck = " ,~~.\n" . " __ , ( O )>\n" . "___( o)> )`~~' (\n" . "\\ <_. ) ( .__) )\n" . " `---' `-.____,'\n"; $cv = caca_create_canvas(0, 0); if (!$cv) { die("Can't created canvas\n"); } $dp = caca_create_display($cv); if (!$dp) { die("Can't create display\n"); } $image = caca_create_canvas(70, 6); $tmp = caca_create_canvas(70, 6); $sprite = caca_create_canvas(0, 0); caca_set_color_ansi($sprite, CACA_LIGHTMAGENTA, CACA_BLACK); caca_import_string($sprite, $pig, "text"); caca_blit($image, 55, 0, $sprite); caca_set_color_ansi($sprite, CACA_LIGHTGREEN, CACA_BLACK); caca_import_string($sprite, $duck, "text"); caca_blit($image, 30, 1, $sprite); caca_set_color_ansi($image, CACA_LIGHTCYAN, CACA_BLACK); caca_put_str($image, 1, 1, "hahaha mais vieux porc immonde !! [⽼ ⾗]"); caca_set_color_ansi($image, CACA_LIGHTRED, CACA_BLACK); caca_put_char($image, 38, 1, ord('|')); caca_set_color_ansi($image, CACA_YELLOW, CACA_BLACK); caca_put_str($image, 4, 2, "\\o\\ \\o| _o/ \\o_ |o/ /o/"); caca_set_color_ansi($image, CACA_WHITE, CACA_LIGHTRED); caca_put_str($image, 7, 3, "▙▘▌▙▘▞▖▞▖▌ ▞▖▌ ▌▌"); caca_put_str($image, 7, 4, "▛▖▌▛▖▚▘▚▘▚▖▚▘▚▖▖▖");
* * This file is a Php port of "examples/truecolor.c" * which is: * Copyright (c) 2006 Sam Hocevar <*****@*****.**> * All Rights Reserved * * 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 F**k You Want * to Public License, Version 2, as published by Sam Hocevar. See * http://www.wtfpl.net/ for more details. */ if (php_sapi_name() != "cli") { die("You have to run this program with php-cli!\n"); } $cv = caca_create_canvas(32, 16); if (!$cv) { die("Failed to create canvas\n"); } $dp = caca_create_display($cv); if (!$dp) { die("Failed to create display\n"); } for ($y = 0; $y < 16; $y++) { for ($x = 0; $x < 16; $x++) { $bgcolor = 0xff00 | $y << 4 | $x; $fgcolor = 0xf000 | 15 - $y << 4 | 15 - $x << 8; caca_set_color_argb($cv, $fgcolor, $bgcolor); caca_put_str($cv, $x * 2, $y, "CA"); } }
* http://www.wtfpl.net/ for more details. */ if (php_sapi_name() != "cli") { die("You have to run this program with php-cli!\n"); } define('CACA', "쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊"); $cv = caca_create_canvas(0, 0); if (!$cv) { die("Can't created canvas\n"); } $dp = caca_create_display($cv); if (!$dp) { die("Can't create display\n"); } $caca = caca_create_canvas(6, 10); $line = caca_create_canvas(2, 1); /* Line of x's */ for ($i = 0; $i < 10; $i++) { caca_set_color_ansi($caca, CACA_WHITE, CACA_BLUE); caca_put_str($caca, 0, $i, CACA); caca_set_color_ansi($caca, CACA_WHITE, CACA_RED); caca_put_char($caca, $i - 2, $i, ord('x')); } caca_blit($cv, 1, 1, $caca); /* Line of ホ's */ for ($i = 0; $i < 10; $i++) { caca_set_color_ansi($caca, CACA_WHITE, CACA_BLUE); caca_put_str($caca, 0, $i, CACA); caca_set_color_ansi($caca, CACA_WHITE, CACA_GREEN); caca_put_str($caca, $i - 2, $i, "ホ"); }
if (php_sapi_name() != "cli") { die("You have to run this program with php-cli!\n"); } $string = <<<EOT |_| _,----._ | | (/ @ @ \\) __ | OO | |_ \\ `--' / |__ `----' |_| Hello world! | EOT; $pig = caca_create_canvas(0, 0); caca_import_string($pig, $string, "text"); $cv = caca_create_canvas(caca_get_canvas_width($pig) * 2, caca_get_canvas_height($pig) * 2); if (!$cv or !$pig) { die("Can't created canvas\n"); } caca_blit($cv, 0, 0, $pig); caca_flip($pig); caca_blit($cv, caca_get_canvas_width($pig), 0, $pig); caca_flip($pig); caca_flop($pig); caca_blit($cv, 0, caca_get_canvas_height($pig), $pig); caca_flop($pig); caca_rotate_180($pig); caca_blit($cv, caca_get_canvas_width($pig), caca_get_canvas_height($pig), $pig); for ($j = 0; $j < caca_get_canvas_height($cv); $j++) { for ($i = 0; $i < caca_get_canvas_width($cv); $i += 2) { caca_set_color_ansi($cv, CACA_LIGHTBLUE + ($i + $j) % 6, CACA_DEFAULT);
function main() { $cv = caca_create_canvas(0, 0); if (!$cv) { die("Error while creating canvas\n"); } $dp = caca_create_display($cv); if (!$dp) { die("Error while attaching canvas to display\n"); } caca_set_display_time($dp, 40000); /* Disable X cursor */ caca_set_mouse($dp, 0); /* Main menu */ $bounds = $outline = $dithering = 0; display_menu($cv, $dp, $bounds, $outline); /* Go ! */ $need_refresh = false; $quit = 0; while (!$quit) { while ($ev = caca_get_event($dp, CACA_EVENT_ANY, 1000)) { if (caca_get_event_type($ev) & CACA_EVENT_KEY_PRESS) { switch (caca_get_event_key_ch($ev)) { case ord('q'): case ord('Q'): case CACA_KEY_ESCAPE: $demo = false; $quit = 1; break; case ord('o'): case ord('O'): $outline = ($outline + 1) % 3; display_menu($cv, $dp, $bounds, $outline); break; case ord('b'): case ord('B'): $bounds = ($bounds + 1) % 2; display_menu($cv, $dp, $bounds, $outline); break; case ord('d'): case ord('D'): $dithering = ($dithering + 1) % 5; caca_set_feature($cv, $dithering); display_menu($cv, $dp, $bounds, $outline); break; case ord('f'): case ord('F'): demo_go($dp, "demo_all", $cv, $bounds, $outline); break; case ord('1'): demo_go($dp, "demo_dots", $cv, $bounds, $outline); break; case ord('2'): demo_go($dp, "demo_lines", $cv, $bounds, $outline); break; case ord('3'): demo_go($dp, "demo_boxes", $cv, $bounds, $outline); break; case ord('4'): demo_go($dp, "demo_triangles", $cv, $bounds, $outline); break; case ord('5'): demo_go($dp, "demo_ellipses", $cv, $bounds, $outline); break; case ord('s'): case ord('S'): demo_go($dp, "demo_sprites", $cv, $bounds, $outline); break; case ord('r'): case ord('R'): demo_go($dp, "demo_render", $cv, $bounds, $outline); break; } } else { if (caca_get_event_type($ev) & CACA_EVENT_MOUSE_MOTION) { $x = caca_get_event_mouse_x($ev); $y = caca_get_event_mouse_y($ev); display_menu($cv, $dp, $bounds, $outline, false); caca_set_color_ansi($cv, CACA_RED, CACA_BLACK); caca_put_str($cv, $x, $y, "."); caca_put_str($cv, $x, $y + 1, "|\\"); $need_refresh = true; } else { if (caca_get_event_type($ev) & CACA_EVENT_RESIZE) { display_menu($cv, $dp, $bounds, $outline); } } } } if ($need_refresh) { caca_refresh_display($dp); $need_refresh = false; } } }