diplomat.utils.shapes.DotShapeDrawer¶
- class diplomat.utils.shapes.DotShapeDrawer[source]¶
Bases:
ABCAbstract class defining an interface for drawing various markers, or dots, based on shape.
- Note: To make a shape drawer, subclass this and implement the required abstract methods. Also, any
additional methods you define that start with ‘_draw_’ (such as ‘_draw_hexagon’) and implement the correct signiture (3 floats: x coordinate, y coordinate, and radius) will automatically be registered as an additional shape to draw. The name of the shape will be the method name excluding the ‘_draw_’ prefix. (‘_draw_hexagon’ adds a shape called ‘hexagon’)
- __init__()¶
Methods
__init__()Attributes
SHAPE_TYPES- __contains__(shape: str) bool[source]¶
Check if this shape drawer supports this shape.
- Parameters:
shape – A string representing a shape type (“square”, “circle”, etc.)
- Returns:
True if this shape drawer supports that shape, otherwise False.
- __getitem__(shape: str) Callable[[float, float, float], None][source]¶
Get a drawer for the provided shape type.
- Parameters:
shape – The shape to get a drawing function for, all drawers must support “circle”, “square”, “triangle”, and “star”.
- Returns:
A function or callable which accepts 3 floats (x coordinate, y coordinate, shape radius), that draws a shape marker to the specified location when called.
- __iter__()[source]¶
Iterate over the names of the set of supported shapes.
- Returns:
Iterable of strings, the supported shapes by their names (“square”, “circle”, etc.)
- __len__()[source]¶
Get the number of supported shapes.
- Returns:
The number of supported shapes, and integer.
- abstractmethod _draw_circle(x: float, y: float, r: float)[source]¶
Private: Draw a circle at the given x and y position, with the provided radius.
- abstractmethod _draw_square(x: float, y: float, r: float)[source]¶
Private: Draw a square at the given x and y position, with the provided radius.