Voting

: seven plus one?
(Example: nine)

The Note You're Voting On

chandlerklebs at gmail dot com
13 years ago
This is an example script I wrote for myself to help me learn how to used the imagearc functions. Maybe if will also help others.

<?php
//example PHP script of imagearc functions
$image_width=360;$image_height=360;
$img = imagecreatetruecolor($image_width,$image_height); //make image variable

//create a background color by making a filled rectangle
$color = imagecolorallocate($img,255,255,255);
imagefilledrectangle($img,0,0,$image_width,$image_height,$color);

$r=$image_width/2 - $image_width/32 ; //radius
$cx=$image_width/2;
$cy=$image_height/2;

$color = imagecolorallocate($img,0,0,0);
imagearc($img, $cx, $cy, $r*2, $r*2, 0, 360, $color); //regular outlines arc

imagefilledarc($img, $cx, $cy, $r*1, $r*1, 0, 90, $color,IMG_ARC_CHORD); //filled triangle with chord of circle
imagefilledarc($img, $cx, $cy, $r*1, $r*1, 180, 270, $color,IMG_ARC_PIE); //pie slice

$font_number=5; //can use built in fonts numbered 1 to 5
$string="Hello world!";
imagestring($img, $font_number, $cx-(imagefontwidth($font_number)*strlen($string))/2, $cy-120, $string, $color);

header("Content-type: image/png");
imagepng($img);// output image in the browser

$filename="imagearc";
imagepng($img,"./frames/$filename.png",9); //make highly compressed png

imagedestroy($img);
?>

<< Back to user notes page

To Top