Circles are drawn by calculating a 2D array of Euclidean distances and clipping:
Here is the code that creates the circle:
.. literalinclude:: circle.py
- the
np.ogrid
function creates two 2D-array of the X/Y coordinates - the
square_dist
contains the squared distance to the center for each pixel - for the mask, the rule of Pythagoras is applied to select points inside the circle
Adopt the code to create patterns from circles, e.g.: