Пример #1
0
 function drawThinTriangle($x1, $y1, $x2, $y2, $x3, $y3)
 {
     return caca_draw_thin_triangle($this->cv, $x1, $y1, $x2, $y2, $x3, $y3);
 }
Пример #2
0
function demo_triangles($cv, $bounds, $outline)
{
    $w = caca_get_canvas_width($cv);
    $h = caca_get_canvas_height($cv);
    if ($bounds) {
        $xa = caca_rand(-$w, 2 * $w);
        $ya = caca_rand(-$h, 2 * $h);
        $xb = caca_rand(-$w, 2 * $w);
        $yb = caca_rand(-$h, 2 * $h);
        $xc = caca_rand(-$w, 2 * $w);
        $yc = caca_rand(-$h, 2 * $h);
    } else {
        $xa = caca_rand(0, $w);
        $ya = caca_rand(0, $h);
        $xb = caca_rand(0, $w);
        $yb = caca_rand(0, $h);
        $xc = caca_rand(0, $w);
        $yc = caca_rand(0, $h);
    }
    caca_set_color_ansi($cv, caca_rand(0, 16), caca_rand(0, 16));
    caca_fill_triangle($cv, $xa, $ya, $xb, $yb, $xc, $yc, ord('#'));
    caca_set_color_ansi($cv, caca_rand(0, 16), CACA_BLACK);
    if ($outline == 2) {
        caca_draw_thin_triangle($cv, $xa, $ya, $xb, $yb, $xc, $yc);
    } else {
        if ($outline == 1) {
            caca_draw_triangle($cv, $xa, $ya, $xb, $yb, $xc, $yc, ord('#'));
        }
    }
}