# Token.Shape¶

## Shape¶

class miniworldmaker.tokens.shapes.Shape(*args, **kwargs)[source]

Base class for Shapes

### Point¶

class miniworldmaker.tokens.shapes.Point(*args, **kwargs)[source]

A Point-Shape

Parameters
• position – The position as 2-tuple

• thickness – The thickness of the point (1: pixel, >1: The point is rendered as circle)

• color – The color as 4-tuple (r, g, b, alpha)

Examples

Creates a red point at position (200,100):

>>> Point((200, 100), 1, color=(255,0,0,255))

### Circle¶

class miniworldmaker.tokens.shapes.Circle(*args, **kwargs)[source]

A Circle-Shape.

Parameters
• position – The position as 2-tuple. The circle is created with its center at the position

• radius – The radius of the circle

• thickness – The thickness of the bounding line (0: The object is filled)

• color – The color as 4-tuple (r, g, b, alpha)

Examples

Example Creation of a circle

>>> Circle((200, 100), 20, 1, color=(255,0,0,255))
Creates a red circle at position (200,100) with radius 20

Example Creation of a filled circle

>>> Circle((200, 100), 20, 0, color=(255,0,0,255))
Creates a red circle at position (200,100) with radius 20. The circle is filled

Gets the radius of the circle. If you change the circle-size (e.g. with self.size = (x, y), the radius value will be changed too.

### Ellipse¶

class miniworldmaker.tokens.shapes.Ellipse(*args, **kwargs)[source]

An Ellipse-Shape.

Parameters
• position – The position as 2-tuple. The circle is created with its center at the position

• width – The width of the ellipse

• height – The height of the ellipse

• thickness – The thickness of the bounding line (0: The object is filled)

• color – The color as 4-tuple (r, g, b, alpha)

Examples

Example Creation of an ellipse

>>> Circle((200, 100), 20, 40, 1, color=(255,0,0,255))
Creates an red ellise at position (200,100) with width 20 and height 40

Example Creation of a filled ellipse

>>> Circle((200, 100), 20, 40, 0, color=(255,0,0,255))
Creates a red circle at position (200,100) with width 20 and height 40. The ellipse is filled
property height

Gets the height of the ellipse If you change the ellipse-size (e.g. with self.size = (x, y), the value will be changed too.

Returns: The height of the ellipse

property width

Gets the width of the ellipse If you change the ellipse-size (e.g. with self.size = (x, y), the value will be changed too.

Returns: The width of the ellipse

### Line¶

class miniworldmaker.tokens.shapes.Line(*args, **kwargs)[source]

A Line-Shape.

Parameters
• start_position – The start_position as 2-tuple.

• end_position – The end_position as 2-tuple.

• thickness – The thickness of the bounding line

• color – The color as 4-tuple (r, g, b, alpha)

Examples

Example Creation of a line

>>> Line((200, 100), (400,100), 1, color=(255,0,0,255))
Creates a line from (200, 100) to (400, 100)

### Rectangle¶

class miniworldmaker.tokens.shapes.Rectangle(*args, **kwargs)[source]

A Rect-Shape.

Parameters
• topleft – Topleft Position of Rect

• height – The height of the rect

• width – The width of the rect

• thickness – The thickness of the bounding line

• color – The color as 4-tuple (r, g, b, alpha)

Examples

Example Creation of a polygon

>>> Rectangle((200, 100), 10, 10, 1, color=(255,0,0,255))
Creates a red rect with the topleft position (200, 100), the height 10 and the width 10

### Polygon¶

class miniworldmaker.tokens.shapes.Polygon(*args, **kwargs)[source]

A Polygon-Shape.

Parameters
• point-list – A list of points

• thickness – The thickness of the bounding line

• color – The color as 4-tuple (r, g, b, alpha)

Examples

Example Creation of a polygon

>>> Polygon([(200, 100), (400,100), (0, 0)], 1, color=(255,0,0,255))
Creates a red polygon with the vertices (200, 100) , (400, 100) and (0, 0)

Example Creation of a filled polygon

>>> Polygon([(200, 100), (400,100), (0, 0)], 0, color=(255,0,0,255))
Creates a red polygon with the vertices (200, 100) , (400, 100) and (0, 0)