Exemple #1
0
     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);
 caca_set_color_ansi($cv, CACA_BLACK, CACA_WHITE);
 caca_fill_ellipse($cv, WIDTH / 2, HEIGHT / 2, WIDTH / 4, HEIGHT / 4, ord(' '));
 caca_set_color_ansi($cv, CACA_LIGHTGRAY, CACA_BLACK);
 caca_put_str($cv, WIDTH / 2 - 12, HEIGHT / 2 - 6, "   lightgray on black   ");
 caca_set_color_ansi($cv, CACA_DEFAULT, CACA_TRANSPARENT);
 caca_put_str($cv, WIDTH / 2 - 12, HEIGHT / 2 - 5, " default on transparent ");
 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");
Exemple #2
0
 function fillEllipse($x1, $y1, $x2, $y2, $char)
 {
     return caca_fill_ellipse($this->cv, $x1, $y1, $x2, $y2, $char);
 }
Exemple #3
0
function demo_ellipses($cv, $bounds, $outline)
{
    $w = caca_get_canvas_width($cv);
    $h = caca_get_canvas_height($cv);
    if ($bounds) {
        $x = caca_rand(-$w, 2 * $w);
        $y = caca_rand(-$h, 2 * $h);
        $a = caca_rand(0, $w);
        $b = caca_rand(0, $h);
    } else {
        do {
            $x = caca_rand(0, $w);
            $y = caca_rand(0, $h);
            $a = caca_rand(0, $w);
            $b = caca_rand(0, $h);
        } while ($x - $a < 0 || $x + $a >= $w || $y - $b < 0 || $y + $b >= $h);
    }
    caca_set_color_ansi($cv, caca_rand(0, 16), caca_rand(0, 16));
    caca_fill_ellipse($cv, $x, $y, $a, $b, ord('#'));
    caca_set_color_ansi($cv, caca_rand(0, 16), CACA_BLACK);
    if ($outline == 2) {
        caca_draw_thin_ellipse($cv, $x, $y, $a, $b);
    } else {
        if ($outline == 1) {
            caca_draw_ellipse($cv, $x, $y, $a, $b, ord('#'));
        }
    }
}