scistag.shapestag.checkerboard.Checkerboard

class Checkerboard(bounding=None, col_row_count=None, tile_size=16.0, color_a=Color(r=0.0, g=0.0, b=0.0, a=1.0, _rgba=(0.0, 0.0, 0.0, 1.0), _int_rgba=(0, 0, 0, 255)), color_b=Color(r=1.0, g=1.0, b=1.0, a=1.0, _rgba=(1.0, 1.0, 1.0, 1.0), _int_rgba=(255, 255, 255, 255)), offset=None)[source]

Bases: Shape

A checkerboard either defined by a count of columns and rows or an area it shall cover.

Draws a grid of rectangles using two different colors, for example to draw a checkerboard for calibration purposes or to use it as background, e.g. for transparent images to be better able to distinguish transparent and non-transparent areas as seen in common photo editing apps.

Parameters
  • bounding (Bounding2DTypes) – The region to be covered in pixels

  • col_row_count (Size2DTypes | None) – The count of columns and rows (alternative to region)

  • tile_size (float) – The size per tile

  • color_a (ColorTypes) – The first color (used for all uneven fields (col+row))

  • color_b (ColorTypes) – The second color (used for all even fields (col+row))

  • offset (Pos2DTypes | None) – The offset in pixels by which the grid shall be moved

Methods

draw

Draws the shape into the defined canvas

get_hash

A unique hash of the data in this shape.

to_image

Renders the shape to an image.

Attributes

HASHABLE_PROPERTIES

__annotations__

__dataclass_fields__

__dataclass_params__

__dict__

__doc__

__hash__

__module__

__weakref__

list of weak references to the object (if defined)

bounding

The region to be covered overall

color_a

The first color (used for all uneven fields)

color_b

The first color (used for all even fields)

columns

The column count (horizontal grid width)

rows

The row count (vertical grid height)

shape_class

The shape's class

tile_size

The tile size in pixels

draw(target, options=None)[source]

Draws the shape into the defined canvas

Parameters
  • target (Canvas) – The canvas to render onto

  • options (dict | None) – Advanced options, such as the cache in which the shape might be cached.

get_hash()

A unique hash of the data in this shape. Is used to cache the shape’s renderings when it has not been modified.

Return type

str

Returns

The hash value

to_image(background_color=Color(r=0.0, g=0.0, b=0.0, a=0.0, _rgba=(0.0, 0.0, 0.0, 0.0), _int_rgba=(0, 0, 0, 0)))

Renders the shape to an image.

The shape needs to either specify it’s bounding or it’s size as member variable to be convertible.

Parameters

background_color – The background color

Return type

Image

bounding: Bounding2D = Bounding2D(0.0,0.0,0.0,0.0)

The region to be covered overall

color_a: Color = Color(r=0.0, g=0.0, b=0.0, a=1.0, _rgba=(0.0, 0.0, 0.0, 1.0), _int_rgba=(0, 0, 0, 255))

The first color (used for all uneven fields)

color_b: Color = Color(r=1.0, g=1.0, b=1.0, a=1.0, _rgba=(1.0, 1.0, 1.0, 1.0), _int_rgba=(255, 255, 255, 255))

The first color (used for all even fields)

columns: int = 16

The column count (horizontal grid width)

rows: int = 16

The row count (vertical grid height)

shape_class: str = ''

The shape’s class

tile_size: Size2D = Size2D(16.0,16.0)

The tile size in pixels