prtools.hexagon#

hexagon(shape, radius, shift=(0, 0), rotate=False, antialias=True)[source]#

Draw a hexagon

Parameters:
  • shape (array_like) – Size of output in pixels (nrows, ncols)

  • radius (float) – Radius of outscribing circle (which also equals the side length) in pixels.

  • shift (tuple of floats, optional) – How far to shift center in (rows, cols). Default is (0, 0).

  • rotate (bool, optional) – Rotate mask so that flat sides are aligned with the Y direction instead of the default orientation which is aligned with the X direction.

  • antialias (bool, optional) – If True (default), the shape edges are antialiased.

Return type:

ndarray

Examples

>>> hex = prtools.hexagon(shape=(256,256), radius=75)
>>> plt.imshow(hex, cmap='gray')
../_images/prtools-hexagon-1.png
>>> hex = prtools.hexagon(shape=(256,256), radius=75, rotate=True)
>>> plt.imshow(hex, cmap='gray')
../_images/prtools-hexagon-2.png