2D shapes

This section presents the main shape classes available in anim.plane, and how to control their geometry and style.

Available shapes

The following classes cover the standard 2D shapes.

Anchor point (reference point)

Each shape inherits from anim.plane.item and is positioned using a reference point (anchor point). This anchor is the point controlled by anim.plane.item.position (or by anim.plane.item.x and anim.plane.item.y).

The exact geometric meaning of the anchor depends on the shape:

C.item.rect = anim.plane.rectangle(dimension=[1.2, 0.6], center=[False, False])
C.item.rect.position = [0.0, 0.0]   # bottom-left corner at origin

Rotation and center of rotation

Rotations are controlled by anim.plane.item.orientation (in radians), or by calling anim.plane.item.rotate() for relative updates.

The pivot point is controlled by anim.plane.item.center_of_rotation:

  • for most shapes, default is [0, 0] in local item coordinates

  • for anim.plane.circle, the natural center rotation is obtained with center_of_rotation=[0, 0]

  • for polygons/paths, [0, 0] means rotating around the anchor point

import numpy as np

C.item.rect = anim.plane.rectangle(dimension=[1.4, 0.5], position=[0.5, -0.2])

# Absolute orientation (30 degrees)
C.item.rect.orientation = np.pi / 6

# Relative rotation (+15 degrees)
C.item.rect.rotate(np.pi / 12)

# Change pivot to the rectangle corner in local coordinates
C.item.rect.center_of_rotation = [0.7, 0.25]
C.item.rect.orientation = np.pi / 3

Geometry control by shape

Each shape exposes specific geometry attributes:

Style: fill and stroke

Shape style is controlled by four attributes settable directly on any shape instance, either at construction time or at runtime.

Attribute

Description

color

Fill color (string, hex, or [r, g, b] in [0, 1]). Set to None for no fill (transparent).

stroke

Contour color. Set to None (default) for no contour.

thickness

Contour thickness in scene units (default 0).

linestyle

Contour pattern: '-' solid, '--' dashed, ':' dotted, '-.' dash-dot.

C.item.ell = anim.plane.ellipse(dimension=[1.2, 0.5], position=[0.0, 0.0])

# Fill only
C.item.ell.color = '#4aa3ff'

# Fill + contour
C.item.ell.color = '#4aa3ff'
C.item.ell.stroke = 'white'
C.item.ell.thickness = 0.01

# Contour only (no fill)
C.item.ell.color = None
C.item.ell.stroke = 'white'
C.item.ell.thickness = 0.01
C.item.ell.linestyle = '--'

For anim.plane.line and anim.plane.path, there is no fill — only stroke, thickness, and linestyle apply.