Example #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");
}
Example #2
0
File: caca.php Project: dns/libcaca
 function getAttr($x, $y)
 {
     return caca_get_attr($this->cv, $x, $y);
 }
Example #3
0
File: text.php Project: dns/libcaca
   \\ `--' /   |__
    `----'
              |_|
 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);
        $a = caca_get_attr($cv, -1, -1);
        caca_put_attr($cv, $i, $j, $a);
        caca_put_attr($cv, $i + 1, $j, $a);
    }
}
echo caca_export_string($cv, "utf8");
caca_rotate_left($cv);
echo caca_export_string($cv, "utf8");