I would like to draw a rectangle at an angle with PHP. I know that you can draw rectangles with PHP using imagefilledrectangle but how to draw it an an angle.
public function drawshelf($x1, $y1, $x2, $y2, $width, $angle = 'false'){
imagesetthickness ( $this->canvas, 1 );
for ($i=0; $i < $width; $i++){ //HORIZONTAL
imageline( $this->canvas, $x1, $y1, $x2, $y2, $this->color );
$y1++; $y2++;
if( $angle == 'true' ){ $x1--; $x2--; }
}
}
I wrote this function to draw it using lines and a loop but its not coming up right like the red box.
Can someone please tell me what am i doing wrong? And can you even draw it like that?

Use
imagepolygon()orimagefilledpolygon()to draw non-rectangular shapes using GD. You may need to review a bit of trigonometry to figure out how to position the points to get right-angle corners.