title: Draw a rectangle with PHP at an angle
body: <p>I would like to draw a rectangle at an angle with PHP. I know that you can draw rectangles with PHP using <code>imagefilledrectangle</code> but how to draw it an an angle.</p>
  
  <pre><code>public function drawshelf($x1, $y1, $x2, $y2, $width, $angle = 'false'){
      imagesetthickness ( $this-&gt;canvas, 1 );
      for ($i=0; $i &lt; $width; $i++){ //HORIZONTAL
          imageline( $this-&gt;canvas, $x1, $y1, $x2, $y2, $this-&gt;color );
          $y1++; $y2++;
          if( $angle == 'true' ){ $x1--; $x2--; }
      }
  }
  </code></pre>
  
  <p>I wrote this function to draw it using lines and a loop but its not coming up right like the red box.</p>
  
  <p>Can someone please tell me what am i doing wrong? And can you even draw it like that?</p>
  
  <p><img src="https://i.stack.imgur.com/ymwoO.png" alt="enter image description here"></p>