caca_set_color_ansi($cv, CACA_BLACK, CACA_WHITE); caca_put_str($cv, WIDTH / 2 - 12, HEIGHT / 2 - 4, " black on white "); caca_set_color_ansi($cv, CACA_BLACK, CACA_WHITE); caca_put_str($cv, WIDTH / 2 - 8, HEIGHT / 2 - 3, "[<><><><> <>--<>]"); caca_put_str($cv, WIDTH / 2 - 8, HEIGHT / 2 - 2, "[ドラゴン ボーレ]"); caca_put_str($cv, WIDTH / 2 - 7, HEIGHT / 2 + 2, "äβç ░▒▓█▓▒░ ΔЗҒ"); caca_put_str($cv, WIDTH / 2 - 5, HEIGHT / 2 + 4, "(\") \\o/ <&>"); caca_set_attr($cv, CACA_BOLD); caca_put_str($cv, WIDTH / 2 - 16, HEIGHT / 2 + 3, "Bold"); caca_set_attr($cv, CACA_BLINK); caca_put_str($cv, WIDTH / 2 - 9, HEIGHT / 2 + 3, "Blink"); caca_set_attr($cv, CACA_ITALICS); caca_put_str($cv, WIDTH / 2 - 1, HEIGHT / 2 + 3, "Italics"); caca_set_attr($cv, CACA_UNDERLINE); caca_put_str($cv, WIDTH / 2 + 8, HEIGHT / 2 + 3, "Underline"); caca_set_attr($cv, 0); caca_set_color_ansi($cv, CACA_WHITE, CACA_LIGHTBLUE); caca_put_str($cv, WIDTH / 2 - 7, HEIGHT / 2, " LIBCACA "); for ($x = 0; $x < 16; $x++) { caca_set_color_argb($cv, 0xff00 | $x, 0xf00f | $x << 4); caca_put_char($cv, WIDTH / 2 - 7 + $x, HEIGHT / 2 + 6, ord('#')); } } $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]; }
function setAttr($attr) { return caca_set_attr($this->cv, $x, $y, $attr); }
<body text="silver" bgcolor="black"> <?php $cv = caca_create_canvas(80, 24); if (!$cv) { die("Failed to create canvas\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_put_str($cv, 3 + 8, 20, "bold"); caca_set_attr($cv, CACA_BLINK); caca_put_str($cv, 3 + 24, 20, "blink"); caca_set_attr($cv, CACA_ITALICS); caca_put_str($cv, 3 + 41, 20, "italics"); caca_set_attr($cv, CACA_UNDERLINE); caca_put_str($cv, 3 + 60, 20, "underline"); echo caca_export_string($cv, "html3"); ?> </body> </html>