PHP/Graphics Image/Line
Drawing a Line with imageline()
<?php
header("Content-type: image/gif");
$image = imagecreate( 200, 200 );
$red = imagecolorallocate($image, 255,0,0);
$blue = imagecolorallocate($image, 0,0,255 );
imageline( $image, 0, 0, 199, 199, $blue );
imagegif($image);
?>
Drawing Lines
<?php
header ("Content-type: image/png");
$im = ImageCreate (150, 150);
$grey = ImageColorAllocate ($im, 230, 230, 230);
$black = ImageColorAllocate ($im, 0, 0, 0);
ImageLine($im, 0, 30, 150, 150, $black);
ImageLine($im, 0, 150, 150, 30, $black);
ImageLine($im, 0, 30, 150, 30, $black);
ImageString($im, 3, 5, 5, "Figure 18.6: Lines", $black);
ImagePng ($im);
ImageDestroy ($im);
?>
Using imagefill()
<?php
header("Content-type: image/gif");
$image = imagecreate( 200, 200 );
$red = imagecolorallocate($image, 255,0,0);
$blue = imagecolorallocate($image, 0,0,255 );
imageline( $image, 0, 0, 199, 199, $blue );
imagefill( $image, 0, 199, $blue );
imagegif($image);
?>