PHP/Graphics Image/imagearc

Материал из Web эксперт
Перейти к: навигация, поиск

Drawing a Circle with imagearc()

 
<?php
header("Content-type: image/png");
$image = imagecreate( 200, 200 );
$red = imagecolorallocate($image, 255,0,0);
$blue = imagecolorallocate($image, 0,0,255 );
imagearc( $image, 99, 99, 180, 180, 0, 360, $blue );
imagefill( $image, 99, 99, $blue );
imagepng($image);
?>



Using imagearc() to Draw Spirals

 
<?php
    define("WIDTH", 400);
    define("HEIGHT", 400);
    $img = imagecreate(WIDTH, HEIGHT);
    $bg = $white = imagecolorallocate($img, 0xFF, 0xFF, 0xFF);
    $black = imagecolorallocate($img, 0, 0, 0);
    imagerectangle($img, 0, 0, WIDTH-1, HEIGHT-1, $black);
    $center_x = (int)WIDTH/2;
    $center_y = (int)HEIGHT/2;
    $angle = 0;
    $radius = 0;
    while($radius <= WIDTH ) {
        imagearc($img, $center_x, $center_y, $radius,
                 $radius, $angle-5, $angle, $black);
        $angle += 5;
        $radius++;
    }
    header("Content-Type: image/png");
    imagepng($img);
?>