How to draw rotated stripe patterns
<p>I want to draw stripe patterns given a rotated angle. I figured out how to draw vertical lines but not rotated. For example, given the image below with an input of 45 degrees I want to generate the second image.</p>

<p>Here's my code for generating the first image:
from <strong>future</strong> import division</p>

<pre><code>import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
stripe_width = 15
gap = 20
offset = 2
image_size = 250

canvas = np.zeros((image_size, image_size))
current_col = 0
while current_col &lt; image_size:
    if current_col + stripe_width + gap &lt;= image_size-1:
        canvas[:, current_col:current_col+stripe_width] = 1
        current_col += stripe_width + gap
    elif current_col + stripe_width &lt;= image_size-1:
        canvas[:, current_col:current_col+stripe_width] = 1
        current_col = image_size
    else:
        canvas[:, current_col:] = 1
        current_col = image_size

plt.imshow(canvas)
</code></pre>

<p>And here's the image output from my code:
<a href="http://i.stack.imgur.com/nJJ9m.png" rel="nofollow">Current Output</a></p>

<p>And here's what I want the rotated image to look like:
<a href="http://i.stack.imgur.com/inCNQ.png" rel="nofollow">Desired Output</a></p>

<p>Any suggestions?</p>

<p>You need to have a rotate method with respect to some <code>center</code>. For example below is a sample method. You will have to modify it for your needs, but that should be sufficient to start your code</p>

<pre><code> def rotate_point(center, point, angle):
        """Rotate point around center by angle
        Args:
            center: 
                Center point (tuple, [x,y])
            point: 
                Point to be rotated (tuple, [x,y])
            angle: 
                Angle in radians to rotate by

        Returns:
            New coordinates for the point
        """
        angle = math.radians(angle)
        temp_point = point[0]-center[0] , point[1]-center[1]
        temp_point = ( -temp_point[0]*math.cos(angle)+temp_point[1]*math.sin(angle) , temp_point[0]*math.sin(angle)-temp_point[1]*math.cos(angle))
        temp_point = [temp_point[0]+center[0] , temp_point[1]+center[1]]
        return temp_point
</code></pre>

python numpy