simetri.graphics package¶
Submodules¶
simetri.graphics.affine module¶
Transformation matrices.
- simetri.graphics.affine.glide(points: Sequence[Sequence[float]], mirror_line: Sequence[Sequence], distance: float) ndarray [source]¶
Glide (mirror about a line then translate along the same line) points about a line.
- Parameters:
points (Sequence[Point]) – The points to glide.
mirror_line (Line) – The line to mirror about.
distance (float) – The distance to translate along the line.
- Returns:
The glided points.
- Return type:
np.ndarray
- simetri.graphics.affine.glide_matrix(mirror_line: Sequence[Sequence], distance: float) ndarray [source]¶
Return a glide-reflection matrix in row form. Reflect about the given vector then translate by dx along the same vector.
- Parameters:
mirror_line (Line) – The line to mirror about.
distance (float) – The distance to translate along the line.
- Returns:
The glide-reflection matrix.
- Return type:
np.ndarray
- simetri.graphics.affine.identity_matrix() ndarray [source]¶
Return the identity matrix [[1.0, 0, 0], [0, 1.0, 0], [0, 0, 1.0]].
- Returns:
The identity matrix.
- Return type:
np.ndarray
- simetri.graphics.affine.inv_glide_matrix(mirror_line: Sequence[Sequence], distance: float) ndarray [source]¶
Return the inverse of a glide-reflection matrix in row form. Reflect about the given vector then translate by dx along the same vector.
- Parameters:
mirror_line (Line) – The line to mirror about.
distance (float) – The distance to translate along the line.
- Returns:
The inverse glide-reflection matrix.
- Return type:
np.ndarray
- simetri.graphics.affine.inv_rotation_matrix(theta: float, about=(0, 0)) ndarray [source]¶
Construct the inverse of a rotation matrix that can be used to rotate a point about another point by theta float. Return a rotation matrix in row form dx, dy = about [[cos(theta), -sin(theta), 0], [sin(theta), cos(theta), 0], -cos(theta)dx-sin(theta)dy+x, -sin(theta)dx+cos(theta)dy+y, 1]].
- Parameters:
theta (float) – The rotation angle in radians.
about (tuple, optional) – The point to rotate about, defaults to (0, 0).
- Returns:
The inverse rotation matrix.
- Return type:
np.ndarray
- simetri.graphics.affine.inv_scale_matrix(scale_x: float, scale_y: float | None = None) ndarray [source]¶
Return the inverse of a scale matrix in row form.
- Parameters:
scale_x (float) – Scale factor in x direction.
scale_y (float, optional) – Scale factor in y direction, defaults to None.
- Returns:
The inverse of a scale matrix in row form.
- Return type:
np.ndarray
- simetri.graphics.affine.inv_shear_matrix(theta_x: float, theta_y: float = 0) ndarray [source]¶
Return the inverse of a shear matrix in row form.
- Parameters:
theta_x (float) – Angle of shear in x direction.
theta_y (float, optional) – Angle of shear in y direction, defaults to 0.
- Returns:
The inverse of a shear matrix in row form.
- Return type:
np.ndarray
- simetri.graphics.affine.inv_translation_matrix(dx: float, dy: float) ndarray [source]¶
Return the inverse of a translation matrix in row form [[1.0, 0, 0], [0, 1.0, 0], [-dx, -dy, 1.0]].
- Parameters:
dx (float) – The translation distance along the x-axis.
dy (float) – The translation distance along the y-axis.
- Returns:
The inverse translation matrix.
- Return type:
np.ndarray
- simetri.graphics.affine.mirror(points: Sequence[Sequence[float]], about: Sequence[Sequence]) ndarray [source]¶
Mirror points about a line.
- Parameters:
points (Sequence[Point]) – The points to mirror.
about (Line) – The line to mirror about.
- Returns:
The mirrored points.
- Return type:
np.ndarray
- simetri.graphics.affine.mirror_about_line_matrix(line: Sequence[Sequence]) ndarray [source]¶
Return a matrix to perform reflection about a line.
- Parameters:
line (Line) – The line about which the reflection is performed.
- Returns:
A matrix to perform reflection about a line.
- Return type:
np.ndarray
- simetri.graphics.affine.mirror_about_origin_matrix() ndarray [source]¶
Return a matrix to perform reflection about the origin.
- Returns:
A matrix to perform reflection about the origin.
- Return type:
np.ndarray
- simetri.graphics.affine.mirror_about_point_matrix(point: Sequence[float]) ndarray [source]¶
Return a matrix to perform reflection about a point.
- Parameters:
point (Point) – The point about which the reflection is performed.
- Returns:
A matrix to perform reflection about a point.
- Return type:
np.ndarray
- simetri.graphics.affine.mirror_about_x_matrix() ndarray [source]¶
Return a matrix to perform reflection about the x-axis.
- Returns:
A matrix to perform reflection about the x-axis.
- Return type:
np.ndarray
- simetri.graphics.affine.mirror_about_y_matrix() ndarray [source]¶
Return a matrix to perform reflection about the y-axis.
- Returns:
A matrix to perform reflection about the y-axis.
- Return type:
np.ndarray
- simetri.graphics.affine.mirror_matrix(about: Sequence[Sequence] | Sequence[float]) ndarray [source]¶
Return a matrix to perform reflection about a line or a point.
- Parameters:
about (Union[Line, Point]) – A line or point about which the reflection is performed.
- Returns:
A matrix to perform reflection about a line or a point.
- Return type:
np.ndarray
- Raises:
RuntimeError – If about is not a line or a point.
- simetri.graphics.affine.rot_about_origin_matrix(theta: float) ndarray [source]¶
Return a rotation matrix in row form [[cos(theta), sin(theta), 0], [-sin(theta), cos(theta), 0], [0, 0, 1.0]].
- Parameters:
theta (float) – The rotation angle in radians.
- Returns:
The rotation matrix.
- Return type:
np.ndarray
- simetri.graphics.affine.rotate(points: Sequence[Sequence[float]], theta: float, about: Sequence[float] = (0, 0)) ndarray [source]¶
Rotate points by theta about a point.
- Parameters:
points (Sequence[Point]) – The points to rotate.
theta (float) – The angle to rotate by.
about (Point, optional) – The point to rotate about, defaults to (0, 0).
- Returns:
The rotated points.
- Return type:
np.ndarray
- simetri.graphics.affine.rotation_matrix(theta: float, about=(0, 0)) ndarray [source]¶
Construct a rotation matrix that can be used to rotate a point about another point by theta float. Return a rotation matrix in row form dx, dy = about [[cos(theta), sin(theta), 0], [-sin(theta), cos(theta), 0], cos(theta)dx-sin(theta)dy+x, cos(theta)dy+sin(theta)dx+y, 1]].
- Parameters:
theta (float) – The rotation angle in radians.
about (tuple, optional) – The point to rotate about, defaults to (0, 0).
- Returns:
The rotation matrix.
- Return type:
np.ndarray
- simetri.graphics.affine.scale(points: Sequence[Sequence[float]], scale_x: float, scale_y: float) ndarray [source]¶
Scale points by scale_x in x direction and scale_y in y direction.
- Parameters:
points (Sequence[Point]) – The points to scale.
scale_x (float) – The scale factor in x direction.
scale_y (float) – The scale factor in y direction.
- Returns:
The scaled points.
- Return type:
np.ndarray
- simetri.graphics.affine.scale_in_place(points: Sequence[Sequence[float]], scale_x: float, scale_y: float, point: Sequence[float]) ndarray [source]¶
Scale points about a point by scale_x in x direction and scale_y in y direction.
- Parameters:
points (Sequence[Point]) – The points to scale.
scale_x (float) – The scale factor in x direction.
scale_y (float) – The scale factor in y direction.
point (Point) – The point about which the scaling is performed.
- Returns:
The scaled points.
- Return type:
np.ndarray
- simetri.graphics.affine.scale_in_place_matrix(scale_x: float, scale_y: float, point: Sequence[float]) ndarray [source]¶
Return a scale matrix in row form that scales about a point.
- Parameters:
scale_x (float) – Scale factor in x direction.
scale_y (float) – Scale factor in y direction.
point (Point) – Point about which the scaling is performed.
- Returns:
A scale matrix in row form that scales about a point.
- Return type:
np.ndarray
- simetri.graphics.affine.scale_matrix(scale_x: float, scale_y: float | None = None) ndarray [source]¶
Return a scale matrix in row form.
- Parameters:
scale_x (float) – Scale factor in x direction.
scale_y (float, optional) – Scale factor in y direction, defaults to None.
- Returns:
A scale matrix in row form.
- Return type:
np.ndarray
- simetri.graphics.affine.shear(points: Sequence[Sequence[float]], theta_x: float, theta_y: float = 0) ndarray [source]¶
Shear points by theta_x in x direction and theta_y in y direction.
- Parameters:
points (Sequence[Point]) – The points to shear.
theta_x (float) – The angle of shear in x direction.
theta_y (float, optional) – The angle of shear in y direction, defaults to 0.
- Returns:
The sheared points.
- Return type:
np.ndarray
- simetri.graphics.affine.shear_matrix(theta_x: float, theta_y: float = 0) ndarray [source]¶
Return a shear matrix in row form.
- Parameters:
theta_x (float) – Angle of shear in x direction.
theta_y (float, optional) – Angle of shear in y direction, defaults to 0.
- Returns:
A shear matrix in row form.
- Return type:
np.ndarray
- simetri.graphics.affine.translate(points: Sequence[Sequence[float]], dx: float, dy: float) ndarray [source]¶
Translate points by dx, dy.
- Parameters:
points (Sequence[Point]) – The points to translate.
dx (float) – The translation distance along the x-axis.
dy (float) – The translation distance along the y-axis.
- Returns:
The translated points.
- Return type:
np.ndarray
- simetri.graphics.affine.translation_matrix(dx: float, dy: float) ndarray [source]¶
Return a translation matrix in row form [[1.0, 0, 0], [0, 1.0, 0], [dx, dy, 1.0]].
- Parameters:
dx (float) – The translation distance along the x-axis.
dy (float) – The translation distance along the y-axis.
- Returns:
The translation matrix.
- Return type:
np.ndarray
- simetri.graphics.affine.xform_matrix(a: float, b: float, c: float, d: float, e: float, f: float) ndarray [source]¶
Return a transformation matrix in row form [[a, b, 0], [c, d, 0], [e, f, 1.0]].
- Parameters:
a (float) – The a component of the transformation matrix.
b (float) – The b component of the transformation matrix.
c (float) – The c component of the transformation matrix.
d (float) – The d component of the transformation matrix.
e (float) – The e component of the transformation matrix.
f (float) – The f component of the transformation matrix.
- Returns:
The transformation matrix.
- Return type:
np.ndarray
simetri.graphics.all_enums module¶
All enumerations.
- class simetri.graphics.all_enums.Align(value)[source]¶
Bases:
StrEnum
Align is used to set the alignment of the text in tags.
- CENTER = 'center'¶
- FLUSH_CENTER = 'flush center'¶
- FLUSH_LEFT = 'flush left'¶
- FLUSH_RIGHT = 'flush right'¶
- JUSTIFY = 'justify'¶
- LEFT = 'left'¶
- RIGHT = 'right'¶
- class simetri.graphics.all_enums.Anchor(value)[source]¶
Bases:
StrEnum
Anchor is used to set the anchor point of the shapes relative to the boundary box of shapes/batches or frames of tag objects.
- BASE = 'base'¶
- BASE_EAST = 'base east'¶
- BASE_WEST = 'base west'¶
- BOTTOM = 'bottom'¶
- CENTER = 'center'¶
- EAST = 'east'¶
- LEFT = 'left'¶
- MID = 'mid'¶
- MIDEAST = 'mid east'¶
- MIDWEST = 'mid west'¶
- NORTH = 'north'¶
- NORTHEAST = 'north east'¶
- NORTHWEST = 'north west'¶
- RIGHT = 'right'¶
- SOUTH = 'south'¶
- SOUTHEAST = 'south east'¶
- SOUTHWEST = 'south west'¶
- TEXT = 'text'¶
- TOP = 'top'¶
- WEST = 'west'¶
- class simetri.graphics.all_enums.ArrowLine(value)[source]¶
Bases:
StrEnum
ArrowLine is used to set the type of arrow line.
- FLATBASE_END = 'flatbase end'¶
- FLATBASE_MIDDLE = 'flatbase middle'¶
- FLATBASE_START = 'flatbase start'¶
- FLATBOTH_END = 'flatboth end'¶
- FLATBOTH_MIDDLE = 'flatboth middle'¶
- FLATBOTH_START = 'flatboth start'¶
- FLATTOP_END = 'flattop end'¶
- FLATTOP_MIDDLE = 'flattop middle'¶
- FLATTOP_START = 'flattop start'¶
- STRAIGHT_END = 'straight end'¶
- STRAIGHT_MIDDLE = 'straight middle'¶
- STRAIGHT_START = 'straight start'¶
- class simetri.graphics.all_enums.Axis(value)[source]¶
Bases:
StrEnum
Cartesian coordinate system axes.
- X = 'x'¶
- Y = 'y'¶
- class simetri.graphics.all_enums.BackStyle(value)[source]¶
Bases:
StrEnum
BackStyle is used to set the background style of a shape or tag. If shape.fill is True, then background will be drawn according to the shape.back_style value.
- COLOR = 'COLOR'¶
- COLOR_AND_GRID = 'COLOR_AND_GRID'¶
- EMPTY = 'EMPTY'¶
- GRIDLINES = 'GRIDLINES'¶
- PATTERN = 'PATTERN'¶
- SHADING = 'SHADING'¶
- SHADING_AND_GRID = 'SHADING_AND_GRID'¶
- class simetri.graphics.all_enums.BlendMode(value)[source]¶
Bases:
StrEnum
BlendMode is used to set the blend mode of the colors.
- COLOR = 'color'¶
- COLORBURN = 'colorburn'¶
- COLORDODGE = 'colordodge'¶
- DARKEN = 'darken'¶
- DIFFERENCE = 'difference'¶
- EXCLUSION = 'exclusion'¶
- HARDLIGHT = 'hardlight'¶
- HUE = 'hue'¶
- LIGHTEN = 'lighten'¶
- LUMINOSITY = 'luminosity'¶
- MULTIPLY = 'multiply'¶
- NORMAL = 'normal'¶
- OVERLAY = 'overlay'¶
- SATURATION = 'saturation'¶
- SCREEN = 'screen'¶
- SOFTLIGHT = 'softlight'¶
- class simetri.graphics.all_enums.ColorSpace(value)[source]¶
Bases:
StrEnum
ColorSpace is used to set the color space of the colors.
- CMYK = 'CMYK'¶
- GRAY = 'GRAY'¶
- HCL = 'HCL'¶
- HLS = 'HLS'¶
- HSV = 'HSV'¶
- LAB = 'LAB'¶
- RGB = 'RGB'¶
- YIQ = 'YIQ'¶
- class simetri.graphics.all_enums.Compiler(value)[source]¶
Bases:
StrEnum
Used for the LaTeX compiler.
- LATEX = 'LATEX'¶
- LUALATEX = 'LUALATEX'¶
- PDFLATEX = 'PDFLATEX'¶
- XELATEX = 'XELATEX'¶
- class simetri.graphics.all_enums.Connection(value)[source]¶
Bases:
StrEnum
Connection is used to set the connection type of the shapes.
- CHAIN = 'CHAIN'¶
- COINCIDENT = 'COINCIDENT'¶
- COLL_CHAIN = 'COLL_CHAIN'¶
- CONGRUENT = 'CONGRUENT'¶
- CONTAINS = 'CONTAINS'¶
- COVERS = 'COVERS'¶
- DISJOINT = 'DISJOINT'¶
- END_END = 'END_END'¶
- END_START = 'END_START'¶
- FLIPPED = 'FLIPPED'¶
- INTERSECT = 'INTERSECT'¶
- NONE = 'NONE'¶
- OVERLAPS = 'OVERLAPS'¶
- PARALLEL = 'PARALLEL'¶
- START_END = 'START_END'¶
- START_START = 'START_START'¶
- TOUCHES = 'TOUCHES'¶
- WITHIN = 'WITHIN'¶
- YJOINT = 'YJOINT'¶
- class simetri.graphics.all_enums.Connector(value)[source]¶
Bases:
StrEnum
Connector is used to set the connector type of the shapes.
- ARC = 'ARC'¶
- ARROW_LINE = 'ARROW_LINE'¶
- CURVE = 'CURVE'¶
- DOUBLE_LINE = 'DOUBLE_LINE'¶
- ELLIPSE = 'ELLIPSE'¶
- LINE = 'LINE'¶
- class simetri.graphics.all_enums.ConstraintType(value)[source]¶
Bases:
StrEnum
Constraint is used to set the constraint type of the shapes.
- COLLINEAR = 'COLLINEAR'¶
- DISTANCE = 'DISTANCE'¶
- EQUAL_SIZE = 'EQUAL_SIZE'¶
- EQUAL_VALUE = 'EQUAL_VALUE'¶
- INNER_TANGENT = 'INNER_TANGENT'¶
- LINE_ANGLE = 'LINE_ANGLE'¶
- OUTER_TANGENT = 'OUTER_TANGENT'¶
- PARALLEL = 'PARALLEL'¶
- PERPENDICULAR = 'PERPENDICULAR'¶
- class simetri.graphics.all_enums.Control(value)[source]¶
Bases:
StrEnum
Used for the modifiers of a bounding box
- INITIAL = 'INITIAL'¶
- PAUSE = 'PAUSE'¶
- RESTART = 'RESTART'¶
- RESUME = 'RESUME'¶
- STOP = 'STOP'¶
- class simetri.graphics.all_enums.Conway(value)[source]¶
Bases:
StrEnum
Frieze groups in Conway notation.
- HOP = 'HOP'¶
- JUMP = 'JUMP'¶
- SIDLE = 'SIDLE'¶
- SPINNING_HOP = 'SPINNING_HOP'¶
- SPINNING_JUMP = 'SPINNING_JUMP'¶
- SPINNING_SIDLE = 'SPINNING_SIDLE'¶
- STEP = 'STEP'¶
- class simetri.graphics.all_enums.CurveMode(value)[source]¶
Bases:
StrEnum
An enumeration.
- CHORD = 'CHORD'¶
- OPEN = 'OPEN'¶
- PIE = 'PIE'¶
- class simetri.graphics.all_enums.DocumentClass(value)[source]¶
Bases:
StrEnum
DocumentClass is used to set the class of the document.
- ARTICLE = 'article'¶
- BEAMER = 'beamer'¶
- BOOK = 'book'¶
- IEEETRAN = 'ieeetran'¶
- LETTER = 'letter'¶
- REPORT = 'report'¶
- SCRARTCL = 'scrartcl'¶
- SLIDES = 'slides'¶
- STANDALONE = 'standalone'¶
- class simetri.graphics.all_enums.FillMode(value)[source]¶
Bases:
StrEnum
FillMode is used to set the fill mode of the shape.
- EVENODD = 'even odd'¶
- NONZERO = 'non zero'¶
- class simetri.graphics.all_enums.FontFamily(value)[source]¶
Bases:
StrEnum
FontFamily is used to set the family of the font.
- CURSIVE = 'cursive'¶
- FANTASY = 'fantasy'¶
- MONOSPACE = 'monospace'¶
- SANSSERIF = 'sansserif'¶
- SERIF = 'serif'¶
- class simetri.graphics.all_enums.FontSize(value)[source]¶
Bases:
StrEnum
FontSize is used to set the size of the font.
- FOOTNOTESIZE = 'footnotesize'¶
- HUGE = 'huge'¶
- HUGE2 = 'Huge'¶
- LARGE = 'large'¶
- LARGE2 = 'Large'¶
- LARGE3 = 'LARGE'¶
- NORMAL = 'normalsize'¶
- SCRIPTSIZE = 'scriptsize'¶
- SMALL = 'small'¶
- TINY = 'tiny'¶
- class simetri.graphics.all_enums.FontStretch(value)[source]¶
Bases:
StrEnum
FontStretch is used to set the stretch of the font.
- CONDENSED = 'condensed'¶
- EXPANDED = 'expanded'¶
- EXTRA_CONDENSED = 'extracondensed'¶
- EXTRA_EXPANDED = 'extraexpanded'¶
- NORMAL = 'normal'¶
- SEMI_CONDENSED = 'semicondensed'¶
- SEMI_EXPANDED = 'semiexpanded'¶
- ULTRA_CONDENSED = 'ultracondensed'¶
- ULTRA_EXPANDED = 'ultraexpanded'¶
- class simetri.graphics.all_enums.FontStrike(value)[source]¶
Bases:
StrEnum
FontStrike is used to set the strike of the font.
- OVERLINE = 'overline'¶
- THROUGH = 'through'¶
- UNDERLINE = 'underline'¶
- class simetri.graphics.all_enums.FontWeight(value)[source]¶
Bases:
StrEnum
FontWeight is used to set the weight of the font.
- BOLD = 'bold'¶
- MEDIUM = 'medium'¶
- NORMAL = 'normal'¶
- class simetri.graphics.all_enums.FrameShape(value)[source]¶
Bases:
StrEnum
FrameShape is used to set the shape of the frame.
- CIRCLE = 'circle'¶
- DIAMOND = 'diamond'¶
- ELLIPSE = 'ellipse'¶
- FORBIDDEN = 'forbidden'¶
- PARALLELOGRAM = 'parallelogram'¶
- POLYGON = 'polygon'¶
- RECTANGLE = 'rectangle'¶
- RHOMBUS = 'rhombus'¶
- SPLITCIRCLE = 'split circle'¶
- SQUARE = 'square'¶
- STAR = 'star'¶
- TRAPEZOID = 'trapezoid'¶
- class simetri.graphics.all_enums.Graph(value)[source]¶
Bases:
StrEnum
Graph is used to set the type of graph.
- DIRECTED = 'DIRECTED'¶
- DIRECTEDWEIGHTED = 'DIRECTEDWEIGHTED'¶
- UNDIRECTED = 'UNDIRECTED'¶
- UNDIRECTEDWEIGHTED = 'UNDIRECTEDWEIGHTED'¶
- class simetri.graphics.all_enums.HeadPos(value)[source]¶
Bases:
StrEnum
Arrow head positions.
- BOTH = 'BOTH'¶
- END = 'END'¶
- MIDDLE = 'MIDDLE'¶
- NONE = 'NONE'¶
- START = 'START'¶
- class simetri.graphics.all_enums.IUC(value)[source]¶
Bases:
StrEnum
IUC notation for frieze groups.
- P1 = 'P1'¶
- P11G = 'P11G'¶
- P11M = 'P11M'¶
- P1M1 = 'P1M1'¶
- P2 = 'P2'¶
- P2MG = 'P2MG'¶
- P2MM = 'P2MM'¶
- class simetri.graphics.all_enums.LineCap(value)[source]¶
Bases:
StrEnum
LineCap is used to set the type of line cap.
- BUTT = 'butt'¶
- ROUND = 'round'¶
- SQUARE = 'square'¶
- class simetri.graphics.all_enums.LineDashArray(value)[source]¶
Bases:
StrEnum
LineDashArray is used to set the type of dashed-line.
- DASHDOT = 'dashdot'¶
- DASHDOTDOT = 'dashdotdot'¶
- DASHED = 'dashed'¶
- DENSELY_DASHED = 'densely dashed'¶
- DENSELY_DOTTED = 'densely dotted'¶
- DOTTED = 'dotted'¶
- LOOSELY_DASHED = 'loosely dashed'¶
- LOOSELY_DOTTED = 'loosely dotted'¶
- SOLID = 'solid'¶
- class simetri.graphics.all_enums.LineJoin(value)[source]¶
Bases:
StrEnum
LineJoin is used to set the type of line join.
- BEVEL = 'bevel'¶
- MITER = 'miter'¶
- ROUND = 'round'¶
- class simetri.graphics.all_enums.LineWidth(value)[source]¶
Bases:
StrEnum
LineWidth is used to set the width of the line.
- SEMITHICK = 'semithick'¶
- THICK = 'thick'¶
- THIN = 'thin'¶
- ULTRA_THICK = 'ultra thick'¶
- ULTRA_THIN = 'ultra thin'¶
- VERY_THICK = 'very thick'¶
- VERY_THIN = 'very thin'¶
- class simetri.graphics.all_enums.MarkerPos(value)[source]¶
Bases:
StrEnum
MarkerPos is used to set the position of the marker.
- CONCAVEHULL = 'CONCAVEHULL'¶
- CONVEXHULL = 'CONVEXHULL'¶
- MAINX = 'MAINX'¶
- OFFSETX = 'OFFSETX'¶
- class simetri.graphics.all_enums.MarkerType(value)[source]¶
Bases:
StrEnum
MarkerType is used to set the type of marker.
- ASTERISK = 'asterisk'¶
- BAR = '|'¶
- CIRCLE = 'o'¶
- CROSS = 'x'¶
- DIAMOND = 'diamond'¶
- DIAMOND_F = 'diamond*'¶
- EMPTY = ''¶
- FCIRCLE = '*'¶
- HALF_CIRCLE = 'halfcircle'¶
- HALF_CIRCLE_F = 'halfcircle*'¶
- HALF_DIAMOND = 'halfdiamond'¶
- HALF_DIAMOND_F = 'halfdiamond*'¶
- HALF_SQUARE = 'halfsquare'¶
- HALF_SQUARE_F = 'halfsquare*'¶
- HEXAGON = 'hexagon'¶
- HEXAGON_F = 'hexagon*'¶
- INDICES = 'indices'¶
- MINUS = '-'¶
- OPLUS = 'oplus'¶
- OPLUS_F = 'oplus*'¶
- O_TIMES = 'otimes'¶
- O_TIMES_F = 'otimes*'¶
- PENTAGON = 'pentagon'¶
- PENTAGON_F = 'pentagon*'¶
- PLUS = '+'¶
- SQUARE = 'square'¶
- SQUARE_F = 'square*'¶
- STAR = 'star'¶
- STAR2 = 'star2'¶
- STAR3 = 'star3'¶
- TEXT = 'text'¶
- TRIANGLE = 'triangle'¶
- TRIANGLE_F = 'triangle*'¶
- class simetri.graphics.all_enums.Orientation(value)[source]¶
Bases:
StrEnum
Orientation is used to set the orientation of the dimension lines.
- ANGLED = 'ANGLED'¶
- HORIZONTAL = 'HORIZONTAL'¶
- VERTICAL = 'VERTICAL'¶
- class simetri.graphics.all_enums.PageMargins(value)[source]¶
Bases:
StrEnum
Page margins for the LaTeX documents.
- CUSTOM = 'custom'¶
- NARROW = 'narrow'¶
- STANDARD = 'standard'¶
- WIDE = 'wide'¶
- class simetri.graphics.all_enums.PageNumberPosition(value)[source]¶
Bases:
StrEnum
Page number positions for the LaTeX documents.
- BOTTOM_CENTER = 'bottom'¶
- BOTTOM_LEFT = 'bottom left'¶
- BOTTOM_RIGHT = 'bottom right'¶
- CUSTOM = 'custom'¶
- TOP_CENTER = 'top'¶
- TOP_LEFT = 'top left'¶
- TOP_RIGHT = 'top right'¶
- class simetri.graphics.all_enums.PageNumbering(value)[source]¶
Bases:
StrEnum
Page numbering style for the LaTeX documents.
- ALPH = 'alph'¶
- ALPHUPPER = 'ALPH'¶
- ARABIC = 'arabic'¶
- NONE = 'none'¶
- ROMAN = 'roman'¶
- ROMAN_UPPER = 'ROMAN'¶
- class simetri.graphics.all_enums.PageOrientation(value)[source]¶
Bases:
StrEnum
Page orientations for the LaTeX documents.
- LANDSCAPE = 'landscape'¶
- PORTRAIT = 'portrait'¶
- class simetri.graphics.all_enums.PageSize(value)[source]¶
Bases:
StrEnum
Page sizes for the LaTeX documents.
- A0 = 'a0paper'¶
- A1 = 'a1paper'¶
- A2 = 'a2paper'¶
- A3 = 'a3paper'¶
- A4 = 'a4paper'¶
- A5 = 'a5paper'¶
- A6 = 'a6paper'¶
- B0 = 'b0paper'¶
- B1 = 'b1paper'¶
- B10 = 'b10paper'¶
- B11 = 'b11paper'¶
- B12 = 'b12paper'¶
- B13 = 'b13paper'¶
- B2 = 'b2paper'¶
- B3 = 'b3paper'¶
- B4 = 'b4paper'¶
- B5 = 'b5paper'¶
- B6 = 'b6paper'¶
- B7 = 'b7paper'¶
- B8 = 'b8paper'¶
- B9 = 'b9paper'¶
- EXECUTIVE = 'executivepaper'¶
- LEGAL = 'legalpaper'¶
- LETTER = 'letterpaper'¶
- class simetri.graphics.all_enums.PathOperation(value)[source]¶
Bases:
StrEnum
PathOperation is used to set the type of path operation.
- ARC = 'ARC'¶
- ARC_TO = 'ARC'¶
- BLEND_ARC = 'BLEND_ARC'¶
- BLEND_CUBIC = 'BLEND_CUBIC'¶
- BLEND_QUAD = 'BLEND_QUAD'¶
- CATMULL_TO = 'CATMULL_TO'¶
- CIRCLE = 'CIRCLE'¶
- CLOSE = 'CLOSE'¶
- CLOSE_CATMULL = 'CLOSE_CATMULL'¶
- CLOSE_HOBBY = 'CLOSE_HOBBY'¶
- CONNECTOR = 'CONNECTOR'¶
- CUBIC_TO = 'CURVE'¶
- ELLIPSE = 'ELLIPSE'¶
- FORWARD = 'FORWARD'¶
- GRID = 'GRID'¶
- HLINE = 'HLINE'¶
- HOBBY_TO = 'HOBBY_TO'¶
- LINE_TO = 'LINE'¶
- MOVE_TO = 'MOVE'¶
- POLYGON = 'POLYGON'¶
- QUAD_TO = 'QUAD_TO'¶
- RECTANGLE = 'RECTANGLE'¶
- RLINE = 'RLINE'¶
- RMOVE = 'RMOVE'¶
- SECTOR = 'SECTOR'¶
- SHAPE = 'SHAPE'¶
- STYLE = 'STYLE'¶
- TAG = 'TAG'¶
- VLINE = 'VLINE'¶
- class simetri.graphics.all_enums.PatternType(value)[source]¶
Bases:
StrEnum
PatternType is used to set the type of pattern.
- BRICKS = 'bricks'¶
- CHECKERBOARD = 'checkerboard'¶
- CROSSHATCH = 'crosshatch'¶
- CROSSHATCH_DOTS = 'crosshatch dots'¶
- DOTS = 'dots'¶
- FIVE_POINTED_STARS = 'fivepointed stars'¶
- GRID = 'grid'¶
- HORIZONTAL_LINES = 'horizontal lines'¶
- NORTHEAST = 'north east lines'¶
- NORTHWEST = 'north west lines'¶
- SIX_POINTED_STARS = 'sixpointed stars'¶
- VERTICAL_LINES = 'vertical lines'¶
- class simetri.graphics.all_enums.Placement(value)[source]¶
Bases:
StrEnum
Placement is used to set the placement of the tags relative to another object.
- ABOVE = 'above'¶
- ABOVE_LEFT = 'above left'¶
- ABOVE_RIGHT = 'above right'¶
- BELOW = 'below'¶
- BELOW_LEFT = 'below left'¶
- BELOW_RIGHT = 'below right'¶
- CENTERED = 'centered'¶
- INSIDE = 'inside'¶
- LEFT = 'left'¶
- OUTSIDE = 'outside'¶
- RIGHT = 'right'¶
- class simetri.graphics.all_enums.Render(value)[source]¶
Bases:
StrEnum
Render is used to set the type of rendering.
- EPS = 'EPS'¶
- PDF = 'PDF'¶
- SVG = 'SVG'¶
- TEX = 'TEX'¶
- class simetri.graphics.all_enums.Result(value)[source]¶
Bases:
StrEnum
Result is used for the return values of the functions.
- FAILURE = 'FAILURE'¶
- GO = 'GO'¶
- NOPAGES = 'NO_PAGES'¶
- OVERWRITE = 'OVERWRITE'¶
- SAVED = 'SAVED'¶
- STOP = 'STOP'¶
- SUCCESS = 'SUCCESS'¶
- class simetri.graphics.all_enums.ShadeType(value)[source]¶
Bases:
StrEnum
ShadeType is used to set the type of shading.
- AXIS_BOTTOM_MIDDLE = 'axis bottom middle'¶
- AXIS_LEFT_MIDDLE = 'axis left middle'¶
- AXIS_LEFT_RIGHT = 'axis left right'¶
- AXIS_RIGHT_MIDDLE = 'axis right middle'¶
- AXIS_TOP_BOTTOM = 'axis top bottom'¶
- AXIS_TOP_MIDDLE = 'axis top middle'¶
- BALL = 'ball'¶
- BILINEAR = 'bilinear'¶
- COLORWHEEL = 'color wheel'¶
- COLORWHEEL_BLACK = 'color wheel black center'¶
- COLORWHEEL_WHITE = 'color wheel white center'¶
- RADIAL_INNER = 'radial inner'¶
- RADIAL_INNER_OUTER = 'radial inner outer'¶
- RADIAL_OUTER = 'radial outer'¶
- class simetri.graphics.all_enums.Side(value)[source]¶
Bases:
StrEnum
Side is used to with boundary boxes.
- BASE = 'BASE'¶
- BOTTOM = 'BOTTOM'¶
- DIAGONAL1 = 'DIAGONAL1'¶
- DIAGONAL2 = 'DIAGONAL2'¶
- H_CENTERLINE = 'H_CENTERLINE'¶
- LEFT = 'LEFT'¶
- MID = 'MID'¶
- RIGHT = 'RIGHT'¶
- TOP = 'TOP'¶
- V_CENTERLINE = 'V_CENTERLINE'¶
- class simetri.graphics.all_enums.State(value)[source]¶
Bases:
StrEnum
State is used for modifiers. Not implemented yet.
- INITIAL = 'INITIAL'¶
- PAUSED = 'PAUSED'¶
- RESTARTING = 'RESTARTING'¶
- RUNNING = 'RUNNING'¶
- STOPPED = 'STOPPED'¶
- class simetri.graphics.all_enums.TexLoc(value)[source]¶
Bases:
StrEnum
TexLoc is used to set the location of the TeX related objects.
- DOCUMENT = 'DOCUMENT'¶
- PICTURE = 'PICTURE'¶
- PREAMBLE = 'PREAMBLE'¶
- class simetri.graphics.all_enums.Topology(value)[source]¶
Bases:
StrEnum
Topology is used to set the type of topology.
- CLOSED = 'CLOSED'¶
- COLLINEAR = 'COLLINEAR'¶
- CONGRUENT = 'CONGRUENT'¶
- FOLDED = 'FOLDED'¶
- INTERSECTING = 'INTERSECTING'¶
- OPEN = 'OPEN'¶
- SELF_INTERSECTING = 'SELF_INTERSECTING'¶
- SIMPLE = 'SIMPLE'¶
- YJOINT = 'YJOINT'¶
- class simetri.graphics.all_enums.Transformation(value)[source]¶
Bases:
StrEnum
Transformation is used to set the type of transformation.
- GLIDE = 'GLIDE'¶
- MIRROR = 'MIRROR'¶
- ROTATE = 'ROTATE'¶
- SCALE = 'SCALE'¶
- SHEAR = 'SHEAR'¶
- TRANSFORM = 'TRANSFORM'¶
- TRANSLATE = 'TRANSLATE'¶
- class simetri.graphics.all_enums.Types(value)[source]¶
Bases:
StrEnum
All objects in simetri.graphics has type and subtype properties.
- ANGULAR_DIMENSION = 'ANGULAR DIMENSION'¶
- ANNOTATION = 'ANNOTATION'¶
- ARC = 'ARC'¶
- ARC_ARROW = 'ARC_ARROW'¶
- ARC_SKETCH = 'ARC_SKETCH'¶
- ARROW = 'ARROW'¶
- ARROW_HEAD = 'ARROW_HEAD'¶
- AXIS = 'AXIS'¶
- BATCH = 'BATCH'¶
- BATCH_SKETCH = 'BATCH_SKETCH'¶
- BBOX_SKETCH = 'BBOX_SKETCH'¶
- BEZIER = 'BEZIER'¶
- BEZIER_SKETCH = 'BEZIER_SKETCH'¶
- BOUNDING_BOX = 'BOUNDING_BOX'¶
- BRACE = 'BRACE'¶
- CANVAS = 'CANVAS'¶
- CIRCLE = 'CIRCLE'¶
- CIRCLE_SKETCH = 'CIRCLE_SKETCH'¶
- CIRCULAR_GRID = 'CIRCULAR_GRID'¶
- COLOR = 'COLOR'¶
- CS = 'CS'¶
- CURVE = 'CURVE'¶
- CURVE_SKETCH = 'CURVE_SKETCH'¶
- DIMENSION = 'DIMENSION'¶
- DIRECTED = 'DIRECTED_GRAPH'¶
- DIVISION = 'DIVISION'¶
- DOT = 'DOT'¶
- DOTS = 'DOTS'¶
- EDGE = 'EDGE'¶
- ELLIPSE = 'ELLIPSE'¶
- ELLIPSE_SKETCH = 'ELLIPSE_SKETCH'¶
- ELLIPTIC_ARC = 'ELLIPTIC_ARC'¶
- FILL_STYLE = 'FILL_STYLE'¶
- FONT = 'FONT'¶
- FONTSKETCH = 'FONT_SKETCH'¶
- FONT_STYLE = 'FONT_STYLE'¶
- FRAGMENT = 'FRAGMENT'¶
- FRAGMENT_SKETCH = 'FRAGMENT_SKETCH'¶
- FRAME = 'FRAME'¶
- FRAMESKETCH = 'FRAME_SKETCH'¶
- FRAME_STYLE = 'FRAME_STYLE'¶
- GRADIENT = 'GRADIENT'¶
- GRID = 'GRID'¶
- GRID_STYLE = 'GRID_STYLE'¶
- HANDLE = 'HANDLE'¶
- HEXAGONAL = 'HEXAGONAL'¶
- ICANVAS = 'ICANVAS'¶
- INTERSECTION = 'INTERSECTION'¶
- LABEL = 'LABEL'¶
- LACE = 'LACE'¶
- LACESKETCH = 'LACE_SKETCH'¶
- LINE = 'LINE'¶
- LINEAR = 'LINEAR'¶
- LINE_SKETCH = 'LINE_SKETCH'¶
- LINE_STYLE = 'LINE_STYLE'¶
- LOOM = 'LOOM'¶
- MARKER = 'MARKER'¶
- MARKER_STYLE = 'MARKER_STYLE'¶
- MASK = 'MASK'¶
- NONE = 'NONE'¶
- OBLIQUE = 'OBLIQUE'¶
- OUTLINE = 'OUTLINE'¶
- OVERLAP = 'OVERLAP'¶
- PAGE = 'PAGE'¶
- PAGE_GRID = 'PAGE_GRID'¶
- PARALLEL_POLYLINE = 'PARALLEL_POLYLINE'¶
- PART = 'PART'¶
- PATH = 'PATH'¶
- PATH_OPERATION = 'PATH_OPERATION'¶
- PATH_SKETCH = 'PATH_SKETCH'¶
- PATTERN_SKETCH = 'PATTERN_SKETCH'¶
- PATTERN_STYLE = 'PATTERN_STYLE'¶
- PETAL = 'PETAL'¶
- PLAIT = 'PLAIT'¶
- PLAIT_SKETCH = 'PLAIT_SKETCH'¶
- POINT = 'POINT'¶
- POINTS = 'POINTS'¶
- POLYLINE = 'POLYLINE'¶
- Q_BEZIER = 'Q_BEZIER'¶
- RADIAL = 'RADIAL'¶
- RECTANGLE = 'RECTANGLE'¶
- RECTANGULAR = 'RECTANGULAR'¶
- RECT_SKETCH = 'RECT_SKETCH'¶
- REGULAR_POLYGON = 'REGULAR_POLYGON'¶
- REG_POLY = 'REGPOLY'¶
- REG_POLY_SKETCH = 'REGPOLY_SKETCH'¶
- RHOMBIC = 'RHOMBIC'¶
- SECTION = 'SECTION'¶
- SEGMENT = 'SEGMENT'¶
- SEGMENTS = 'SEGMENTS'¶
- SHADE_STYLE = 'SHADE_STYLE'¶
- SHAPE = 'SHAPE'¶
- SHAPE_SKETCH = 'SHAPE_SKETCH'¶
- SHAPE_STYLE = 'SHAPE_STYLE'¶
- SKETCH = 'SKETCH'¶
- SKETCH_STYLE = 'SKETCH_STYLE'¶
- SQUARE = 'SQUARE'¶
- STAR = 'STAR'¶
- STYLE = 'STYLE'¶
- SVG_PATH = 'SVG_PATH'¶
- SVG_PATH_SKETCH = 'SVG_PATH_SKETCH'¶
- TAG = 'TAG'¶
- TAG_SKETCH = 'TAG_SKETCH'¶
- TAG_STYLE = 'TAG_STYLE'¶
- TEX = 'TEX'¶
- TEXT = 'TEXT'¶
- TEXTANCHOR = 'TEXT_ANCHOR'¶
- TEXT_ANCHOR_LINE = 'TEXT_ANCHORLINE'¶
- TEXT_ANCHOR_POINT = 'TEXT_ANCHORPOINT'¶
- TEX_SKETCH = 'TEX_SKETCH'¶
- THREAD = 'THREAD'¶
- TRIANGLE = 'TRIANGLE'¶
- TURTLE = 'TURTLE'¶
- UNDIRECTED = 'UNDIRECTED_GRAPH'¶
- VERTEX = 'VERTEX'¶
- WARP = 'WARP'¶
- WEFT = 'WEFT'¶
- WEIGHTED = 'WEIGHTED_GRAPH'¶
simetri.graphics.batch module¶
Batch objects are used for grouping other Shape and Batch objects.
- class simetri.graphics.batch.Batch(elements: Sequence[Any] = None, modifiers: Sequence[Modifier] = None, subtype: Types = Types.BATCH, **kwargs)[source]¶
Bases:
Base
A Batch object is a collection of other objects (Batch, Shape, and Tag objects). It can be used to apply a transformation to all the objects in the Batch. It is used for creating 1D and 2D patterns of objects. all_vertices, all_elements, etc. means a flat list of the specified object gathered recursively from all the elements in the Batch.
- property all_elements: list[Any]¶
Return a list of all elements in the batch, including the elements in the nested batches.
- Returns:
A list of all elements in the batch.
- Return type:
list[Any]
- all_polygons(dist_tol: float | None = None) list [source]¶
Return a list of all polygons in the batch in their transformed positions.
- Parameters:
dist_tol (float, optional) – The distance tolerance for proximity. Defaults to None.
- Returns:
A list of all polygons in the batch.
- Return type:
list
- property all_segments: list[Sequence[Sequence]]¶
Return a list of all segments in the batch.
- Returns:
A list of all segments in the batch.
- Return type:
list[Line]
- property all_shapes: list[Shape]¶
Return a list of all shapes in the batch.
- Returns:
A list of all shapes in the batch.
- Return type:
list[Shape]
- property all_vertices: list[Sequence[float]]¶
Return a list of all points in the batch in their transformed positions.
- Returns:
A list of all points in the batch in their transformed positions.
- Return type:
list[Point]
- append(element: Any) Self [source]¶
Appends the element to the batch.
- Parameters:
element (Any) – The element to append.
- Returns:
The batch object.
- Return type:
Self
- as_graph(directed: bool = False, weighted: bool = False, dist_tol: float | None = None, atol=None, n_round: int | None = None) Graph [source]¶
Return the batch as a Graph object. Graph.nx is the networkx graph.
- Parameters:
directed (bool, optional) – Whether the graph is directed. Defaults to False.
weighted (bool, optional) – Whether the graph is weighted. Defaults to False.
dist_tol (float, optional) – The distance tolerance for proximity. Defaults to None.
atol (optional) – The absolute tolerance. Defaults to None.
n_round (int, optional) – The number of decimal places to round to. Defaults to None.
- Returns:
The batch as a Graph object.
- Return type:
- property b_box¶
Returns the bounding box of the batch.
- Returns:
The bounding box of the batch.
- Return type:
- clear() Self [source]¶
Removes all elements from the batch.
- Returns:
The batch object.
- Return type:
Self
- extend(elements: Sequence[Any]) Self [source]¶
Extends the batch with the given elements.
- Parameters:
elements (Sequence[Any]) – The elements to extend the batch with.
- Returns:
The batch object.
- Return type:
Self
- graph_summary(dist_tol: float | None = None, n_round: int | None = None) str [source]¶
Returns a representation of the Batch object as a graph.
- Parameters:
dist_tol (float, optional) – The distance tolerance for proximity. Defaults to None.
n_round (int, optional) – The number of decimal places to round to. Defaults to None.
- Returns:
A representation of the Batch object as a graph.
- Return type:
str
- insert(index, element: Any) Self [source]¶
Inserts the element at the given index.
- Parameters:
index (int) – The index to insert the element at.
element (Any) – The element to insert.
- Returns:
The batch object.
- Return type:
Self
- iter_elements(element_type: Types | None = None) Iterator [source]¶
Iterate over all elements in the batch, including the elements in the nested batches.
- Parameters:
element_type (Types, optional) – The type of elements to iterate over. Defaults to None.
- Returns:
An iterator over the elements in the batch.
- Return type:
Iterator
- merge_shapes(dist_tol: float | None = None, n_round: int | None = None) Self [source]¶
Merges the shapes in the batch if they are connected. Returns a new batch with the merged shapes as well as the shapes as well as the shapes that could not be merged.
- Parameters:
tol (float, optional) – The tolerance for merging shapes. Defaults to None.
rtol (float, optional) – The relative tolerance. Defaults to None.
atol (float, optional) – The absolute tolerance. Defaults to None.
- Returns:
The batch object with merged shapes.
- Return type:
Self
- pop(index: int) Any [source]¶
Removes the element at the given index and returns it.
- Parameters:
index (int) – The index to remove the element from.
- Returns:
The removed element.
- Return type:
Any
- proximity(dist_tol: float | None = None, n: int = 5) list[Sequence[float]] [source]¶
Returns the n closest points in the batch.
- Parameters:
dist_tol (float, optional) – The distance tolerance for proximity.
n (int, optional) – The number of closest points to return.
- Returns:
The n closest points in the batch.
- Return type:
list[Point]
- remove(element: Any) Self [source]¶
Removes the element from the batch.
- Parameters:
element (Any) – The element to remove.
- Returns:
The batch object.
- Return type:
Self
- reverse() Self [source]¶
Reverses the order of the elements in the batch.
- Returns:
The batch object.
- Return type:
Self
- set_attribs(attrib, value)[source]¶
Sets the attribute to the given value for all elements in the batch if it is applicable.
- Parameters:
attrib (str) – The attribute to set.
value (Any) – The value to set the attribute to.
- set_batch_attr(attrib: str, value: Any) Self [source]¶
Sets the attribute to the given value for the batch itself. batch.attrib = value would set the attribute to the elements of the batch object but not the batch itself.
- Parameters:
attrib (str) – The attribute to set.
value (Any) – The value to set the attribute to.
- Returns:
The batch object.
- Return type:
Self
simetri.graphics.bbox module¶
Bounding box class. Shape and Batch objects have a bounding box. Bounding box is axis-aligned. Provides reference edges and points.
- class simetri.graphics.bbox.BoundingBox(southwest: Sequence[float], northeast: Sequence[float])[source]¶
Bases:
object
Rectangular bounding box. If the object is a Shape, it contains all points. If the object is a Batch, it contains all points of all Shapes.
Provides reference edges and points as shown in the Book page ???.
- property all_anchors¶
Return all anchors of the bounding box.
- Returns:
All anchors of the bounding box.
- Return type:
tuple
- angle_point(angle: float) float [source]¶
Return the intersection point of the angled line starting from the center and the bounding box. angle is in radians.
- Parameters:
angle (float) – The angle in radians.
- Returns:
The intersection point.
- Return type:
float
- property bottom¶
Return the bottom edge.
- Returns:
The bottom edge.
- Return type:
tuple
- property center¶
Return the center of the bounding box.
- Returns:
The center of the bounding box.
- Return type:
tuple
- property corners¶
Return the four corners of the bounding box.
- Returns:
The four corners of the bounding box.
- Return type:
tuple
- property diagonal1¶
Return the first diagonal. From the top left to the bottom right.
- Returns:
The first diagonal.
- Return type:
tuple
- property diagonal2¶
Return the second diagonal. From the top right to the bottom left.
- Returns:
The second diagonal.
- Return type:
tuple
- property diamond¶
Return the four center points of the bounding box in a diamond shape.
- Returns:
The four center points of the bounding box in a diamond shape.
- Return type:
tuple
- property east¶
Return the right edge midpoint.
- Returns:
The right edge midpoint.
- Return type:
tuple
- get_inflated_b_box(left_margin=None, bottom_margin=None, right_margin=None, top_margin=None)[source]¶
Return a bounding box with offset edges.
- Parameters:
left_margin (float, optional) – The left margin.
bottom_margin (float, optional) – The bottom margin.
right_margin (float, optional) – The right margin.
top_margin (float, optional) – The top margin.
- Returns:
The inflated bounding box.
- Return type:
- property height¶
Return the height of the bounding box.
- Returns:
The height of the bounding box.
- Return type:
float
- property horiz_centerline¶
Return the horizontal centerline.
- Returns:
The horizontal centerline.
- Return type:
tuple
- property left¶
Return the left edge.
- Returns:
The left edge.
- Return type:
tuple
- property north¶
Return the top edge midpoint.
- Returns:
The top edge midpoint.
- Return type:
tuple
- property northeast¶
Return the top right corner.
- Returns:
The top right corner.
- Return type:
tuple
- property northwest¶
Return the top left corner.
- Returns:
The top left corner.
- Return type:
tuple
- offset_line(side, offset)[source]¶
Offset is applied outwards. Use negative values for inward offset.
- Parameters:
side (Side) – The side to offset.
offset (float) – The offset distance.
- Returns:
The offset line.
- Return type:
tuple
- offset_point(anchor, dx, dy)[source]¶
Return an offset point from the given corner.
- Parameters:
anchor (Anchor) – The anchor point.
dx (float) – The x offset.
dy (float) – The y offset.
- Returns:
The offset point.
- Return type:
list
- property right¶
Return the right edge.
- Returns:
The right edge.
- Return type:
tuple
- property size¶
Return the size of the bounding box.
- Returns:
The size of the bounding box.
- Return type:
tuple
- property south¶
Return the bottom edge midpoint.
- Returns:
The bottom edge midpoint.
- Return type:
tuple
- property southeast¶
Return the bottom right corner.
- Returns:
The bottom right corner.
- Return type:
tuple
- property southwest¶
Return the bottom left corner.
- Returns:
The bottom left corner.
- Return type:
tuple
- property top¶
Return the top edge.
- Returns:
The top edge.
- Return type:
tuple
- property vert_centerline¶
Return the vertical centerline.
- Returns:
The vertical centerline.
- Return type:
tuple
- property west¶
Return the left edge midpoint.
- Returns:
The left edge midpoint.
- Return type:
tuple
- property width¶
Return the width of the bounding box.
- Returns:
The width of the bounding box.
- Return type:
float
simetri.graphics.common module¶
Simetri library’s constants and common data.
- simetri.graphics.common.common_properties(obj, graphics_object=True, id_only=False)[source]¶
Set common properties for an object. All objects in Simetri have these properties.
- Parameters:
obj (Any) – The object to set properties for.
graphics_object (bool, optional) – Whether the object is a graphics object. Defaults to True.
id_only (bool, optional) – Whether to set only the id. Defaults to False.
- simetri.graphics.common.gen_unique_ids() Iterator[int] [source]¶
Generate unique Ids. Every object in Simetri has a unique id.
- Yields:
Iterator[int] – A unique id.
- simetri.graphics.common.get_defaults(args, values)[source]¶
Internally used in instance construction to set default values for None values.
- Parameters:
args (list) – The arguments to set.
values (list) – The values to set.
- Returns:
The default values.
- Return type:
list
simetri.graphics.core module¶
Base class. This is the parent for Shape and Batch classes.
- class simetri.graphics.core.Base[source]¶
Bases:
object
Base class for Shape and Batch objects.
- glide(glide_line: Sequence[Sequence], glide_dist: float, reps: int = 0) Self [source]¶
Glides (first mirror then translate) the object along the given line by the given glide_dist.
- Parameters:
glide_line (Line) – The line to glide along.
glide_dist (float) – The distance to glide.
reps (int, optional) – The number of repetitions. Defaults to 0.
- Returns:
The glided object.
- Return type:
Self
- mirror(about: Sequence[Sequence] | Sequence[float], reps: int = 0) Self [source]¶
Mirrors the object about the given line or point.
- Parameters:
about (Union[Line, Point]) – The line or point to mirror about.
reps (int, optional) – The number of repetitions. Defaults to 0.
- Returns:
The mirrored object.
- Return type:
Self
- move_to(pos: Sequence[float], anchor: Anchor = Anchor.CENTER) Self [source]¶
Moves the object to the given position by using its center point.
- Parameters:
pos (Point) – The position to move to.
anchor (Anchor, optional) – The anchor point. Defaults to Anchor.CENTER.
- Returns:
The moved object.
- Return type:
Self
- offset_line(side: Side, offset: float) Sequence[Sequence] [source]¶
Offset the line by the given side and offset distance. side can be Side.LEFT, Side.RIGHT, Side.TOP, or Side.BOTTOM. offset is applied outwards.
- Parameters:
side (Side) – The side to offset.
offset (float) – The offset distance.
- Returns:
The offset line.
- Return type:
Line
- offset_point(anchor: Anchor, dx: float, dy: float = 0) Sequence[float] [source]¶
Offset the point by the given anchor and offset distances. anchor can be Anchor.CENTER, Anchor.SOUTHWEST, Anchor.SOUTHEAST, Anchor.NORTHWEST, Anchor.NORTHEAST, Anchor.SOUTH, Anchor.WEST, Anchor.EAST, or Anchor.NORTH.
- Parameters:
anchor (Anchor) – The anchor point.
dx (float) – The x offset.
dy (float, optional) – The y offset. Defaults to 0.
- Returns:
The offset point.
- Return type:
Point
- reset_xform_matrix() Self [source]¶
Resets the transformation matrix to the identity matrix.
- Returns:
The object with the reset transformation matrix.
- Return type:
Self
- rotate(angle: float, about: Sequence[float] = (0, 0), reps: int = 0) Self [source]¶
Rotates the object by the given angle (in radians) about the given point.
- Parameters:
angle (float) – The rotation angle in radians.
about (Point, optional) – The point to rotate about. Defaults to (0, 0).
reps (int, optional) – The number of repetitions. Defaults to 0.
- Returns:
The rotated object.
- Return type:
Self
- scale(scale_x: float, scale_y: float | None = None, about: Sequence[float] = (0, 0), reps: int = 0) Self [source]¶
Scales the object by the given scale factors about the given point.
- Parameters:
scale_x (float) – The scale factor in the x direction.
scale_y (float, optional) – The scale factor in the y direction. Defaults to None.
about (Point, optional) – The point to scale about. Defaults to (0, 0).
reps (int, optional) – The number of repetitions. Defaults to 0.
- Returns:
The scaled object.
- Return type:
Self
- shear(theta_x: float, theta_y: float, reps: int = 0) Self [source]¶
Shears the object by the given angles.
- Parameters:
theta_x (float) – The shear angle in the x direction.
theta_y (float) – The shear angle in the y direction.
reps (int, optional) – The number of repetitions. Defaults to 0.
- Returns:
The sheared object.
- Return type:
Self
- transform(xform_matrix: ndarray, reps: int = 0) Self [source]¶
Transforms the object by the given transformation matrix.
- Parameters:
xform_matrix (ndarray) – The transformation matrix.
reps (int, optional) – The number of repetitions. Defaults to 0.
- Returns:
The transformed object.
- Return type:
Self
- translate(dx: float = 0, dy: float = 0, reps: int = 0) Self [source]¶
Translates the object by dx and dy.
- Parameters:
dx (float) – The translation distance along the x-axis.
dy (float) – The translation distance along the y-axis.
reps (int, optional) – The number of repetitions. Defaults to 0.
- Returns:
The transformed object.
- Return type:
Self
- translate_along(path: Sequence[Sequence[float]], step: int = 1, align_tangent: bool = False, scale: float = 1, rotate: float = 0) Self [source]¶
Translates the object along the given curve. Every n-th point is used to calculate the translation vector. If align_tangent is True, the object is rotated to align with the tangent at each point. scale is the scale factor applied at each point. rotate is the angle in radians applied at each point.
- Parameters:
path (Sequence[Point]) – The path to translate along.
step (int, optional) – The step size. Defaults to 1.
align_tangent (bool, optional) – Whether to align the object with the tangent. Defaults to False.
scale (float, optional) – The scale factor. Defaults to 1.
rotate (float, optional) – The rotation angle in radians. Defaults to 0.
- Returns:
The transformed object.
- Return type:
Self
simetri.graphics.dots module¶
Dot and Dots classes for creating dots.
- class simetri.graphics.dots.Dot(pos: Sequence[float] = (0, 0), radius: float = 1, color: Color | None = None, **kwargs)[source]¶
Bases:
Shape
A dot defined by a single point. The radius is for drawing. The only style property is the color.
- property pos: Sequence[float]¶
Return the point of the dot.
- Returns:
The point of the dot.
- Return type:
Point
simetri.graphics.merge module¶
simetri.graphics.path module¶
Path module for graphics package.
- class simetri.graphics.path.LinPath(start: Sequence[float] = (0, 0), **kwargs)[source]¶
Bases:
Batch
A LinPath object is a container for various linear elements. Path objects can be transformed like other Shape and Batch objects.
- arc(rx: float, ry: float, start_angle: float, span_angle: float, rot_angle: float = 0, n_points=None, **kwargs)[source]¶
Add an arc to the path. The arc is defined by an ellipse (with rx as half-width and ry as half-height). The sign of the span angle determines the drawing direction.
- Parameters:
rx (float) – The x radius of the arc.
ry (float) – The y radius of the arc.
start_angle (float) – The starting angle of the arc.
span_angle (float) – The span angle of the arc.
rot_angle (float, optional) – The rotation angle of the arc. Defaults to 0.
n_points (int, optional) – The number of points to use for the arc. Defaults to None.
**kwargs – Additional keyword arguments.
- Returns:
The path object.
- Return type:
Path
- blend_arc(rx: float, ry: float, start_angle: float, span_angle: float, sharp=False, n_points=None, **kwargs)[source]¶
Add a blended elliptic arc to the path.
- Parameters:
rx (float) – The x radius of the arc.
ry (float) – The y radius of the arc.
start_angle (float) – The starting angle of the arc.
span_angle (float) – The span angle of the arc.
sharp (bool, optional) – Whether the arc is sharp. Defaults to False.
n_points (int, optional) – The number of points to use for the arc. Defaults to None.
**kwargs – Additional keyword arguments.
- Returns:
The path object.
- Return type:
Path
- blend_cubic(control1_length, control2: Sequence[float], end: Sequence[float], **kwargs)[source]¶
Add a cubic Bézier curve to the path where the first control point is computed based on a length.
- Parameters:
control1_length (float) – The length to the first control point.
control2 (Point) – The second control point.
end (Point) – The end point of the curve.
**kwargs – Additional keyword arguments.
- Returns:
The path object.
- Return type:
Path
- blend_quad(control_length, end: Sequence[float], **kwargs)[source]¶
Add a quadratic Bézier curve to the path where the control point is computed based on a length.
- Parameters:
control_length (float) – The length to the control point.
end (Point) – The end point of the curve.
**kwargs – Additional keyword arguments.
- Returns:
The path object.
- Return type:
Path
- close(**kwargs)[source]¶
Close the path.
- Parameters:
**kwargs – Additional keyword arguments.
- Returns:
The path object.
- Return type:
Path
- cubic_to(control1: Sequence[float], control2: Sequence[float], end: Sequence[float], *args, **kwargs)[source]¶
Add a Bézier curve with two control points to the path. Multiple blended curves can be added by providing additional arguments.
- Parameters:
control1 (Point) – The first control point.
control2 (Point) – The second control point.
end (Point) – The end point of the curve.
*args – Additional arguments for blended curves.
**kwargs – Additional keyword arguments.
- Returns:
The path object.
- Return type:
Path
- forward(length: float, **kwargs)[source]¶
Extend the path by the given length.
- Parameters:
length (float) – The length to extend.
**kwargs – Additional keyword arguments.
- Returns:
The path object.
- Return type:
Path
- Raises:
ValueError – If the path angle is not set.
- h_line(length: float, **kwargs)[source]¶
Add a horizontal line to the path.
- Parameters:
length (float) – The length of the line.
**kwargs – Additional keyword arguments.
- Returns:
The path object.
- Return type:
Path
- hobby_to(points, **kwargs)[source]¶
Add a Hobby curve to the path.
- Parameters:
points (list) – The points of the Hobby curve.
**kwargs – Additional keyword arguments.
- Returns:
The path object.
- Return type:
Path
- line_to(point: Sequence[float], **kwargs)[source]¶
Add a line to the path.
- Parameters:
point (Point) – The end point of the line.
**kwargs – Additional keyword arguments.
- Returns:
The path object.
- Return type:
Path
- move_to(point: Sequence[float], **kwargs)[source]¶
Move the path to a new point.
- Parameters:
point (Point) – The new point.
**kwargs – Additional keyword arguments.
- Returns:
The path object.
- Return type:
Path
- quad_to(control: Sequence[float], end: Sequence[float], *args, **kwargs)[source]¶
Add a quadratic Bézier curve to the path. Multiple blended curves can be added by providing additional arguments.
- Parameters:
control (Point) – The control point.
end (Point) – The end point of the curve.
*args – Additional arguments for blended curves.
**kwargs – Additional keyword arguments.
- Returns:
The path object.
- Return type:
Path
- Raises:
ValueError – If an argument does not have exactly two elements.
- r_coord(dx: float, dy: float)[source]¶
Return the relative coordinates of a point in a coordinate system with the path’s origin and y-axis aligned with the path.angle.
- Parameters:
dx (float) – The x offset.
dy (float) – The y offset.
- Returns:
The relative coordinates.
- Return type:
tuple
- r_line(dx: float, dy: float, **kwargs)[source]¶
Add a relative line to the path.
- Parameters:
dx (float) – The x offset.
dy (float) – The y offset.
**kwargs – Additional keyword arguments.
- Returns:
The path object.
- Return type:
Path
- r_move(dx: float = 0, dy: float = 0, **kwargs)[source]¶
Move the path to a new relative point.
- Parameters:
dx (float) – The x offset.
dy (float) – The y offset.
**kwargs – Additional keyword arguments.
- Returns:
The path object.
- Return type:
Path
- r_polar(r: float, angle: float)[source]¶
Return the relative coordinates of a point in a polar coordinate system with the path’s origin and 0 degree axis aligned with the path.angle.
- Parameters:
r (float) – The radius.
angle (float) – The angle in radians.
- Returns:
The relative coordinates.
- Return type:
tuple
simetri.graphics.points module¶
Shape object uses the Points class to store the coordinates of the points that make up the shape. The Points class is a container for coordinates of multiple points. It provides conversion to homogeneous coordinates in nd_arrays. Shape.final_coords is computed by using the Points.homogen_coords property.
- class simetri.graphics.points.Points(coords: Sequence[Sequence[float]] | None = None)[source]¶
Bases:
object
Container for coordinates of multiple points. They provide conversion to homogeneous coordinates in nd_arrays. Used in Shape objects.
- append(item: Sequence[float]) Self [source]¶
Append a point to the points.
- Parameters:
item (Point) – The point to append.
- Returns:
The updated Points object.
- Return type:
Self
- copy()[source]¶
Return a copy of the Points object.
- Returns:
A copy of the Points object.
- Return type:
- extend(items: Sequence[Sequence[float]]) Self [source]¶
Extend the points with a given sequence of points.
- Parameters:
items (Sequence[Point]) – The sequence of points to add.
- Returns:
The updated Points object.
- Return type:
Self
- property homogen_coords¶
Return the homogeneous coordinates of the points.
- Returns:
The homogeneous coordinates.
- Return type:
ndarray
- insert(index, points)[source]¶
Insert a point at the specified index.
- Parameters:
index (int) – The index to insert the point at.
points (Point) – The point to insert.
- property pairs¶
Return a list of consecutive pairs of points.
- Returns:
A list where each element is a tuple containing two consecutive points.
- Return type:
list[tuple[Point, Point]]
- pop(index: int = -1) Sequence[float] [source]¶
Remove the point at the given index and return it.
- Parameters:
index (int, optional) – The index of the point to remove. Defaults to -1.
- Returns:
The removed point.
- Return type:
Point
simetri.graphics.shape module¶
Shape objects are the main geometric entities in Simetri. They are created by providing a sequence of points (a list of (x, y) coordinates). If a style argument (a ShapeStyle object) is provided, then the style attributes of this ShapeStyle object will superseed the style attributes of the Shape object. The dist_tol argument is the distance tolerance for checking. The xform_matrix argument is the transformation matrix. Additional attributes can be provided as keyword arguments. The line_width, fill_color, line_style, etc. for style attributes can be provided as keyword arguments. The Shape object has a subtype attribute that can be set to one of the values in the shape_types dictionary. The Shape object has a dist_tol attribute that is the distance tolerance for checking. The Shape object has a dist_tol2 attribute that is the square of the distance tolerance. The Shape object has a primary_points attribute that is a Points object. The Shape object has a closed attribute that is a boolean value. The Shape object has an xform_matrix attribute that is a transformation matrix. The Shape object has a type attribute that is a Types.SHAPE object. The Shape object has a subtype attribute that is a Types.SHAPE object. The Shape object has a dist_tol attribute that is a distance tolerance for checking. The Shape object has a dist_tol2 attribute that is the square of the distance tolerance. The Shape object has a _b_box attribute that is a bounding box. The Shape object has a area attribute that is the area of the shape. The Shape object has a total_length attribute that is the total length of the shape. The Shape object has a is_polygon attribute that is a boolean value. The Shape object has a topology attribute that is a set of topology values. The Shape object has a merge method that merges two shapes if they are connected. The Shape object has a _chain_vertices method that chains two sets of vertices if they are connected. The Shape object has a _is_polygon method that returns True if the vertices form a polygon. The Shape object has an as_graph method that returns the shape as a graph object. The Shape object has an as_array method that returns the vertices as an array. The Shape object has an as_list method that returns the vertices as a list of tuples. The Shape object has a final_coords attribute that is the final coordinates of the shape. The Shape object has a vertices attribute that is the final coordinates of the shape. The Shape object has a vertex
- class simetri.graphics.shape.Shape(points: Sequence[Sequence[float]] | None = None, closed: bool = False, xform_matrix: array | None = None, **kwargs)[source]¶
Bases:
Base
The main class for all geometric entities in Simetri.
A Shape is created by providing a sequence of points (a list of (x, y) coordinates). If a style argument (a ShapeStyle object) is provided, then its style attributes override those of the Shape object. Additional attributes (e.g. line_width, fill_color, line_style) may be provided.
- dist_tol¶
Distance tolerance for checking.
- xform_matrix¶
Transformation matrix.
- append(value)[source]¶
Append a point to the shape.
- Parameters:
value (Point) – The point to append.
- property area¶
Return the area of the shape.
- Returns:
The area of the shape.
- Return type:
float
- as_array(homogeneous=False)[source]¶
Return the vertices as an array.
- Parameters:
homogeneous (bool, optional) – Whether to return homogeneous coordinates, defaults to False.
- Returns:
The vertices as an array.
- Return type:
ndarray
- as_graph(directed=False, weighted=False, n_round=None)[source]¶
Return the shape as a graph object.
- Parameters:
directed (bool, optional) – Whether the graph is directed, defaults to False.
weighted (bool, optional) – Whether the graph is weighted, defaults to False.
n_round (int, optional) – The number of decimal places to round to, defaults to None.
- Returns:
The graph object.
- Return type:
- as_list()[source]¶
Return the vertices as a list of tuples.
- Returns:
The vertices as a list of tuples.
- Return type:
list[tuple]
- property b_box¶
Return the bounding box of the shape.
- Returns:
The bounding box of the shape.
- Return type:
- connect(other)[source]¶
Connect two shapes by adding the other shape’s vertices to self.
- Parameters:
other (Shape) – The other shape to connect.
- count(value)[source]¶
Return the number of times the value is found in the shape.
- Parameters:
value (Point) – The value to count.
- Returns:
The number of times the value is found in the shape.
- Return type:
int
- property edges: List[Sequence[Sequence]]¶
Return a list of edges.
Edges are represented as tuples of points: edge: ((x1, y1), (x2, y2)) edges: [((x1, y1), (x2, y2)), ((x2, y2), (x3, y3)), …]
- Returns:
A list of edges.
- Return type:
list[tuple[Point, Point]]
- extend(values)[source]¶
Extend the shape with a list of points.
- Parameters:
values (list[Point]) – The points to extend the shape with.
- property final_coords¶
The final coordinates of the shape. primary_points @ xform_matrix.
- Returns:
The final coordinates of the shape.
- Return type:
ndarray
- insert(index, value)[source]¶
Insert a point at a given index.
- Parameters:
index (int) – The index to insert the point at.
value (Point) – The point to insert.
- property is_polygon¶
Return True if ‘closed’.
- Returns:
True if the shape is closed, False otherwise.
- Return type:
bool
- merge(other, dist_tol: float | None = None)[source]¶
Merge two shapes if they are connected. Does not work for polygons. Only polyline shapes can be merged together.
- property orig_coords¶
The primary points in homogeneous coordinates.
- Returns:
The primary points in homogeneous coordinates.
- Return type:
ndarray
- pop(index: int = -1)[source]¶
Pop a point from the shape.
- Parameters:
index (int, optional) – The index to pop the point from, defaults to -1.
- Returns:
The popped point.
- Return type:
Point
- remove(value)[source]¶
Remove a point from the shape.
- Parameters:
value (Point) – The point to remove.
- topology()[source]¶
Return info about the topology of the shape.
- Returns:
A set of topology values.
- Return type:
set
- property total_length¶
Return the total length of the shape.
- Returns:
The total length of the shape.
- Return type:
float
- property vertex_pairs¶
Return a list of connected pairs of vertices.
- Returns:
A list of connected pairs of vertices.
- Return type:
list[tuple[Point, Point]]
- property vertices¶
The final coordinates of the shape.
- Returns:
The final coordinates of the shape.
- Return type:
tuple
- simetri.graphics.shape.custom_attributes(item: Shape) List[str] [source]¶
Return a list of custom attributes of a Shape or Batch instance.
- Parameters:
item (Shape) – The Shape or Batch instance.
- Returns:
A list of custom attribute names.
- Return type:
list[str]
- Raises:
TypeError – If the item is not a Shape instance.
simetri.graphics.shapes module¶
Shapes module contains classes and functions for creating shapes.
- class simetri.graphics.shapes.Circle(center: Sequence[float] = (0, 0), radius: float | None = None, xform_matrix: array | None = None, **kwargs)[source]¶
Bases:
Shape
A circle defined by a center point and a radius.
- property b_box¶
Return the bounding box of the shape.
- Returns:
The bounding box of the shape.
- Return type:
- property center¶
Return the center of the circle.
- Returns:
The center of the circle.
- Return type:
Point
- property closed¶
Return True. Circles are closed.
- Returns:
True
- Return type:
bool
- property radius¶
Return the radius of the circle.
- Returns:
The radius of the circle.
- Return type:
float
- class simetri.graphics.shapes.Mask(points, reverse=False, xform_matrix=None)[source]¶
Bases:
Shape
A mask is a closed shape that is used to clip other shapes. All it has is points and a transformation matrix.
- class simetri.graphics.shapes.Rectangle(center: Sequence[float], width: float, height: float, **kwargs)[source]¶
Bases:
Shape
A rectangle defined by width and height.
- property center¶
Return the center of the rectangle.
- Returns:
The center of the rectangle.
- Return type:
Point
- property height¶
Return the height of the rectangle.
- Returns:
The height of the rectangle.
- Return type:
float
- scale(scale_x: float, scale_y: float | None = None, about: Sequence[float] = (0, 0), reps: int = 0)[source]¶
Scale the rectangle by scale_x and scale_y. Rectangles cannot be scaled non-uniformly. scale_x changes the width and scale_y changes the height.
- Parameters:
scale_x (float) – The scale factor for the width.
scale_y (float, optional) – The scale factor for the height. Defaults to None.
about (Point, optional) – The point to scale about. Defaults to (0, 0).
reps (int, optional) – The number of repetitions. Defaults to 0.
- Returns:
The scaled rectangle.
- Return type:
- property width¶
Return the width of the rectangle.
- Returns:
The width of the rectangle.
- Return type:
float
- class simetri.graphics.shapes.Rectangle2(corner1: Sequence[float], corner2: Sequence[float], **kwargs)[source]¶
Bases:
Rectangle
A rectangle defined by two opposite corners.
- class simetri.graphics.shapes.Segment(start: Sequence[float], end: Sequence[float], **kwargs)[source]¶
Bases:
Shape
A line segment defined by two points.
- property end¶
Return the end point of the segment.
- Returns:
The end point of the segment.
- Return type:
Point
- property length¶
Return the length of the segment.
- Returns:
The length of the segment.
- Return type:
float
- property start¶
Return the start point of the segment.
- Returns:
The start point of the segment.
- Return type:
Point
- simetri.graphics.shapes.arc_points(center: Sequence[float], radius: float, start_angle: float, end_angle: float, clockwise: bool = False, n: int = 20) list[Sequence[float]] [source]¶
Return a list of points that form a circular arc with the given parameters.
- Parameters:
center (Point) – The center point of the arc.
radius (float) – The radius of the arc.
start_angle (float) – The starting angle of the arc.
end_angle (float) – The ending angle of the arc.
clockwise (bool, optional) – Whether the arc is drawn clockwise. Defaults to False.
n (int, optional) – The number of points in the arc. Defaults to 20.
- Returns:
A list of points that form a circular arc.
- Return type:
list[Point]
- simetri.graphics.shapes.arc_shape(x, y, radius, start_angle, end_angle, clockwise=False, n=20)[source]¶
Return a Shape object with points that form a circular arc with the given parameters.
- Parameters:
x (float) – The x-coordinate of the center of the arc.
y (float) – The y-coordinate of the center of the arc.
radius (float) – The radius of the arc.
start_angle (float) – The starting angle of the arc.
end_angle (float) – The ending angle of the arc.
clockwise (bool, optional) – Whether the arc is drawn clockwise. Defaults to False.
n (int, optional) – The number of points to use for the arc. Defaults to 20.
- Returns:
A Shape object with points that form a circular arc.
- Return type:
- simetri.graphics.shapes.circle_points(center: Sequence[float], radius: float, n: int = 30) list[Sequence[float]] [source]¶
Return a list of points that form a circle with the given parameters.
- Parameters:
center (Point) – The center point of the circle.
radius (float) – The radius of the circle.
n (int, optional) – The number of points in the circle. Defaults to 30.
- Returns:
A list of points that form a circle.
- Return type:
list[Point]
- simetri.graphics.shapes.circle_shape(x, y, radius, n=30)[source]¶
Return a Shape object with points that form a circle with the given parameters.
- Parameters:
x (float) – The x-coordinate of the center of the circle.
y (float) – The y-coordinate of the center of the circle.
radius (float) – The radius of the circle.
n (int, optional) – The number of points to use for the circle. Defaults to 30.
- Returns:
A Shape object with points that form a circle.
- Return type:
- simetri.graphics.shapes.di_star(points: Sequence[Sequence[float]], n: int) Batch [source]¶
Return a dihedral star with n petals.
- Parameters:
points (Sequence[Point]) – List of [x, y] points.
n (int) – Number of petals.
- Returns:
A Batch instance (dihedral star with n petals).
- Return type:
- simetri.graphics.shapes.dot_shape(x, y, radius=1, fill_color=None, line_color=None, line_width=None)[source]¶
Return a Shape object with a single point.
- Parameters:
x (float) – The x-coordinate of the point.
y (float) – The y-coordinate of the point.
radius (float, optional) – The radius of the point. Defaults to 1.
fill_color (Color, optional) – The fill color of the point. Defaults to None.
line_color (Color, optional) – The line color of the point. Defaults to None.
line_width (float, optional) – The line width of the point. Defaults to None.
- Returns:
A Shape object with a single point.
- Return type:
- simetri.graphics.shapes.ellipse_shape(x, y, width, height, n=30)[source]¶
Return a Shape object with points that form an ellipse with the given parameters.
- Parameters:
x (float) – The x-coordinate of the center of the ellipse.
y (float) – The y-coordinate of the center of the ellipse.
width (float) – The width of the ellipse.
height (float) – The height of the ellipse.
n (int, optional) – The number of points to use for the ellipse. Defaults to 30.
- Returns:
A Shape object with points that form an ellipse.
- Return type:
- simetri.graphics.shapes.hex_grid_centers(x, y, side_length, n_rows, n_cols)[source]¶
Return a list of points that define the centers of hexagons in a grid.
- Parameters:
x (float) – The x-coordinate of the starting point.
y (float) – The y-coordinate of the starting point.
side_length (float) – The length of each side of the hexagons.
n_rows (int) – The number of rows in the grid.
n_cols (int) – The number of columns in the grid.
- Returns:
A list of points that define the centers of the hexagons.
- Return type:
list[Point]
- simetri.graphics.shapes.hex_points(side_length: float) List[List[float]] [source]¶
Return a list of points that define a hexagon with a given side length.
- Parameters:
side_length (float) – The length of each side of the hexagon.
- Returns:
A list of points that define the hexagon.
- Return type:
list[list[float]]
- simetri.graphics.shapes.line_shape(p1, p2, line_width=1, line_color=Color(0.0, 0.0, 0.0), **kwargs)[source]¶
Return a Shape object with two points p1 and p2.
- Parameters:
p1 (Point) – The first point of the line.
p2 (Point) – The second point of the line.
line_width (float, optional) – The width of the line. Defaults to 1.
line_color (Color, optional) – The color of the line. Defaults to colors.black.
kwargs (dict) – Additional keyword arguments.
- Returns:
A Shape object with two points that form a line.
- Return type:
- simetri.graphics.shapes.offset_polygon_shape(polygon_shape, offset: float = 1, dist_tol: float = 0.05) list[Sequence[float]] [source]¶
Return a copy of a polygon with offset edges.
- Parameters:
polygon_shape (Shape) – The original polygon shape.
offset (float, optional) – The offset distance. Defaults to 1.
dist_tol (float, optional) – The distance tolerance. Defaults to defaults[“dist_tol”].
- Returns:
A list of points that form the offset polygon.
- Return type:
list[Point]
- simetri.graphics.shapes.rect_grid(x, y, cell_width, cell_height, n_rows, n_cols, pattern)[source]¶
Return a grid of rectangles with the given parameters.
- Parameters:
x (float) – The x-coordinate of the starting point.
y (float) – The y-coordinate of the starting point.
cell_width (float) – The width of each cell in the grid.
cell_height (float) – The height of each cell in the grid.
n_rows (int) – The number of rows in the grid.
n_cols (int) – The number of columns in the grid.
pattern (list[list[bool]]) – A pattern to fill the grid.
- Returns:
A Batch object representing the grid.
- Return type:
- simetri.graphics.shapes.rect_shape(x: float, y: float, width: float, height: float, fill_color: Color = Color(1.0, 1.0, 1.0), line_color: Color = Color(0.0, 0.0, 0.0), line_width: float = 1, fill: bool = True, marker: Marker = None) Shape [source]¶
Given lower left corner position, width, and height, return a Shape object with points that form a rectangle.
- Parameters:
x (float) – The x-coordinate of the lower left corner.
y (float) – The y-coordinate of the lower left corner.
width (float) – The width of the rectangle.
height (float) – The height of the rectangle.
fill_color (Color, optional) – The fill color of the rectangle. Defaults to colors.white.
line_color (Color, optional) – The line color of the rectangle. Defaults to defaults[“line_color”].
line_width (float, optional) – The line width of the rectangle. Defaults to defaults[“line_width”].
fill (bool, optional) – Whether to fill the rectangle. Defaults to True.
marker (Marker, optional) – The marker for the rectangle. Defaults to None.
- Returns:
A Shape object with points that form a rectangle.
- Return type:
- simetri.graphics.shapes.rectangle_points(x: float, y: float, width: float, height: float, angle: float = 0) Sequence[Sequence[float]] [source]¶
Return a list of points that form a rectangle with the given parameters.
- Parameters:
x (float) – The x-coordinate of the center of the rectangle.
y (float) – The y-coordinate of the center of the rectangle.
width (float) – The width of the rectangle.
height (float) – The height of the rectangle.
angle (float, optional) – The rotation angle of the rectangle. Defaults to 0.
- Returns:
A list of points that form the rectangle.
- Return type:
Sequence[Point]
- simetri.graphics.shapes.reg_poly_points(pos: Sequence[float], n: int, r: float) Sequence[Sequence[float]] [source]¶
Return a regular polygon points list with n sides and radius r.
- Parameters:
pos (Point) – The position of the center of the polygon.
n (int) – The number of sides of the polygon.
r (float) – The radius of the polygon.
- Returns:
A list of points that form the polygon.
- Return type:
Sequence[Point]
- simetri.graphics.shapes.reg_poly_points_side_length(pos: Sequence[float], n: int, side_len: float) Sequence[Sequence[float]] [source]¶
Return a regular polygon points list with n sides and side_len length.
- Parameters:
pos (Point) – The position of the center of the polygon.
n (int) – The number of sides of the polygon.
side_len (float) – The length of each side of the polygon.
- Returns:
A list of points that form the polygon.
- Return type:
Sequence[Point]
- simetri.graphics.shapes.reg_poly_shape(pos, n, r=100, **kwargs)[source]¶
Return a regular polygon.
- Parameters:
pos (Point) – The position of the center of the polygon.
n (int) – The number of sides of the polygon.
r (float, optional) – The radius of the polygon. Defaults to 100.
kwargs (dict) – Additional keyword arguments.
- Returns:
A Shape object with points that form a regular polygon.
- Return type:
- simetri.graphics.shapes.regular_star_polygon(n, step, rad)[source]¶
Return a regular star polygon with the given parameters.
- Parameters:
n (int) – The number of vertices of the star polygon.
step (int) – The step size for connecting vertices.
rad (float) – The radius of the star polygon.
- Returns:
A Batch object representing the star polygon.
- Return type:
- simetri.graphics.shapes.star_shape(points, reps=5, scale=1)[source]¶
Return a dihedral star from a list of points.
- Parameters:
points (list[Point]) – The list of points that form the star.
reps (int, optional) – The number of repetitions. Defaults to 5.
scale (float, optional) – The scale factor. Defaults to 1.
- Returns:
A Batch object representing the star.
- Return type:
simetri.graphics.sketch module¶
This module creates sketch objects with a neutral format for drawing. Every other format is converted from this format. If you need to save as a different format, you can use these sketch objects to convert to the format you need. Sketches are not meant to be modified. They preserve the state of graphics objects at the time of drawing. They are snapshots of the state of the objects and the Canvas at the time of drawing.
- class simetri.graphics.sketch.ArcSketch(center: tuple, start_angle: float, end_angle: float, radius: float, radius2: float | None = None, rot_angle: float = 0, start_point: tuple | None = None, xform_matrix: ndarray | None = None, mode: CurveMode = CurveMode.OPEN)[source]¶
Bases:
object
ArcSketch is a dataclass for creating an arc sketch object.
- center¶
The center of the arc.
- Type:
tuple
- start_angle¶
The start angle of the arc.
- Type:
float
- end_angle¶
The end angle of the arc.
- Type:
float
- radius¶
The radius of the arc.
- Type:
float
- radius2¶
The secondary radius of the arc. Defaults to None.
- Type:
float, optional
- rot_angle¶
The rotation angle of the arc. Defaults to 0.
- Type:
float, optional
- start_point¶
The start point of the arc. Defaults to None.
- Type:
tuple, optional
- xform_matrix¶
The transformation matrix. Defaults to None.
- Type:
ndarray, optional
- center: tuple¶
- end_angle: float¶
- radius: float¶
- radius2: float = None¶
- rot_angle: float = 0¶
- start_angle: float¶
- start_point: tuple = None¶
- xform_matrix: ndarray = None¶
- class simetri.graphics.sketch.BatchSketch(sketches: List[SKETCH], xform_matrix: ndarray = None)[source]¶
Bases:
object
BatchSketch is a dataclass for creating a batch sketch object.
- sketches¶
The list of sketches.
- Type:
List[Types.SKETCH]
- xform_matrix¶
The transformation matrix. Defaults to None.
- Type:
ndarray, optional
- sketches: List[SKETCH]¶
- xform_matrix: ndarray = None¶
- class simetri.graphics.sketch.BezierSketch(control_points: list, xform_matrix: ndarray | None = None, mode: CurveMode = CurveMode.OPEN)[source]¶
Bases:
object
BezierSketch is a dataclass for creating a bezier sketch object.
- control_points¶
The control points of the bezier curve.
- Type:
list
- xform_matrix¶
The transformation matrix. Defaults to None.
- Type:
ndarray, optional
- control_points: list¶
- xform_matrix: ndarray = None¶
- class simetri.graphics.sketch.CircleSketch(center: tuple, radius: float, xform_matrix: ndarray | None = None)[source]¶
Bases:
object
CircleSketch is a dataclass for creating a circle sketch object.
- center¶
The center of the circle.
- Type:
tuple
- radius¶
The radius of the circle.
- Type:
float
- xform_matrix¶
The transformation matrix. Defaults to None.
- Type:
ndarray, optional
- center: tuple¶
- radius: float¶
- xform_matrix: ndarray = None¶
- class simetri.graphics.sketch.EllipseSketch(center: tuple, x_radius: float, y_radius: float, angle: float = 0, xform_matrix: ndarray | None = None)[source]¶
Bases:
object
EllipseSketch is a dataclass for creating an ellipse sketch object.
- center¶
The center of the ellipse.
- Type:
tuple
- x_radius¶
The x-axis radius of the ellipse.
- Type:
float
- y_radius¶
The y-axis radius of the ellipse.
- Type:
float
- angle¶
The orientation angle. Defaults to 0.
- Type:
float, optional
- xform_matrix¶
The transformation matrix. Defaults to None.
- Type:
ndarray, optional
- angle: float = 0¶
- center: tuple¶
- x_radius: float¶
- xform_matrix: ndarray = None¶
- y_radius: float¶
- class simetri.graphics.sketch.FrameSketch(frame_shape: FrameShape = 'rectangle', line_width: float = 1, line_dash_array: list | None = None, line_color: Color = Color(0.0, 0.0, 0.0), back_color: Color = Color(1.0, 1.0, 1.0), fill: bool = False, stroke: bool = True, double: bool = False, double_distance: float = 2, inner_sep: float = 10, outer_sep: float = 10, smooth: bool = False, rounded_corners: bool = False, fillet_radius: float = 10, draw_fillets: bool = False, blend_mode: str | None = None, gradient: str | None = None, pattern: str | None = None, visible: bool = True, min_width: float = 0, min_height: float = 0, min_radius: float = 0)[source]¶
Bases:
object
FrameSketch is a dataclass for creating a frame sketch object.
- frame_shape¶
The shape of the frame. Defaults to “rectangle”.
- Type:
FrameShape, optional
- line_width¶
The width of the line. Defaults to 1.
- Type:
float, optional
- line_dash_array¶
The dash array for the line. Defaults to None.
- Type:
list, optional
- fill¶
Whether to fill the frame. Defaults to False.
- Type:
bool, optional
- stroke¶
Whether to stroke the frame. Defaults to True.
- Type:
bool, optional
- double¶
Whether to draw a double line. Defaults to False.
- Type:
bool, optional
- double_distance¶
The distance between double lines. Defaults to 2.
- Type:
float, optional
- inner_sep¶
The inner separation. Defaults to 10.
- Type:
float, optional
- outer_sep¶
The outer separation. Defaults to 10.
- Type:
float, optional
- smooth¶
Whether to smooth the frame. Defaults to False.
- Type:
bool, optional
- rounded_corners¶
Whether to round the corners. Defaults to False.
- Type:
bool, optional
- fillet_radius¶
The radius of the fillet. Defaults to 10.
- Type:
float, optional
- draw_fillets¶
Whether to draw fillets. Defaults to False.
- Type:
bool, optional
- blend_mode¶
The blend mode. Defaults to None.
- Type:
str, optional
- gradient¶
The gradient. Defaults to None.
- Type:
str, optional
- pattern¶
The pattern. Defaults to None.
- Type:
str, optional
- visible¶
Whether the frame is visible. Defaults to True.
- Type:
bool, optional
- min_width¶
The minimum width. Defaults to 0.
- Type:
float, optional
- min_height¶
The minimum height. Defaults to 0.
- Type:
float, optional
- min_radius¶
The minimum radius. Defaults to 0.
- Type:
float, optional
- blend_mode: str = None¶
- double: bool = False¶
- double_distance: float = 2¶
- draw_fillets: bool = False¶
- fill: bool = False¶
- fillet_radius: float = 10¶
- frame_shape: FrameShape = 'rectangle'¶
- gradient: str = None¶
- inner_sep: float = 10¶
- line_dash_array: list = None¶
- line_width: float = 1¶
- min_height: float = 0¶
- min_radius: float = 0¶
- min_width: float = 0¶
- outer_sep: float = 10¶
- pattern: str = None¶
- rounded_corners: bool = False¶
- smooth: bool = False¶
- stroke: bool = True¶
- visible: bool = True¶
- class simetri.graphics.sketch.LaceSketch(fragment_sketches: List[ShapeSketch], plait_sketches: List[ShapeSketch], xform_matrix: ndarray | None = None)[source]¶
Bases:
object
LaceSketch is a dataclass for creating a lace sketch object.
- fragment_sketches¶
The list of fragment sketches.
- Type:
List[ShapeSketch]
- plait_sketches¶
The list of plait sketches.
- Type:
List[ShapeSketch]
- xform_matrix¶
The transformation matrix. Defaults to None.
- Type:
ndarray, optional
- fragment_sketches: List[ShapeSketch]¶
- plait_sketches: List[ShapeSketch]¶
- xform_matrix: ndarray = None¶
- class simetri.graphics.sketch.LineSketch(vertices: list, xform_matrix: ndarray | None = None)[source]¶
Bases:
object
LineSketch is a dataclass for creating a line sketch object.
- vertices¶
The vertices of the line.
- Type:
list
- xform_matrix¶
The transformation matrix. Defaults to None.
- Type:
ndarray, optional
- vertices: list¶
- xform_matrix: ndarray = None¶
- class simetri.graphics.sketch.PathSketch(sketches: List[SKETCH], xform_matrix: ndarray = None)[source]¶
Bases:
object
PathSketch is a dataclass for creating a path sketch object.
- sketches¶
The list of sketches.
- Type:
List[Types.SKETCH]
- xform_matrix¶
The transformation matrix. Defaults to None.
- Type:
ndarray, optional
- sketches: List[SKETCH]¶
- xform_matrix: ndarray = None¶
- class simetri.graphics.sketch.RectSketch(pos: Sequence[float], width: float, height: float, xform_matrix: ndarray | None = None)[source]¶
Bases:
object
RectSketch is a dataclass for creating a rectangle sketch object.
- pos¶
The position of the rectangle.
- Type:
Point
- width¶
The width of the rectangle.
- Type:
float
- height¶
The height of the rectangle.
- Type:
float
- xform_matrix¶
The transformation matrix. Defaults to None.
- Type:
ndarray, optional
- height: float¶
- pos: Sequence[float]¶
- width: float¶
- xform_matrix: ndarray = None¶
- class simetri.graphics.sketch.ShapeSketch(vertices: list | None = None, xform_matrix: ndarray | None = None)[source]¶
Bases:
object
ShapeSketch is a neutral format for drawing.
It contains geometry (only vertices for shapes) and style properties. Style properties are not assigned during initialization. They are not meant to be transformed, only to be drawn. Sketches have no methods, only data. They do not check anything, they just store data. They are populated during sketch creation. You should make sure the data is correct before creating a sketch.
- vertices¶
The vertices of the shape. Defaults to None.
- Type:
list, optional
- xform_matrix¶
The transformation matrix. Defaults to None.
- Type:
ndarray, optional
- vertices: list = None¶
- xform_matrix: ndarray = None¶
- class simetri.graphics.sketch.TagSketch(text: str | None = None, pos: Sequence[float] | None = None, anchor: Anchor | None = None, font_family: str | None = None, font_size: float | None = None, minimum_width: float | None = None, xform_matrix: ndarray | None = None)[source]¶
Bases:
object
TagSketch is a dataclass for creating a tag sketch object.
- text¶
The text of the tag. Defaults to None.
- Type:
str, optional
- pos¶
The position of the tag. Defaults to None.
- Type:
Point, optional
- font_family¶
The font family. Defaults to None.
- Type:
str, optional
- font_size¶
The font size. Defaults to None.
- Type:
float, optional
- minimum_width¶
The minimum width. Defaults to None.
- Type:
float, optional
- xform_matrix¶
The transformation matrix. Defaults to None.
- Type:
ndarray, optional
- font_family: str = None¶
- font_size: float = None¶
- minimum_width: float = None¶
- pos: Sequence[float] = None¶
- text: str = None¶
- xform_matrix: ndarray = None¶
Module contents¶
simetri.graphics is a module that provides a simple and intuitive way to create geometric shapes and patterns.
- simetri.graphics.random() x in the interval [0, 1). ¶