Exemple #1
0
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");
}
Exemple #2
0
 function putChar($x, $y, $c)
 {
     return caca_put_char($this->cv, $x, $y, $c);
 }
Exemple #3
0
    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];
}
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)) {
Exemple #4
0
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, "▛▖▌▛▖▚▘▚▘▚▖▚▘▚▖▖▖");
caca_set_color_ansi($image, CACA_BLACK, CACA_LIGHTRED);
caca_put_str($image, 4, 3, "▓▒░");
caca_put_str($image, 4, 4, "▓▒░");
caca_put_str($image, 24, 3, "░▒▓");
caca_put_str($image, 24, 4, "░▒▓");
/* Blit the transformed canvas onto the main canvas */
caca_set_color_ansi($cv, CACA_WHITE, CACA_BLUE);
caca_put_str($cv, 0, 0, "normal");
caca_blit($cv, 10, 0, $image);
caca_put_str($cv, 0, 6, "flip");
Exemple #5
0
$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, "ホ");
}
caca_blit($cv, 15, 1, $caca);
/* Line of canvas */
caca_set_color_ansi($line, CACA_WHITE, CACA_MAGENTA);
caca_put_str($line, 0, 0, "ほ");
for ($i = 0; $i < 10; $i++) {
    caca_set_color_ansi($caca, CACA_WHITE, CACA_BLUE);
Exemple #6
0
function demo_dots($cv, $bounds, $outline)
{
    $xmax = caca_get_canvas_width($cv);
    $ymax = caca_get_canvas_height($cv);
    $chars = array('+', '-', '*', '#', 'X', '@', '%', '$', 'M', 'W');
    for ($i = 1000; $i--;) {
        /* Putpixel */
        caca_set_color_ansi($cv, caca_rand(0, 16), caca_rand(0, 16));
        caca_put_char($cv, caca_rand(0, $xmax), caca_rand(0, $ymax), ord($chars[caca_rand(0, 9)]));
    }
}