note 107923 added to function.imageline
| From: | Nils | Date: | Thu, 15 Mar 2012 00:57:47 +0000 |
| Subject: | note 107923 added to function.imageline | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186671@lists.php.net to get a copy of this message | ||
A quick function using imageline that I wrote so i could specify a starting point, angle and length
of vector.
Thought other people might find this useful.
<?php
$size = 600;
$img = imagecreatetruecolor($size, $size);
$white = imagecolorallocate($img, 255, 255, 255);
$black = imagecolorallocate($img, 0, 0, 0);
imagefilledrectangle($img,0,0,$size,$size,$white);
function Vector($palette,$startx,$starty,$angle,$length,$colour){
$angle = deg2rad($angle);
$endx = $startx+cos($angle)*$length;
$endy = $starty-sin($angle)*$length;
return(imageline($palette,$startx,$starty,$endx,$endy,$colour));
}
Vector($img,$size/2,$size/2,30,200,$black);
header("Content-type: image/png");
imagepng($img);
?>
For this script angles work in a anti-clockwise direction (modify + and - in function to change
start of 0 degrees and also direction of angle calculated)
----
Server IP: 69.147.83.197
Probable Submitter: 101.162.53.61
----
Manual Page -- http://www.php.net/manual/en/function.imageline.php
Edit -- https://master.php.net/note/edit/107923
Del: integrated -- https://master.php.net/note/delete/107923/integrated
Del: useless -- https://master.php.net/note/delete/107923/useless
Del: bad code -- https://master.php.net/note/delete/107923/bad+code
Del: spam -- https://master.php.net/note/delete/107923/spam
Del: non-english -- https://master.php.net/note/delete/107923/non-english
Del: in docs -- https://master.php.net/note/delete/107923/in+docs
Del: other reasons-- https://master.php.net/note/delete/107923
Reject -- https://master.php.net/note/reject/107923
Search -- https://master.php.net/manage/user-notes.php