simetri.frieze.frieze

Simetri graphics library's frieze patterns.

  1"""Simetri graphics library's frieze patterns."""
  2
  3from typing import Sequence, Union
  4
  5from ..geometry.geometry import vec_along_line, point_to_line_vec, pi
  6from ..graphics.common import VecType, Line, Point
  7from ..graphics.batch import Batch
  8
  9from ..graphics.shape import Shape
 10
 11
 12def hop(design: Union[Batch, Shape], vector: VecType = (1, 0), reps: int = 3) -> Batch:
 13    """
 14    p1 symmetry group.
 15
 16    Args:
 17        design (Union[Batch, Shape]): The design to be repeated.
 18        vector (VecType, optional): The direction and distance of the hop. Defaults to (1, 0).
 19        reps (int, optional): The number of repetitions. Defaults to 3.
 20
 21    Returns:
 22        Batch: A Batch of Shapes with the p1 symmetry.
 23    """
 24    dx, dy = vector[:2]
 25    return design.translate(dx, dy, reps)
 26
 27
 28def p1(design: Union[Batch, Shape], vector: VecType = (1, 0), reps: int = 3) -> Batch:
 29    """
 30    p1 symmetry group.
 31
 32    Args:
 33        design (Union[Batch, Shape]): The design to be repeated.
 34        vector (VecType, optional): The direction and distance of the hop. Defaults to (1, 0).
 35        reps (int, optional): The number of repetitions. Defaults to 3.
 36
 37    Returns:
 38        Batch: A Batch of Shapes with the p1 symmetry.
 39    """
 40    return hop(design, vector, reps)
 41
 42
 43def jump(
 44    design: Union[Batch, Shape],
 45    mirror_line: Line,
 46    dist: float,
 47    reps: int = 3,
 48) -> Batch:
 49    """
 50    p11m symmetry group.
 51
 52    Args:
 53        design (Union[Batch, Shape]): The design to be repeated.
 54        mirror_line (Line): The line to mirror the design.
 55        dist (float): The distance between the shapes.
 56        reps (int, optional): The number of repetitions. Defaults to 3.
 57
 58    Returns:
 59        Batch: A Batch of shapes with the p11m symmetry.
 60    """
 61    dx, dy = vec_along_line(mirror_line, dist)[:2]
 62    design.mirror(mirror_line, reps=1)
 63    if reps > 0:
 64        design.translate(dx, dy, reps)
 65    return design
 66
 67
 68def jump_along(
 69    design: Batch,
 70    mirror_line: Line,
 71    path: Sequence[Point],
 72    reps: int = 3,
 73) -> Batch:
 74    """
 75    Jump along the given path.
 76
 77    Args:
 78        design (Batch): The design to be repeated.
 79        mirror_line (Line): The line to mirror the design.
 80        path (Sequence[Point]): The path along which to translate the design.
 81        reps (int, optional): The number of repetitions. Defaults to 3.
 82
 83    Returns:
 84        Batch: A Batch of shapes with the jump along symmetry.
 85    """
 86    design.mirror(mirror_line, reps=1)
 87    if reps > 0:
 88        design.translate_along(path, reps)
 89    return design
 90
 91
 92def sidle(design: Batch, mirror_line: Line, dist: float, reps: int = 3) -> Batch:
 93    """
 94    p1m1 symmetry group.
 95
 96    Args:
 97        design (Batch): The design to be repeated.
 98        mirror_line (Line): The line to mirror the design.
 99        dist (float): The distance between the shapes.
100        reps (int, optional): The number of repetitions. Defaults to 3.
101
102    Returns:
103        Batch: A Batch of Shapes with the sidle symmetry.
104    """
105    x, y = point_to_line_vec(design.midpoint, mirror_line, unit=True)[:2]
106    dx = x * dist
107    dy = y * dist
108    return design.mirror(mirror_line, reps=1).translate(dist, 0, reps)
109
110
111def sidle_along(
112    design: Batch, mirror_line: Line, path: Sequence[Point], reps: int = 3
113) -> Batch:
114    """
115    Sidle along the given path.
116
117    Args:
118        design (Batch): The design to be repeated.
119        mirror_line (Line): The line to mirror the design.
120        path (Sequence[Point]): The path along which to translate the design.
121        reps (int, optional): The number of repetitions. Defaults to 3.
122
123    Returns:
124        Batch: A Batch of shapes with the sidle along symmetry.
125    """
126    x, y = point_to_line_vec(design.midpoint, mirror_line, unit=True)[:2]
127    design.mirror(mirror_line, reps=1)
128    return design.translate_along(path, reps)
129
130
131def spinning_hop(
132    design: Batch, rotocenter: Point, dx: float, dy: float, reps: int = 3
133) -> Batch:
134    """
135    p2 symmetry group.
136
137    Args:
138        design (Batch): The design to be repeated.
139        rotocenter (Point): The center of rotation.
140        dx (float): The distance to translate in the x direction.
141        dy (float): The distance to translate in the y direction.
142        reps (int, optional): The number of repetitions. Defaults to 3.
143
144    Returns:
145        Batch: A Batch of Shapes with spinning hop symmetry.
146    """
147    design.rotate(pi, rotocenter, reps=1)
148    if reps > 0:
149        design.translate(dx, dy, reps)
150    return design
151
152
153def spinning_jump(
154    design: Batch, mirror1: Line, mirror2: Line, dist: float, reps: int = 3
155) -> Batch:
156    """
157    p2mm symmetry group.
158
159    Args:
160        design (Batch): The design to be repeated.
161        mirror1 (Line): The first mirror line.
162        mirror2 (Line): The second mirror line.
163        dist (float): The distance between the shapes along mirror1.
164        reps (int, optional): The number of repetitions. Defaults to 3.
165
166    Returns:
167        Batch: A Batch of Shapes with spinning jump symmetry.
168    """
169    dx, dy = vec_along_line(mirror1, dist)[:2]
170    design.mirror(mirror1, reps=1).mirror(mirror2, reps=1)
171    if reps > 0:
172        design.translate(dx, dy, reps)
173    return design
174
175
176def spinning_sidle(
177    design: Batch,
178    mirror_line: Line = None,
179    glide_line: Line = None,
180    glide_dist: float = None,
181    trans_dist: float = None,
182    reps: int = 3,
183) -> Batch:
184    """
185    p2mg symmetry group.
186
187    Args:
188        design (Batch): The design to be repeated.
189        mirror_line (Line, optional): The mirror line. Defaults to None.
190        glide_line (Line, optional): The glide line. Defaults to None.
191        glide_dist (float, optional): The distance of the glide. Defaults to None.
192        trans_dist (float, optional): The distance of the translation. Defaults to None.
193        reps (int, optional): The number of repetitions. Defaults to 3.
194
195    Returns:
196        Batch: A Batch of Shapes with spinning sidle symmetry.
197    """
198    dx, dy = vec_along_line(glide_line, trans_dist)[:2]
199    design.mirror(mirror_line, reps=1).glide(glide_line, glide_dist, reps=1)
200    if reps > 0:
201        design.translate(dx, dy, reps)
202    return design
203
204
205def step(
206    design: Batch,
207    glide_line: Line = None,
208    glide_dist: float = None,
209    reps: int = 3,
210) -> Batch:
211    """
212    p11g symmetry group.
213
214    Args:
215        design (Batch): The design to be repeated.
216        glide_line (Line, optional): The glide line. Defaults to None.
217        glide_dist (float, optional): The distance of the glide. Defaults to None.
218        reps (int, optional): The number of repetitions. Defaults to 3.
219
220    Returns:
221        Batch: A Batch of Shapes with step symmetry.
222    """
223    design.glide(glide_line, glide_dist, reps=1)
224    if reps > 0:
225        dx, dy = vec_along_line(glide_line, 2 * glide_dist)[:2]
226        design.translate(dx, dy, reps=reps)
227    return design
228
229
230def step_along(
231    design: Batch,
232    glide_line: Line = None,
233    glide_dist: float = None,
234    path: Sequence[Point] = None,
235    reps: int = 3,
236) -> Batch:
237    """
238    Step along a path.
239
240    Args:
241        design (Batch): The design to be repeated.
242        glide_line (Line, optional): The glide line. Defaults to None.
243        glide_dist (float, optional): The distance of the glide. Defaults to None.
244        path (Sequence[Point], optional): The path along which to translate the design. Defaults to None.
245        reps (int, optional): The number of repetitions. Defaults to 3.
246
247    Returns:
248        Batch: A Batch of shapes with the step along symmetry.
249    """
250    design.glide(glide_dist, glide_line, reps=1)
251    if reps > 0:
252        design.translate_along(path, reps)
253    return design
def hop( design: Union[simetri.graphics.batch.Batch, simetri.graphics.shape.Shape], vector: Sequence[float] = (1, 0), reps: int = 3) -> simetri.graphics.batch.Batch:
13def hop(design: Union[Batch, Shape], vector: VecType = (1, 0), reps: int = 3) -> Batch:
14    """
15    p1 symmetry group.
16
17    Args:
18        design (Union[Batch, Shape]): The design to be repeated.
19        vector (VecType, optional): The direction and distance of the hop. Defaults to (1, 0).
20        reps (int, optional): The number of repetitions. Defaults to 3.
21
22    Returns:
23        Batch: A Batch of Shapes with the p1 symmetry.
24    """
25    dx, dy = vector[:2]
26    return design.translate(dx, dy, reps)

p1 symmetry group.

Arguments:
  • design (Union[Batch, Shape]): The design to be repeated.
  • vector (VecType, optional): The direction and distance of the hop. Defaults to (1, 0).
  • reps (int, optional): The number of repetitions. Defaults to 3.
Returns:

Batch: A Batch of Shapes with the p1 symmetry.

def p1( design: Union[simetri.graphics.batch.Batch, simetri.graphics.shape.Shape], vector: Sequence[float] = (1, 0), reps: int = 3) -> simetri.graphics.batch.Batch:
29def p1(design: Union[Batch, Shape], vector: VecType = (1, 0), reps: int = 3) -> Batch:
30    """
31    p1 symmetry group.
32
33    Args:
34        design (Union[Batch, Shape]): The design to be repeated.
35        vector (VecType, optional): The direction and distance of the hop. Defaults to (1, 0).
36        reps (int, optional): The number of repetitions. Defaults to 3.
37
38    Returns:
39        Batch: A Batch of Shapes with the p1 symmetry.
40    """
41    return hop(design, vector, reps)

p1 symmetry group.

Arguments:
  • design (Union[Batch, Shape]): The design to be repeated.
  • vector (VecType, optional): The direction and distance of the hop. Defaults to (1, 0).
  • reps (int, optional): The number of repetitions. Defaults to 3.
Returns:

Batch: A Batch of Shapes with the p1 symmetry.

def jump( design: Union[simetri.graphics.batch.Batch, simetri.graphics.shape.Shape], mirror_line: Sequence[Sequence], dist: float, reps: int = 3) -> simetri.graphics.batch.Batch:
44def jump(
45    design: Union[Batch, Shape],
46    mirror_line: Line,
47    dist: float,
48    reps: int = 3,
49) -> Batch:
50    """
51    p11m symmetry group.
52
53    Args:
54        design (Union[Batch, Shape]): The design to be repeated.
55        mirror_line (Line): The line to mirror the design.
56        dist (float): The distance between the shapes.
57        reps (int, optional): The number of repetitions. Defaults to 3.
58
59    Returns:
60        Batch: A Batch of shapes with the p11m symmetry.
61    """
62    dx, dy = vec_along_line(mirror_line, dist)[:2]
63    design.mirror(mirror_line, reps=1)
64    if reps > 0:
65        design.translate(dx, dy, reps)
66    return design

p11m symmetry group.

Arguments:
  • design (Union[Batch, Shape]): The design to be repeated.
  • mirror_line (Line): The line to mirror the design.
  • dist (float): The distance between the shapes.
  • reps (int, optional): The number of repetitions. Defaults to 3.
Returns:

Batch: A Batch of shapes with the p11m symmetry.

def jump_along( design: simetri.graphics.batch.Batch, mirror_line: Sequence[Sequence], path: Sequence[Sequence[float]], reps: int = 3) -> simetri.graphics.batch.Batch:
69def jump_along(
70    design: Batch,
71    mirror_line: Line,
72    path: Sequence[Point],
73    reps: int = 3,
74) -> Batch:
75    """
76    Jump along the given path.
77
78    Args:
79        design (Batch): The design to be repeated.
80        mirror_line (Line): The line to mirror the design.
81        path (Sequence[Point]): The path along which to translate the design.
82        reps (int, optional): The number of repetitions. Defaults to 3.
83
84    Returns:
85        Batch: A Batch of shapes with the jump along symmetry.
86    """
87    design.mirror(mirror_line, reps=1)
88    if reps > 0:
89        design.translate_along(path, reps)
90    return design

Jump along the given path.

Arguments:
  • design (Batch): The design to be repeated.
  • mirror_line (Line): The line to mirror the design.
  • path (Sequence[Point]): The path along which to translate the design.
  • reps (int, optional): The number of repetitions. Defaults to 3.
Returns:

Batch: A Batch of shapes with the jump along symmetry.

def sidle( design: simetri.graphics.batch.Batch, mirror_line: Sequence[Sequence], dist: float, reps: int = 3) -> simetri.graphics.batch.Batch:
 93def sidle(design: Batch, mirror_line: Line, dist: float, reps: int = 3) -> Batch:
 94    """
 95    p1m1 symmetry group.
 96
 97    Args:
 98        design (Batch): The design to be repeated.
 99        mirror_line (Line): The line to mirror the design.
100        dist (float): The distance between the shapes.
101        reps (int, optional): The number of repetitions. Defaults to 3.
102
103    Returns:
104        Batch: A Batch of Shapes with the sidle symmetry.
105    """
106    x, y = point_to_line_vec(design.midpoint, mirror_line, unit=True)[:2]
107    dx = x * dist
108    dy = y * dist
109    return design.mirror(mirror_line, reps=1).translate(dist, 0, reps)

p1m1 symmetry group.

Arguments:
  • design (Batch): The design to be repeated.
  • mirror_line (Line): The line to mirror the design.
  • dist (float): The distance between the shapes.
  • reps (int, optional): The number of repetitions. Defaults to 3.
Returns:

Batch: A Batch of Shapes with the sidle symmetry.

def sidle_along( design: simetri.graphics.batch.Batch, mirror_line: Sequence[Sequence], path: Sequence[Sequence[float]], reps: int = 3) -> simetri.graphics.batch.Batch:
112def sidle_along(
113    design: Batch, mirror_line: Line, path: Sequence[Point], reps: int = 3
114) -> Batch:
115    """
116    Sidle along the given path.
117
118    Args:
119        design (Batch): The design to be repeated.
120        mirror_line (Line): The line to mirror the design.
121        path (Sequence[Point]): The path along which to translate the design.
122        reps (int, optional): The number of repetitions. Defaults to 3.
123
124    Returns:
125        Batch: A Batch of shapes with the sidle along symmetry.
126    """
127    x, y = point_to_line_vec(design.midpoint, mirror_line, unit=True)[:2]
128    design.mirror(mirror_line, reps=1)
129    return design.translate_along(path, reps)

Sidle along the given path.

Arguments:
  • design (Batch): The design to be repeated.
  • mirror_line (Line): The line to mirror the design.
  • path (Sequence[Point]): The path along which to translate the design.
  • reps (int, optional): The number of repetitions. Defaults to 3.
Returns:

Batch: A Batch of shapes with the sidle along symmetry.

def spinning_hop( design: simetri.graphics.batch.Batch, rotocenter: Sequence[float], dx: float, dy: float, reps: int = 3) -> simetri.graphics.batch.Batch:
132def spinning_hop(
133    design: Batch, rotocenter: Point, dx: float, dy: float, reps: int = 3
134) -> Batch:
135    """
136    p2 symmetry group.
137
138    Args:
139        design (Batch): The design to be repeated.
140        rotocenter (Point): The center of rotation.
141        dx (float): The distance to translate in the x direction.
142        dy (float): The distance to translate in the y direction.
143        reps (int, optional): The number of repetitions. Defaults to 3.
144
145    Returns:
146        Batch: A Batch of Shapes with spinning hop symmetry.
147    """
148    design.rotate(pi, rotocenter, reps=1)
149    if reps > 0:
150        design.translate(dx, dy, reps)
151    return design

p2 symmetry group.

Arguments:
  • design (Batch): The design to be repeated.
  • rotocenter (Point): The center of rotation.
  • dx (float): The distance to translate in the x direction.
  • dy (float): The distance to translate in the y direction.
  • reps (int, optional): The number of repetitions. Defaults to 3.
Returns:

Batch: A Batch of Shapes with spinning hop symmetry.

def spinning_jump( design: simetri.graphics.batch.Batch, mirror1: Sequence[Sequence], mirror2: Sequence[Sequence], dist: float, reps: int = 3) -> simetri.graphics.batch.Batch:
154def spinning_jump(
155    design: Batch, mirror1: Line, mirror2: Line, dist: float, reps: int = 3
156) -> Batch:
157    """
158    p2mm symmetry group.
159
160    Args:
161        design (Batch): The design to be repeated.
162        mirror1 (Line): The first mirror line.
163        mirror2 (Line): The second mirror line.
164        dist (float): The distance between the shapes along mirror1.
165        reps (int, optional): The number of repetitions. Defaults to 3.
166
167    Returns:
168        Batch: A Batch of Shapes with spinning jump symmetry.
169    """
170    dx, dy = vec_along_line(mirror1, dist)[:2]
171    design.mirror(mirror1, reps=1).mirror(mirror2, reps=1)
172    if reps > 0:
173        design.translate(dx, dy, reps)
174    return design

p2mm symmetry group.

Arguments:
  • design (Batch): The design to be repeated.
  • mirror1 (Line): The first mirror line.
  • mirror2 (Line): The second mirror line.
  • dist (float): The distance between the shapes along mirror1.
  • reps (int, optional): The number of repetitions. Defaults to 3.
Returns:

Batch: A Batch of Shapes with spinning jump symmetry.

def spinning_sidle( design: simetri.graphics.batch.Batch, mirror_line: Sequence[Sequence] = None, glide_line: Sequence[Sequence] = None, glide_dist: float = None, trans_dist: float = None, reps: int = 3) -> simetri.graphics.batch.Batch:
177def spinning_sidle(
178    design: Batch,
179    mirror_line: Line = None,
180    glide_line: Line = None,
181    glide_dist: float = None,
182    trans_dist: float = None,
183    reps: int = 3,
184) -> Batch:
185    """
186    p2mg symmetry group.
187
188    Args:
189        design (Batch): The design to be repeated.
190        mirror_line (Line, optional): The mirror line. Defaults to None.
191        glide_line (Line, optional): The glide line. Defaults to None.
192        glide_dist (float, optional): The distance of the glide. Defaults to None.
193        trans_dist (float, optional): The distance of the translation. Defaults to None.
194        reps (int, optional): The number of repetitions. Defaults to 3.
195
196    Returns:
197        Batch: A Batch of Shapes with spinning sidle symmetry.
198    """
199    dx, dy = vec_along_line(glide_line, trans_dist)[:2]
200    design.mirror(mirror_line, reps=1).glide(glide_line, glide_dist, reps=1)
201    if reps > 0:
202        design.translate(dx, dy, reps)
203    return design

p2mg symmetry group.

Arguments:
  • design (Batch): The design to be repeated.
  • mirror_line (Line, optional): The mirror line. Defaults to None.
  • glide_line (Line, optional): The glide line. Defaults to None.
  • glide_dist (float, optional): The distance of the glide. Defaults to None.
  • trans_dist (float, optional): The distance of the translation. Defaults to None.
  • reps (int, optional): The number of repetitions. Defaults to 3.
Returns:

Batch: A Batch of Shapes with spinning sidle symmetry.

def step( design: simetri.graphics.batch.Batch, glide_line: Sequence[Sequence] = None, glide_dist: float = None, reps: int = 3) -> simetri.graphics.batch.Batch:
206def step(
207    design: Batch,
208    glide_line: Line = None,
209    glide_dist: float = None,
210    reps: int = 3,
211) -> Batch:
212    """
213    p11g symmetry group.
214
215    Args:
216        design (Batch): The design to be repeated.
217        glide_line (Line, optional): The glide line. Defaults to None.
218        glide_dist (float, optional): The distance of the glide. Defaults to None.
219        reps (int, optional): The number of repetitions. Defaults to 3.
220
221    Returns:
222        Batch: A Batch of Shapes with step symmetry.
223    """
224    design.glide(glide_line, glide_dist, reps=1)
225    if reps > 0:
226        dx, dy = vec_along_line(glide_line, 2 * glide_dist)[:2]
227        design.translate(dx, dy, reps=reps)
228    return design

p11g symmetry group.

Arguments:
  • design (Batch): The design to be repeated.
  • glide_line (Line, optional): The glide line. Defaults to None.
  • glide_dist (float, optional): The distance of the glide. Defaults to None.
  • reps (int, optional): The number of repetitions. Defaults to 3.
Returns:

Batch: A Batch of Shapes with step symmetry.

def step_along( design: simetri.graphics.batch.Batch, glide_line: Sequence[Sequence] = None, glide_dist: float = None, path: Sequence[Sequence[float]] = None, reps: int = 3) -> simetri.graphics.batch.Batch:
231def step_along(
232    design: Batch,
233    glide_line: Line = None,
234    glide_dist: float = None,
235    path: Sequence[Point] = None,
236    reps: int = 3,
237) -> Batch:
238    """
239    Step along a path.
240
241    Args:
242        design (Batch): The design to be repeated.
243        glide_line (Line, optional): The glide line. Defaults to None.
244        glide_dist (float, optional): The distance of the glide. Defaults to None.
245        path (Sequence[Point], optional): The path along which to translate the design. Defaults to None.
246        reps (int, optional): The number of repetitions. Defaults to 3.
247
248    Returns:
249        Batch: A Batch of shapes with the step along symmetry.
250    """
251    design.glide(glide_dist, glide_line, reps=1)
252    if reps > 0:
253        design.translate_along(path, reps)
254    return design

Step along a path.

Arguments:
  • design (Batch): The design to be repeated.
  • glide_line (Line, optional): The glide line. Defaults to None.
  • glide_dist (float, optional): The distance of the glide. Defaults to None.
  • path (Sequence[Point], optional): The path along which to translate the design. Defaults to None.
  • reps (int, optional): The number of repetitions. Defaults to 3.
Returns:

Batch: A Batch of shapes with the step along symmetry.