prtools.hexagon#

hexagon(shape, radius, shift=(0, 0), rotate=True, antialias=True, indexing='ij')[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. Default is (0, 0).

  • rotate (bool, optional) – If True (default), the mask is rotated so that the flat sides are aligned with the horizontal direction.

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

  • indexing ({'ij', 'xy'}, optional) – Matrix (‘ij’, default) or cartesian (‘xy’) indexing of shift.

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=False)
>>> plt.imshow(hex, cmap='gray')
../_images/prtools-hexagon-2.png