simetri.wallpaper.wallpaper

Simetri graphics library's wallpaper patterns.

  1"""Simetri graphics library's wallpaper patterns.
  2"""
  3
  4# Only six of the 17 wallpaper groups are tested yet.
  5
  6from math import sqrt, pi, cos
  7
  8from typing import Union
  9
 10from ..geometry.geometry import mid_point, line_through_point_and_angle
 11from ..graphics.common import VecType, Point, Line
 12from ..helpers.illustration import Tag
 13from ..graphics.batch import Batch
 14from ..graphics.shape import Shape
 15
 16
 17cos60 = cos(pi / 3)
 18cos30 = cos(pi / 6)
 19
 20
 21def cover_hex(
 22    item: Union[Batch, Shape, Tag],
 23    size: float,
 24    gap: float = 0,
 25    reps1: int = 2,
 26    reps2: int = 2,
 27    flat: bool = True,
 28) -> Batch:
 29    """
 30    Covers an area with a hexagonal pattern.
 31
 32    Args:
 33        item (Union[Batch, Shape, Tag]): The item to be repeated.
 34        size (float): The size of the hexagons.
 35        gap (float, optional): The gap between hexagons. Defaults to 0.
 36        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 2.
 37        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 2.
 38        flat (bool, optional): If True, hexagons are flat-topped. Defaults to True.
 39
 40    Returns:
 41        Batch: The resulting pattern as a Batch object.
 42    """
 43    gap_x = 2 * gap * cos60
 44    gap_y = gap * cos30
 45    if (flat):
 46        w = 2 * size
 47        h = sqrt(3) * size
 48        dx = 3 * size + (gap_x * 2)
 49        dy = h + (gap_y * 2)
 50        item.translate((3 * size / 2) + gap_x, (h / 2) + gap_y, reps=1)
 51    else:
 52        w = sqrt(3) * size
 53        h = 2 * size
 54        dx = w + (gap_x * 2)
 55        dy = (2 * size) + (h / 2) + (gap_y * 2)
 56        item.translate((w / 2) + gap_x, (3 * h / 4) + gap_y, reps=1)
 57
 58    item.translate(dx, 0, reps=reps1)
 59    item.translate(0, dy, reps=reps2)
 60
 61    return item
 62
 63
 64def cover_rhombic(
 65    item: Union[Batch, Shape, Tag], size: float, reps1: int = 2, reps2: int = 2
 66) -> Batch:
 67    """
 68    Covers an area with a rhombic pattern.
 69
 70    Args:
 71        item (Union[Batch, Shape, Tag]): The item to be repeated.
 72        size (float): The size of the rhombuses.
 73        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 2.
 74        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 2.
 75
 76    Returns:
 77        Batch: The resulting pattern as a Batch object.
 78    """
 79    sqrt2 = sqrt(2)
 80    diag = (sqrt2 / 2) * size
 81    item.translate(diag, diag, reps=1)
 82    dx = dy = diag * 2
 83    item.translate(dx, 0, reps=reps1)
 84    item.translate(0, dy, reps=reps2)
 85
 86    return item
 87
 88
 89def hex_grid_pointy(x: float, y: float, size: float, n_rows: int, n_cols: int) -> Batch:
 90    """
 91    Creates a hexagonal grid with pointy tops.
 92
 93    Args:
 94        x (float): The x-coordinate of the starting point.
 95        y (float): The y-coordinate of the starting point.
 96        size (float): The size of the hexagons.
 97        n_rows (int): Number of rows in the grid.
 98        n_cols (int): Number of columns in the grid.
 99
100    Returns:
101        Batch: The resulting grid as a Batch of Shapes.
102    """
103    height = sqrt(3) * size
104    width = 2 * size
105    edge_length = 2 * size * cos(pi / 6)
106    # create the first row by translating a single hexagon in the x direction
107    row = Batch(Shape([(x, y)])).translate(size, 0, reps=n_cols - 1)
108    # create the second row by translating the first row
109    two_rows = row.translate(width, height + edge_length, reps=1)
110    # create the grid by translating the first and second row in the y direction
111    grid = two_rows.translate(0, 2 * size + edge_length, reps=n_rows / 2 - 1)
112
113    return grid
114
115
116def cover_hex_pointy(
117    item: Union[Shape, Batch, Tag],
118    size: float,
119    gap: float = 0,
120    reps1: int = 2,
121    reps2: int = 2,
122) -> Batch:
123    """
124    Covers an area with a hexagonal pattern with pointy tops.
125
126    Args:
127        item (Union[Shape, Batch, Tag]): The item to be repeated.
128        size (float): The size of the hexagons.
129        gap (float, optional): The gap between hexagons. Defaults to 0.
130        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 2.
131        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 2.
132
133    Returns:
134        Batch: The resulting pattern as a Batch object.
135    """
136    gap_x = 2 * gap * cos60
137    gap_y = gap * cos30
138    w = sqrt(3) * size
139    h = 2 * size
140    dx = w + (gap_x * 2)
141    dy = (2 * size) + (h / 2) + (gap_y * 2)
142    item.translate((w / 2) + gap_x, (3 * h / 4) + gap_y, reps=1)
143    item.translate(dx, 0, reps=reps1)
144    item.translate(0, dy, reps=reps2)
145
146    return item
147
148
149def cover_hex_flat(
150    item: Union[Batch, Shape, Tag],
151    size: float,
152    gap: float = 0,
153    reps1: int = 2,
154    reps2: int = 2,
155) -> Batch:
156    """
157    Covers an area with a hexagonal pattern with flat tops.
158
159    Args:
160        item (Union[Batch, Shape, Tag]): The item to be repeated.
161        size (float): The size of the hexagons.
162        gap (float, optional): The gap between hexagons. Defaults to 0.
163        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 2.
164        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 2.
165
166    Returns:
167        Batch: The resulting pattern as a Batch object.
168    """
169    gap_x = 2 * gap * cos60
170    gap_y = gap * cos30
171    h = sqrt(3) * size
172    dx = 3 * size + (gap_x * 2)
173    dy = h + (gap_y * 2)
174    item.translate((3 * size / 2) + gap_x, (h / 2) + gap_y, reps=1)
175    item.translate(dx, 0, reps=reps1)
176    item.translate(0, dy, reps=reps2)
177
178    return item
179
180
181# Wallpaper groups
182
183# generator is the primary cell
184# tile is the basic unit cell
185# mirrors
186# glide-mirror (m1, m2), glide-dist (dist1, dist2) if more than one
187# rotocenters
188# n rotations (n1, n2, ...) corresponding to each rotocenter
189# translations (vec1, n1, vec2, n2) this is the lattice
190
191
192def wallpaper_p1(
193    generator: Union[Batch, Shape, Tag],
194    vector1: VecType,
195    vector2: VecType,
196    reps1: int = 4,
197    reps2: int = 4,
198) -> Batch:
199    """
200    Translation symmetry.
201    IUC: p1
202    Conway: o
203    Oblique lattice
204    Point group: C1
205
206    Args:
207        generator (Union[Batch, Shape, Tag]): The repeating motif.
208        vector1 (VecType): The translation vector in the x direction.
209        vector2 (VecType): The translation vector in the y direction.
210        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
211        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
212
213    Returns:
214        Batch: The resulting wallpaper pattern as a Batch object.
215    """
216    dx1, dy1 = vector1
217    wallpaper = generator.translate(dx1, dy1, reps1)
218    dx2, dy2 = vector2
219    wallpaper.translate(dx2, dy2, reps2)
220
221    return wallpaper
222
223
224def wallpaper_p2(
225    generator: Union[Shape, Batch, Tag],
226    vector1: VecType,
227    vector2: VecType,
228    reps1: int = 4,
229    reps2: int = 4,
230) -> Batch:
231    """
232    Half-turn rotation symmetry.
233    IUC: p2 (p211)
234    Conway: 2222
235    Oblique lattice
236    Point group: C2
237
238    Args:
239        generator (Union[Shape, Batch, Tag]): The repeating motif.
240        vector1 (VecType): The translation vector in the x direction.
241        vector2 (VecType): The translation vector in the y direction.
242        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
243        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
244
245    Returns:
246        Batch: The resulting wallpaper pattern as a Batch object.
247    """
248    rotocenter = mid_point(vector1, vector2)
249    wallpaper = generator.rotate(pi, rotocenter, reps=1)
250    dx1, dy1 = vector1
251    wallpaper.translate(dx1, dy1, reps=reps1)
252    dx2, dy2 = vector2
253    wallpaper.translate(dx2, dy2, reps=reps2)
254
255    return wallpaper
256
257
258def wallpaper_p2_rect_lattice(
259    generator: Union[Shape, Batch, Tag],
260    rotocenter: Point,
261    vector1: VecType,
262    vector2: VecType,
263    reps1: int = 4,
264    reps2: int = 4,
265) -> Batch:
266    # """
267    # Half-turn rotation symmetry.
268    # IUC: p2 (p211)
269    # Conway: 2222
270    # Oblique lattice
271    # Point group: C2
272
273    # Point argument can be an Anchor object or a tuple, or two points can be given
274    # as a sequence.
275
276    # Example:
277    # import simetri.graphics as sg
278    # import simetri.wallpaper as wp
279
280    # directory = 'dir_path'
281    # canvas = sg.Canvas()
282
283    # F = sg.letter_F()
284    # vec1 = (2 * F.width + 10, 0)
285    # vec2 = (0, F.height + 10)
286
287    # pattern = wp.wallpaper_p2(F, vec1, vec2, reps1=2, reps2=2)
288    # file_path = os.path.join(directory, 'wallpaper_test_p2.pdf')
289    # canvas.draw(pattern, file_path=file_path)
290
291    # """
292
293    rotocenter = mid_point(vector1, vector2)
294    wallpaper = generator.rotate(pi, rotocenter, reps=1)
295    dx1, dy1 = vector1
296    wallpaper.translate(dx1, dy1, reps=reps1)
297    dx2, dy2 = vector2
298    wallpaper.translate(dx2, dy2, reps=reps2)
299
300    return wallpaper
301
302
303def wallpaper_p3(
304    generator: Union[Shape, Batch, Tag],
305    rotocenter: Point,
306    distance: float,
307    reps1: int = 4,
308    reps2: int = 4,
309    flat_hex: bool = False,
310) -> Batch:
311    """
312    Three rotations.
313    IUC: p3
314    Conway: 333
315    Hexagonal lattice.
316    Point group: C3
317
318    Args:
319        generator (Union[Shape, Batch, Tag]): The repeating motif.
320        rotocenter (Point): The center of rotation.
321        distance (float): The distance between the centers of the hexagons.
322        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
323        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
324        flat_hex (bool, optional): If True, hexagons are flat-topped. Defaults to False.
325
326    Returns:
327        Batch: The resulting wallpaper pattern as a Batch object.
328    """
329    wallpaper = generator.rotate(2 * pi / 3, rotocenter, reps=2)
330    if flat_hex:
331        cover_hex_flat(wallpaper, distance, reps1=reps1, reps2=reps2)
332    else:
333        cover_hex_pointy(wallpaper, distance, reps1=reps1, reps2=reps2)
334
335    return wallpaper
336
337
338def wallpaper_p4(
339    generator: Union[Batch, Shape, Tag],
340    rotocenter: Point,
341    distance: float,
342    reps1: int = 4,
343    reps2: int = 4,
344) -> Batch:
345    """
346    Pinwheel symmetry.
347    IUC: p4
348    Conway: 442
349    Square lattice
350    Point group: C4
351
352    Args:
353        generator (Union[Batch, Shape, Tag]): The repeating motif.
354        rotocenter (Point): The center of rotation.
355        distance (float): The distance between the centers of the squares.
356        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
357        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
358
359    Returns:
360        Batch: The resulting wallpaper pattern as a Batch object.
361    """
362    wallpaper = generator.rotate(pi / 2, rotocenter, reps=3)
363    wallpaper.translate(distance, 0, reps1)
364    wallpaper.translate(0, distance, reps2)
365
366    return wallpaper
367
368
369def wallpaper_p6(
370    generator: Union[Batch, Shape, Tag],
371    rotocenter: Point,
372    hex_size: float,
373    reps1: int = 4,
374    reps2: int = 4,
375    flat_hex=False,
376) -> Batch:
377    """
378    Six rotations.
379    IUC: p6
380    Conway : 632
381    Hexagonal lattice
382    Point group: C6
383
384    Args:
385        generator (Union[Batch, Shape, Tag]): The repeating motif.
386        rotocenter (Point): The center of rotation.
387        hex_size (float): The size of the hexagons.
388        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
389        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
390        flat_hex (bool, optional): If True, hexagons are flat-topped. Defaults to False.
391
392    Returns:
393        Batch: The resulting pattern as a Batch object.
394    """
395    wallpaper = generator.rotate(pi / 3, rotocenter, reps=5)
396    if flat_hex:
397        cover_hex_flat(wallpaper, hex_size, reps1=reps1, reps2=reps2)
398    else:
399        cover_hex_pointy(wallpaper, hex_size, reps1=reps1, reps2=reps2)
400
401    return wallpaper
402
403
404def wallpaper_pm(
405    generator: Union[Batch, Shape, Tag],
406    mirror_line: Line,
407    dx: float,
408    dy: float,
409    reps1: int = 4,
410    reps2: int = 4,
411) -> Batch:
412    """
413    Mirror symmetry.
414    Mirror could be horizontal or vertical.
415    IUC: pm(p1m1)
416    Conway : **
417    Rectangular lattice
418    Point group: D1
419
420    Args:
421        generator (Union[Batch, Shape, Tag]): The repeating motif.
422        mirror_line (Line): The line of symmetry.
423        dx (float): Translation distance in the x direction.
424        dy (float): Translation distance in the y direction.
425        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
426        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
427
428    Returns:
429        Batch: The resulting pattern as a Batch object.
430    """
431    wallpaper = generator.mirror(mirror_line, reps=1)
432    wallpaper.translate(dx, 0, reps=reps1)
433    wallpaper.translate(0, dy, reps=reps2)
434
435    return wallpaper
436
437
438def wallpaper_pg(
439    generator: Union[Batch, Shape, Tag],
440    mirror_line: Line,
441    distance: float,
442    dx: float,
443    dy: float,
444    reps1: int = 4,
445    reps2: int = 4,
446) -> Batch:
447    """
448    Glide symmetry.
449    IUC: pg(p1g1)
450    Conway : xx
451    Rectangular lattice
452    Point group: D1
453
454    Args:
455        generator (Union[Batch, Shape, Tag]): The repeating motif.
456        mirror_line (Line): The line of symmetry.
457        distance (float): The distance for the glide reflection.
458        dx (float): Translation distance in the x direction.
459        dy (float): Translation distance in the y direction.
460        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
461        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
462
463    Returns:
464        Batch: The resulting pattern as a Batch object.
465    """
466    wallpaper = generator.glide(mirror_line, distance, reps=1)
467    wallpaper.translate(dx, 0, reps=reps1)
468    wallpaper.translate(0, dy, reps=reps2)
469
470    return wallpaper
471
472
473def wallpaper_cm(
474    generator: Union[Batch, Shape, Tag],
475    mirror_point: Point,
476    rhomb_size: float,
477    reps1: int = 4,
478    reps2: int = 4,
479    horizontal: bool = True,
480) -> Batch:
481    """
482    Spinning-sidle symmetry.
483    IUC: cm(c1m1)
484    Conway : *x
485    Rhombic lattice
486    Point group: D1
487
488    Args:
489        generator (Union[Batch, Shape, Tag]): The repeating motif.
490        mirror_point (Point): The point of symmetry.
491        rhomb_size (float): The size of the rhombuses.
492        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
493        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
494        horizontal (bool, optional): If True, the mirror line is horizontal. Defaults to True.
495
496    Returns:
497        Batch: The resulting pattern as a Batch object.
498    """
499    x1, y1 = mirror_point
500    if horizontal:
501        x2, y2 = x1 + 1, y1
502    else:
503        x2, y2 = x1, y1 + 1
504    wallpaper = generator.mirror(((x1, y1), (x2, y2)), reps=1)
505    cover_rhombic(
506        wallpaper,
507        rhomb_size,
508        reps1=reps1,
509        reps2=reps2,
510    )
511
512    return wallpaper
513
514
515def wallpaper_pmm(
516    generator: Union[Batch, Shape, Tag],
517    mirror_cross: Point,
518    dx: float,
519    dy: float,
520    reps1=4,
521    reps2=4,
522) -> Batch:
523    """
524    Double mirror symmetry.
525    IUC: pmm(p2mm)
526    Conway : *2222
527    Rectangular lattice
528    Point group: D2
529
530    Args:
531        generator (Union[Batch, Shape, Tag]): The repeating motif.
532        mirror_cross (Point): The point where the mirror lines cross.
533        dx (float): Translation distance in the x direction.
534        dy (float): Translation distance in the y direction.
535        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
536        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
537
538    Returns:
539        Batch: The resulting pattern as a Batch object.
540    """
541    x, y = mirror_cross[:2]
542    mirror_line1 = ((x, y), (x + 1, y))
543    mirror_line2 = ((x, y), (x, y + 1))
544    wallpaper = generator.mirror(mirror_line1, reps=1)
545    wallpaper.mirror(mirror_line2, reps=1)
546    wallpaper.translate(dx, 0, reps=reps1)
547    wallpaper.translate(0, dy, reps=reps2)
548
549    return wallpaper
550
551
552def wallpaper_pmg(
553    generator: Union[Batch, Shape, Tag],
554    center_point: Point,
555    dx: float,
556    dy: float,
557    reps1=4,
558    reps2=4,
559    horizontal=True,
560) -> Batch:
561    """
562    Glided staggered symmetry.
563    IUC: pmg(p2mg)
564    Conway : 22*
565    Rectangular lattice
566    Point group: D2
567
568    Args:
569        generator (Union[Batch, Shape, Tag]): The repeating motif.
570        center_point (Point): The center point for the symmetry.
571        dx (float): Translation distance in the x direction.
572        dy (float): Translation distance in the y direction.
573        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
574        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
575        horizontal (bool, optional): If True, the mirror line is horizontal. Defaults to True.
576
577    Returns:
578        Batch: The resulting pattern as a Batch object.
579    """
580    x, y = center_point[:2]
581    if horizontal:
582        rotocenter = mid_point((x, y), (x, (y + dy) / 2))
583        mirror_line = ((x, y), (x + 1, y))
584    else:
585        rotocenter = mid_point((x, y), (-(x + dx) / 2, y))
586        mirror_line = ((x, y), (x, y + 1))
587    wallpaper = generator.rotate(pi, rotocenter, reps=1)
588    wallpaper.mirror(mirror_line, reps=1)
589    wallpaper.translate(dx, 0, reps=reps1)
590    wallpaper.translate(0, dy, reps=reps2)
591
592    return wallpaper
593
594
595def wallpaper_pgg(
596    generator: Union[Batch, Shape, Tag],
597    rotocenter: Point,
598    dx: float,
599    dy: float,
600    reps1: int = 4,
601    reps2: int = 4,
602    horizontal=True,
603) -> Batch:
604    """
605    Double glide symmetry.
606    IUC: pgg(p2gg)
607    Conway : 22x
608    Rectangular lattice
609    Point group: D2
610
611    Args:
612        generator (Union[Batch, Shape, Tag]): The repeating motif.
613        rotocenter (Point): The center of rotation.
614        dx (float): Translation distance in the x direction.
615        dy (float): Translation distance in the y direction.
616        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
617        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
618        horizontal (bool, optional): If True, the glide reflection is horizontal. Defaults to True.
619
620    Returns:
621        Batch: The resulting pattern as a Batch object.
622    """
623    if horizontal:
624        dist = rotocenter[0] - generator.center[0]
625        wallpaper = generator.glide(generator.horiz_centerline, 2 * dist, reps=1)
626        wallpaper.rotate(pi, rotocenter, reps=1)
627    else:
628        dist = rotocenter[1] - generator.center[1]
629        wallpaper = generator.glide(generator.vert_centerline, 2 * dist, reps=1)
630        wallpaper.rotate(pi, rotocenter, reps=1)
631    wallpaper.translate(dx, 0, reps1)
632    wallpaper.translate(0, dy, reps2)
633
634    return wallpaper
635
636
637def wallpaper_cmm(
638    generator: Union[Batch, Shape, Tag],
639    mirror_cross: Point,
640    rhomb_size: float,
641    reps1: int = 4,
642    reps2: int = 4,
643) -> Batch:
644    """
645    Staggered double mirror symmetry.
646    IUC: cmm(c2mm)
647    Conway : 2*22
648    Rhombic lattice
649    Point group: D2
650
651    Args:
652        generator (Union[Batch, Shape, Tag]): The repeating motif.
653        mirror_cross (Point): The point where the mirror lines cross.
654        rhomb_size (float): The size of the rhombuses.
655        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
656        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
657
658    Returns:
659        Batch: The resulting pattern as a Batch object.
660    """
661    x, y = mirror_cross[:2]
662    mirror_line1 = ((x, y), (x + 1, y))
663    mirror_line2 = ((x, y), (x, y + 1))
664    wallpaper = generator.mirror(mirror_line1, reps=1)
665    wallpaper.mirror(mirror_line2, reps=1)
666    cover_rhombic(wallpaper, rhomb_size, reps1=reps1, reps2=reps2)
667
668    return wallpaper
669
670
671def wallpaper_p4m(
672    generator: Union[Batch, Shape, Tag],
673    mirror_cross: Point,
674    side_length: float,
675    reps1: int = 4,
676    reps2: int = 4,
677) -> Batch:
678    """
679    Block symmetry.
680    IUC: p4m(p4mm)
681    Conway : *442
682    Square lattice
683    Point group: D4
684
685    Args:
686        generator (Union[Batch, Shape, Tag]): The repeating motif.
687        mirror_cross (Point): The point where the mirror lines cross.
688        side_length (float): The side length of the squares.
689        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
690        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
691
692    Returns:
693        Batch: The resulting pattern as a Batch object.
694    """
695    x, y = mirror_cross[:2]
696    mirror_line = ((x, y), (x, y + 1))
697    rotocenter = x, y
698    wallpaper = generator.mirror(mirror_line, reps=1)
699    wallpaper.rotate(pi / 2, rotocenter, reps=3)
700    wallpaper.translate(side_length, 0, reps=reps1)
701    wallpaper.translate(0, side_length, reps=reps2)
702
703    return wallpaper
704
705
706def wallpaper_p4g(
707    generator: Union[Batch, Shape, Tag], dist: float, reps1: int = 4, reps2: int = 4
708) -> Batch:
709    """
710    Mirrored pinwheel symmetry.
711    IUC: p4g(p4gm)
712    Conway : 4*2
713    Square lattice
714    Point group: D4
715
716    Args:
717        generator (Union[Batch, Shape, Tag]): The repeating motif.
718        dist (float): The distance between the centers of the squares.
719        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
720        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
721
722    Returns:
723        Batch: The resulting pattern as a Batch object.
724    """
725    # rotocenter should be (0, 0) and mirror_cross should be (d/4,d/4 )
726    # translations are (d, d)
727
728    wallpaper = generator.rotate(pi / 2, (0, 0), reps=3)
729    x, y = (dist / 4, dist / 4)
730    wallpaper.mirror(((x, y), (x + 1, y)), reps=1)
731    wallpaper.mirror(((x, y), (x, y + 1)), reps=1)
732    wallpaper.translate(dist, 0, reps=reps1)
733    wallpaper.translate(0, dist, reps=reps2)
734
735    return wallpaper
736
737
738def wallpaper_p3m1(
739    generator: Union[Batch, Shape, Tag],
740    center_point: Point,
741    hex_size: float,
742    reps1: int = 4,
743    reps2: int = 4,
744) -> Batch:
745    """
746    Mirror and three rotations.
747    IUC: p3m1
748    Conway : *333
749    Hexagonal lattice
750    Point group: D3
751
752    Args:
753        generator (Union[Batch, Shape, Tag]): The repeating motif.
754        center_point (Point): The center point for the symmetry.
755        hex_size (float): The size of the hexagons.
756        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
757        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
758
759    Returns:
760        Batch: The resulting pattern as a Batch object.
761    """
762    x, y = center_point[:2]
763    mirror_line = line_through_point_and_angle((x, y), 2 * pi / 3)
764    wallpaper = generator.mirror(mirror_line, reps=1)
765    wallpaper.rotate(2 * pi / 3, center_point, reps=2)
766    cover_hex(wallpaper, hex_size, reps1=reps1, reps2=reps2, flat=True)
767
768    return wallpaper
769
770
771def wallpaper_p31m(
772    generator: Union[Batch, Shape, Tag],
773    center_point: Point,
774    hex_size: float,
775    reps1: int = 4,
776    reps2: int = 4,
777) -> Batch:
778    """
779    Three rotations and a mirror.
780    IUC: p31m
781    Conway : 3*3
782    Hexagonal lattice
783    Point group: D3
784
785    Args:
786        generator (Union[Batch, Shape, Tag]): The repeating motif.
787        center_point (Point): The center point for the symmetry.
788        hex_size (float): The size of the hexagons.
789        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
790        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
791
792    Returns:
793        Batch: The resulting pattern as a Batch object.
794    """
795    x, y = center_point[:2]
796    dy = 0.28866 * hex_size
797    mirror_line = ((x, y + dy), (x + 1, y + dy))
798    wallpaper = generator.rotate(2 * pi / 3, center_point, reps=2)
799    wallpaper.mirror(mirror_line, reps=1)
800
801    rotocenter = (x + hex_size / 2, y + dy)
802    wallpaper.rotate(2 * pi / 3, rotocenter, reps=2)
803    cover_hex(wallpaper, hex_size, reps1=reps1, reps2=reps2, flat=True)
804
805    return wallpaper
806
807
808def wallpaper_p6m(
809    generator: Union[Batch, Shape, Tag],
810    rotocenter: Point,
811    mirror_cross: Point,
812    hex_size: float,
813    reps1: int = 4,
814    reps2: int = 4,
815    flat_hex: bool = False,
816) -> Batch:
817    """
818    Kaleidoscope.
819    IUC: p6m(p6mm)
820    Conway : *632
821    Hexagonal lattice
822    Point group: D6
823
824    Args:
825        generator (Union[Batch, Shape, Tag]): The repeating motif.
826        rotocenter (Point): The center of rotation.
827        mirror_cross (Point): The point where the mirror lines cross.
828        hex_size (float): The size of the hexagons.
829        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
830        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
831        flat_hex (bool, optional): If True, hexagons are flat-topped. Defaults to False.
832
833    Returns:
834        Batch: The resulting pattern as a Batch object.
835    """
836    x, y = mirror_cross[:2]
837    mirror1 = [(x, y), (x + 1, y)]
838    mirror2 = [(x, y), (x, y + 1)]
839    wallpaper = generator.mirror(mirror1, reps=1)
840    wallpaper.mirror(mirror2, reps=1)
841    wallpaper.rotate(pi / 3, rotocenter, reps=5)
842    wallpaper = wallpaper.merge_shapes(1, n_round=0)
843    if flat_hex:
844        cover_hex_flat(wallpaper, hex_size, reps1=reps1, reps2=reps2)
845    else:
846        cover_hex_pointy(wallpaper, hex_size, reps1=reps1, reps2=reps2)
847
848    return wallpaper
cos60 = 0.5000000000000001
cos30 = 0.8660254037844387
def cover_hex( item: Union[simetri.graphics.batch.Batch, simetri.graphics.shape.Shape, simetri.helpers.illustration.Tag], size: float, gap: float = 0, reps1: int = 2, reps2: int = 2, flat: bool = True) -> simetri.graphics.batch.Batch:
22def cover_hex(
23    item: Union[Batch, Shape, Tag],
24    size: float,
25    gap: float = 0,
26    reps1: int = 2,
27    reps2: int = 2,
28    flat: bool = True,
29) -> Batch:
30    """
31    Covers an area with a hexagonal pattern.
32
33    Args:
34        item (Union[Batch, Shape, Tag]): The item to be repeated.
35        size (float): The size of the hexagons.
36        gap (float, optional): The gap between hexagons. Defaults to 0.
37        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 2.
38        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 2.
39        flat (bool, optional): If True, hexagons are flat-topped. Defaults to True.
40
41    Returns:
42        Batch: The resulting pattern as a Batch object.
43    """
44    gap_x = 2 * gap * cos60
45    gap_y = gap * cos30
46    if (flat):
47        w = 2 * size
48        h = sqrt(3) * size
49        dx = 3 * size + (gap_x * 2)
50        dy = h + (gap_y * 2)
51        item.translate((3 * size / 2) + gap_x, (h / 2) + gap_y, reps=1)
52    else:
53        w = sqrt(3) * size
54        h = 2 * size
55        dx = w + (gap_x * 2)
56        dy = (2 * size) + (h / 2) + (gap_y * 2)
57        item.translate((w / 2) + gap_x, (3 * h / 4) + gap_y, reps=1)
58
59    item.translate(dx, 0, reps=reps1)
60    item.translate(0, dy, reps=reps2)
61
62    return item

Covers an area with a hexagonal pattern.

Arguments:
  • item (Union[Batch, Shape, Tag]): The item to be repeated.
  • size (float): The size of the hexagons.
  • gap (float, optional): The gap between hexagons. Defaults to 0.
  • reps1 (int, optional): Number of repetitions in the x direction. Defaults to 2.
  • reps2 (int, optional): Number of repetitions in the y direction. Defaults to 2.
  • flat (bool, optional): If True, hexagons are flat-topped. Defaults to True.
Returns:

Batch: The resulting pattern as a Batch object.

def cover_rhombic( item: Union[simetri.graphics.batch.Batch, simetri.graphics.shape.Shape, simetri.helpers.illustration.Tag], size: float, reps1: int = 2, reps2: int = 2) -> simetri.graphics.batch.Batch:
65def cover_rhombic(
66    item: Union[Batch, Shape, Tag], size: float, reps1: int = 2, reps2: int = 2
67) -> Batch:
68    """
69    Covers an area with a rhombic pattern.
70
71    Args:
72        item (Union[Batch, Shape, Tag]): The item to be repeated.
73        size (float): The size of the rhombuses.
74        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 2.
75        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 2.
76
77    Returns:
78        Batch: The resulting pattern as a Batch object.
79    """
80    sqrt2 = sqrt(2)
81    diag = (sqrt2 / 2) * size
82    item.translate(diag, diag, reps=1)
83    dx = dy = diag * 2
84    item.translate(dx, 0, reps=reps1)
85    item.translate(0, dy, reps=reps2)
86
87    return item

Covers an area with a rhombic pattern.

Arguments:
  • item (Union[Batch, Shape, Tag]): The item to be repeated.
  • size (float): The size of the rhombuses.
  • reps1 (int, optional): Number of repetitions in the x direction. Defaults to 2.
  • reps2 (int, optional): Number of repetitions in the y direction. Defaults to 2.
Returns:

Batch: The resulting pattern as a Batch object.

def hex_grid_pointy( x: float, y: float, size: float, n_rows: int, n_cols: int) -> simetri.graphics.batch.Batch:
 90def hex_grid_pointy(x: float, y: float, size: float, n_rows: int, n_cols: int) -> Batch:
 91    """
 92    Creates a hexagonal grid with pointy tops.
 93
 94    Args:
 95        x (float): The x-coordinate of the starting point.
 96        y (float): The y-coordinate of the starting point.
 97        size (float): The size of the hexagons.
 98        n_rows (int): Number of rows in the grid.
 99        n_cols (int): Number of columns in the grid.
100
101    Returns:
102        Batch: The resulting grid as a Batch of Shapes.
103    """
104    height = sqrt(3) * size
105    width = 2 * size
106    edge_length = 2 * size * cos(pi / 6)
107    # create the first row by translating a single hexagon in the x direction
108    row = Batch(Shape([(x, y)])).translate(size, 0, reps=n_cols - 1)
109    # create the second row by translating the first row
110    two_rows = row.translate(width, height + edge_length, reps=1)
111    # create the grid by translating the first and second row in the y direction
112    grid = two_rows.translate(0, 2 * size + edge_length, reps=n_rows / 2 - 1)
113
114    return grid

Creates a hexagonal grid with pointy tops.

Arguments:
  • x (float): The x-coordinate of the starting point.
  • y (float): The y-coordinate of the starting point.
  • size (float): The size of the hexagons.
  • n_rows (int): Number of rows in the grid.
  • n_cols (int): Number of columns in the grid.
Returns:

Batch: The resulting grid as a Batch of Shapes.

def cover_hex_pointy( item: Union[simetri.graphics.shape.Shape, simetri.graphics.batch.Batch, simetri.helpers.illustration.Tag], size: float, gap: float = 0, reps1: int = 2, reps2: int = 2) -> simetri.graphics.batch.Batch:
117def cover_hex_pointy(
118    item: Union[Shape, Batch, Tag],
119    size: float,
120    gap: float = 0,
121    reps1: int = 2,
122    reps2: int = 2,
123) -> Batch:
124    """
125    Covers an area with a hexagonal pattern with pointy tops.
126
127    Args:
128        item (Union[Shape, Batch, Tag]): The item to be repeated.
129        size (float): The size of the hexagons.
130        gap (float, optional): The gap between hexagons. Defaults to 0.
131        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 2.
132        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 2.
133
134    Returns:
135        Batch: The resulting pattern as a Batch object.
136    """
137    gap_x = 2 * gap * cos60
138    gap_y = gap * cos30
139    w = sqrt(3) * size
140    h = 2 * size
141    dx = w + (gap_x * 2)
142    dy = (2 * size) + (h / 2) + (gap_y * 2)
143    item.translate((w / 2) + gap_x, (3 * h / 4) + gap_y, reps=1)
144    item.translate(dx, 0, reps=reps1)
145    item.translate(0, dy, reps=reps2)
146
147    return item

Covers an area with a hexagonal pattern with pointy tops.

Arguments:
  • item (Union[Shape, Batch, Tag]): The item to be repeated.
  • size (float): The size of the hexagons.
  • gap (float, optional): The gap between hexagons. Defaults to 0.
  • reps1 (int, optional): Number of repetitions in the x direction. Defaults to 2.
  • reps2 (int, optional): Number of repetitions in the y direction. Defaults to 2.
Returns:

Batch: The resulting pattern as a Batch object.

def cover_hex_flat( item: Union[simetri.graphics.batch.Batch, simetri.graphics.shape.Shape, simetri.helpers.illustration.Tag], size: float, gap: float = 0, reps1: int = 2, reps2: int = 2) -> simetri.graphics.batch.Batch:
150def cover_hex_flat(
151    item: Union[Batch, Shape, Tag],
152    size: float,
153    gap: float = 0,
154    reps1: int = 2,
155    reps2: int = 2,
156) -> Batch:
157    """
158    Covers an area with a hexagonal pattern with flat tops.
159
160    Args:
161        item (Union[Batch, Shape, Tag]): The item to be repeated.
162        size (float): The size of the hexagons.
163        gap (float, optional): The gap between hexagons. Defaults to 0.
164        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 2.
165        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 2.
166
167    Returns:
168        Batch: The resulting pattern as a Batch object.
169    """
170    gap_x = 2 * gap * cos60
171    gap_y = gap * cos30
172    h = sqrt(3) * size
173    dx = 3 * size + (gap_x * 2)
174    dy = h + (gap_y * 2)
175    item.translate((3 * size / 2) + gap_x, (h / 2) + gap_y, reps=1)
176    item.translate(dx, 0, reps=reps1)
177    item.translate(0, dy, reps=reps2)
178
179    return item

Covers an area with a hexagonal pattern with flat tops.

Arguments:
  • item (Union[Batch, Shape, Tag]): The item to be repeated.
  • size (float): The size of the hexagons.
  • gap (float, optional): The gap between hexagons. Defaults to 0.
  • reps1 (int, optional): Number of repetitions in the x direction. Defaults to 2.
  • reps2 (int, optional): Number of repetitions in the y direction. Defaults to 2.
Returns:

Batch: The resulting pattern as a Batch object.

def wallpaper_p1( generator: Union[simetri.graphics.batch.Batch, simetri.graphics.shape.Shape, simetri.helpers.illustration.Tag], vector1: Sequence[float], vector2: Sequence[float], reps1: int = 4, reps2: int = 4) -> simetri.graphics.batch.Batch:
193def wallpaper_p1(
194    generator: Union[Batch, Shape, Tag],
195    vector1: VecType,
196    vector2: VecType,
197    reps1: int = 4,
198    reps2: int = 4,
199) -> Batch:
200    """
201    Translation symmetry.
202    IUC: p1
203    Conway: o
204    Oblique lattice
205    Point group: C1
206
207    Args:
208        generator (Union[Batch, Shape, Tag]): The repeating motif.
209        vector1 (VecType): The translation vector in the x direction.
210        vector2 (VecType): The translation vector in the y direction.
211        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
212        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
213
214    Returns:
215        Batch: The resulting wallpaper pattern as a Batch object.
216    """
217    dx1, dy1 = vector1
218    wallpaper = generator.translate(dx1, dy1, reps1)
219    dx2, dy2 = vector2
220    wallpaper.translate(dx2, dy2, reps2)
221
222    return wallpaper

Translation symmetry. IUC: p1 Conway: o Oblique lattice Point group: C1

Arguments:
  • generator (Union[Batch, Shape, Tag]): The repeating motif.
  • vector1 (VecType): The translation vector in the x direction.
  • vector2 (VecType): The translation vector in the y direction.
  • reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
  • reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
Returns:

Batch: The resulting wallpaper pattern as a Batch object.

def wallpaper_p2( generator: Union[simetri.graphics.shape.Shape, simetri.graphics.batch.Batch, simetri.helpers.illustration.Tag], vector1: Sequence[float], vector2: Sequence[float], reps1: int = 4, reps2: int = 4) -> simetri.graphics.batch.Batch:
225def wallpaper_p2(
226    generator: Union[Shape, Batch, Tag],
227    vector1: VecType,
228    vector2: VecType,
229    reps1: int = 4,
230    reps2: int = 4,
231) -> Batch:
232    """
233    Half-turn rotation symmetry.
234    IUC: p2 (p211)
235    Conway: 2222
236    Oblique lattice
237    Point group: C2
238
239    Args:
240        generator (Union[Shape, Batch, Tag]): The repeating motif.
241        vector1 (VecType): The translation vector in the x direction.
242        vector2 (VecType): The translation vector in the y direction.
243        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
244        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
245
246    Returns:
247        Batch: The resulting wallpaper pattern as a Batch object.
248    """
249    rotocenter = mid_point(vector1, vector2)
250    wallpaper = generator.rotate(pi, rotocenter, reps=1)
251    dx1, dy1 = vector1
252    wallpaper.translate(dx1, dy1, reps=reps1)
253    dx2, dy2 = vector2
254    wallpaper.translate(dx2, dy2, reps=reps2)
255
256    return wallpaper

Half-turn rotation symmetry. IUC: p2 (p211) Conway: 2222 Oblique lattice Point group: C2

Arguments:
  • generator (Union[Shape, Batch, Tag]): The repeating motif.
  • vector1 (VecType): The translation vector in the x direction.
  • vector2 (VecType): The translation vector in the y direction.
  • reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
  • reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
Returns:

Batch: The resulting wallpaper pattern as a Batch object.

def wallpaper_p2_rect_lattice( generator: Union[simetri.graphics.shape.Shape, simetri.graphics.batch.Batch, simetri.helpers.illustration.Tag], rotocenter: Sequence[float], vector1: Sequence[float], vector2: Sequence[float], reps1: int = 4, reps2: int = 4) -> simetri.graphics.batch.Batch:
259def wallpaper_p2_rect_lattice(
260    generator: Union[Shape, Batch, Tag],
261    rotocenter: Point,
262    vector1: VecType,
263    vector2: VecType,
264    reps1: int = 4,
265    reps2: int = 4,
266) -> Batch:
267    # """
268    # Half-turn rotation symmetry.
269    # IUC: p2 (p211)
270    # Conway: 2222
271    # Oblique lattice
272    # Point group: C2
273
274    # Point argument can be an Anchor object or a tuple, or two points can be given
275    # as a sequence.
276
277    # Example:
278    # import simetri.graphics as sg
279    # import simetri.wallpaper as wp
280
281    # directory = 'dir_path'
282    # canvas = sg.Canvas()
283
284    # F = sg.letter_F()
285    # vec1 = (2 * F.width + 10, 0)
286    # vec2 = (0, F.height + 10)
287
288    # pattern = wp.wallpaper_p2(F, vec1, vec2, reps1=2, reps2=2)
289    # file_path = os.path.join(directory, 'wallpaper_test_p2.pdf')
290    # canvas.draw(pattern, file_path=file_path)
291
292    # """
293
294    rotocenter = mid_point(vector1, vector2)
295    wallpaper = generator.rotate(pi, rotocenter, reps=1)
296    dx1, dy1 = vector1
297    wallpaper.translate(dx1, dy1, reps=reps1)
298    dx2, dy2 = vector2
299    wallpaper.translate(dx2, dy2, reps=reps2)
300
301    return wallpaper
def wallpaper_p3( generator: Union[simetri.graphics.shape.Shape, simetri.graphics.batch.Batch, simetri.helpers.illustration.Tag], rotocenter: Sequence[float], distance: float, reps1: int = 4, reps2: int = 4, flat_hex: bool = False) -> simetri.graphics.batch.Batch:
304def wallpaper_p3(
305    generator: Union[Shape, Batch, Tag],
306    rotocenter: Point,
307    distance: float,
308    reps1: int = 4,
309    reps2: int = 4,
310    flat_hex: bool = False,
311) -> Batch:
312    """
313    Three rotations.
314    IUC: p3
315    Conway: 333
316    Hexagonal lattice.
317    Point group: C3
318
319    Args:
320        generator (Union[Shape, Batch, Tag]): The repeating motif.
321        rotocenter (Point): The center of rotation.
322        distance (float): The distance between the centers of the hexagons.
323        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
324        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
325        flat_hex (bool, optional): If True, hexagons are flat-topped. Defaults to False.
326
327    Returns:
328        Batch: The resulting wallpaper pattern as a Batch object.
329    """
330    wallpaper = generator.rotate(2 * pi / 3, rotocenter, reps=2)
331    if flat_hex:
332        cover_hex_flat(wallpaper, distance, reps1=reps1, reps2=reps2)
333    else:
334        cover_hex_pointy(wallpaper, distance, reps1=reps1, reps2=reps2)
335
336    return wallpaper

Three rotations. IUC: p3 Conway: 333 Hexagonal lattice. Point group: C3

Arguments:
  • generator (Union[Shape, Batch, Tag]): The repeating motif.
  • rotocenter (Point): The center of rotation.
  • distance (float): The distance between the centers of the hexagons.
  • reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
  • reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
  • flat_hex (bool, optional): If True, hexagons are flat-topped. Defaults to False.
Returns:

Batch: The resulting wallpaper pattern as a Batch object.

def wallpaper_p4( generator: Union[simetri.graphics.batch.Batch, simetri.graphics.shape.Shape, simetri.helpers.illustration.Tag], rotocenter: Sequence[float], distance: float, reps1: int = 4, reps2: int = 4) -> simetri.graphics.batch.Batch:
339def wallpaper_p4(
340    generator: Union[Batch, Shape, Tag],
341    rotocenter: Point,
342    distance: float,
343    reps1: int = 4,
344    reps2: int = 4,
345) -> Batch:
346    """
347    Pinwheel symmetry.
348    IUC: p4
349    Conway: 442
350    Square lattice
351    Point group: C4
352
353    Args:
354        generator (Union[Batch, Shape, Tag]): The repeating motif.
355        rotocenter (Point): The center of rotation.
356        distance (float): The distance between the centers of the squares.
357        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
358        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
359
360    Returns:
361        Batch: The resulting wallpaper pattern as a Batch object.
362    """
363    wallpaper = generator.rotate(pi / 2, rotocenter, reps=3)
364    wallpaper.translate(distance, 0, reps1)
365    wallpaper.translate(0, distance, reps2)
366
367    return wallpaper

Pinwheel symmetry. IUC: p4 Conway: 442 Square lattice Point group: C4

Arguments:
  • generator (Union[Batch, Shape, Tag]): The repeating motif.
  • rotocenter (Point): The center of rotation.
  • distance (float): The distance between the centers of the squares.
  • reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
  • reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
Returns:

Batch: The resulting wallpaper pattern as a Batch object.

def wallpaper_p6( generator: Union[simetri.graphics.batch.Batch, simetri.graphics.shape.Shape, simetri.helpers.illustration.Tag], rotocenter: Sequence[float], hex_size: float, reps1: int = 4, reps2: int = 4, flat_hex=False) -> simetri.graphics.batch.Batch:
370def wallpaper_p6(
371    generator: Union[Batch, Shape, Tag],
372    rotocenter: Point,
373    hex_size: float,
374    reps1: int = 4,
375    reps2: int = 4,
376    flat_hex=False,
377) -> Batch:
378    """
379    Six rotations.
380    IUC: p6
381    Conway : 632
382    Hexagonal lattice
383    Point group: C6
384
385    Args:
386        generator (Union[Batch, Shape, Tag]): The repeating motif.
387        rotocenter (Point): The center of rotation.
388        hex_size (float): The size of the hexagons.
389        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
390        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
391        flat_hex (bool, optional): If True, hexagons are flat-topped. Defaults to False.
392
393    Returns:
394        Batch: The resulting pattern as a Batch object.
395    """
396    wallpaper = generator.rotate(pi / 3, rotocenter, reps=5)
397    if flat_hex:
398        cover_hex_flat(wallpaper, hex_size, reps1=reps1, reps2=reps2)
399    else:
400        cover_hex_pointy(wallpaper, hex_size, reps1=reps1, reps2=reps2)
401
402    return wallpaper

Six rotations. IUC: p6 Conway : 632 Hexagonal lattice Point group: C6

Arguments:
  • generator (Union[Batch, Shape, Tag]): The repeating motif.
  • rotocenter (Point): The center of rotation.
  • hex_size (float): The size of the hexagons.
  • reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
  • reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
  • flat_hex (bool, optional): If True, hexagons are flat-topped. Defaults to False.
Returns:

Batch: The resulting pattern as a Batch object.

def wallpaper_pm( generator: Union[simetri.graphics.batch.Batch, simetri.graphics.shape.Shape, simetri.helpers.illustration.Tag], mirror_line: Sequence[Sequence], dx: float, dy: float, reps1: int = 4, reps2: int = 4) -> simetri.graphics.batch.Batch:
405def wallpaper_pm(
406    generator: Union[Batch, Shape, Tag],
407    mirror_line: Line,
408    dx: float,
409    dy: float,
410    reps1: int = 4,
411    reps2: int = 4,
412) -> Batch:
413    """
414    Mirror symmetry.
415    Mirror could be horizontal or vertical.
416    IUC: pm(p1m1)
417    Conway : **
418    Rectangular lattice
419    Point group: D1
420
421    Args:
422        generator (Union[Batch, Shape, Tag]): The repeating motif.
423        mirror_line (Line): The line of symmetry.
424        dx (float): Translation distance in the x direction.
425        dy (float): Translation distance in the y direction.
426        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
427        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
428
429    Returns:
430        Batch: The resulting pattern as a Batch object.
431    """
432    wallpaper = generator.mirror(mirror_line, reps=1)
433    wallpaper.translate(dx, 0, reps=reps1)
434    wallpaper.translate(0, dy, reps=reps2)
435
436    return wallpaper

Mirror symmetry. Mirror could be horizontal or vertical. IUC: pm(p1m1) Conway : ** Rectangular lattice Point group: D1

Arguments:
  • generator (Union[Batch, Shape, Tag]): The repeating motif.
  • mirror_line (Line): The line of symmetry.
  • dx (float): Translation distance in the x direction.
  • dy (float): Translation distance in the y direction.
  • reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
  • reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
Returns:

Batch: The resulting pattern as a Batch object.

def wallpaper_pg( generator: Union[simetri.graphics.batch.Batch, simetri.graphics.shape.Shape, simetri.helpers.illustration.Tag], mirror_line: Sequence[Sequence], distance: float, dx: float, dy: float, reps1: int = 4, reps2: int = 4) -> simetri.graphics.batch.Batch:
439def wallpaper_pg(
440    generator: Union[Batch, Shape, Tag],
441    mirror_line: Line,
442    distance: float,
443    dx: float,
444    dy: float,
445    reps1: int = 4,
446    reps2: int = 4,
447) -> Batch:
448    """
449    Glide symmetry.
450    IUC: pg(p1g1)
451    Conway : xx
452    Rectangular lattice
453    Point group: D1
454
455    Args:
456        generator (Union[Batch, Shape, Tag]): The repeating motif.
457        mirror_line (Line): The line of symmetry.
458        distance (float): The distance for the glide reflection.
459        dx (float): Translation distance in the x direction.
460        dy (float): Translation distance in the y direction.
461        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
462        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
463
464    Returns:
465        Batch: The resulting pattern as a Batch object.
466    """
467    wallpaper = generator.glide(mirror_line, distance, reps=1)
468    wallpaper.translate(dx, 0, reps=reps1)
469    wallpaper.translate(0, dy, reps=reps2)
470
471    return wallpaper

Glide symmetry. IUC: pg(p1g1) Conway : xx Rectangular lattice Point group: D1

Arguments:
  • generator (Union[Batch, Shape, Tag]): The repeating motif.
  • mirror_line (Line): The line of symmetry.
  • distance (float): The distance for the glide reflection.
  • dx (float): Translation distance in the x direction.
  • dy (float): Translation distance in the y direction.
  • reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
  • reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
Returns:

Batch: The resulting pattern as a Batch object.

def wallpaper_cm( generator: Union[simetri.graphics.batch.Batch, simetri.graphics.shape.Shape, simetri.helpers.illustration.Tag], mirror_point: Sequence[float], rhomb_size: float, reps1: int = 4, reps2: int = 4, horizontal: bool = True) -> simetri.graphics.batch.Batch:
474def wallpaper_cm(
475    generator: Union[Batch, Shape, Tag],
476    mirror_point: Point,
477    rhomb_size: float,
478    reps1: int = 4,
479    reps2: int = 4,
480    horizontal: bool = True,
481) -> Batch:
482    """
483    Spinning-sidle symmetry.
484    IUC: cm(c1m1)
485    Conway : *x
486    Rhombic lattice
487    Point group: D1
488
489    Args:
490        generator (Union[Batch, Shape, Tag]): The repeating motif.
491        mirror_point (Point): The point of symmetry.
492        rhomb_size (float): The size of the rhombuses.
493        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
494        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
495        horizontal (bool, optional): If True, the mirror line is horizontal. Defaults to True.
496
497    Returns:
498        Batch: The resulting pattern as a Batch object.
499    """
500    x1, y1 = mirror_point
501    if horizontal:
502        x2, y2 = x1 + 1, y1
503    else:
504        x2, y2 = x1, y1 + 1
505    wallpaper = generator.mirror(((x1, y1), (x2, y2)), reps=1)
506    cover_rhombic(
507        wallpaper,
508        rhomb_size,
509        reps1=reps1,
510        reps2=reps2,
511    )
512
513    return wallpaper

Spinning-sidle symmetry. IUC: cm(c1m1) Conway : *x Rhombic lattice Point group: D1

Arguments:
  • generator (Union[Batch, Shape, Tag]): The repeating motif.
  • mirror_point (Point): The point of symmetry.
  • rhomb_size (float): The size of the rhombuses.
  • reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
  • reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
  • horizontal (bool, optional): If True, the mirror line is horizontal. Defaults to True.
Returns:

Batch: The resulting pattern as a Batch object.

def wallpaper_pmm( generator: Union[simetri.graphics.batch.Batch, simetri.graphics.shape.Shape, simetri.helpers.illustration.Tag], mirror_cross: Sequence[float], dx: float, dy: float, reps1=4, reps2=4) -> simetri.graphics.batch.Batch:
516def wallpaper_pmm(
517    generator: Union[Batch, Shape, Tag],
518    mirror_cross: Point,
519    dx: float,
520    dy: float,
521    reps1=4,
522    reps2=4,
523) -> Batch:
524    """
525    Double mirror symmetry.
526    IUC: pmm(p2mm)
527    Conway : *2222
528    Rectangular lattice
529    Point group: D2
530
531    Args:
532        generator (Union[Batch, Shape, Tag]): The repeating motif.
533        mirror_cross (Point): The point where the mirror lines cross.
534        dx (float): Translation distance in the x direction.
535        dy (float): Translation distance in the y direction.
536        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
537        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
538
539    Returns:
540        Batch: The resulting pattern as a Batch object.
541    """
542    x, y = mirror_cross[:2]
543    mirror_line1 = ((x, y), (x + 1, y))
544    mirror_line2 = ((x, y), (x, y + 1))
545    wallpaper = generator.mirror(mirror_line1, reps=1)
546    wallpaper.mirror(mirror_line2, reps=1)
547    wallpaper.translate(dx, 0, reps=reps1)
548    wallpaper.translate(0, dy, reps=reps2)
549
550    return wallpaper

Double mirror symmetry. IUC: pmm(p2mm) Conway : *2222 Rectangular lattice Point group: D2

Arguments:
  • generator (Union[Batch, Shape, Tag]): The repeating motif.
  • mirror_cross (Point): The point where the mirror lines cross.
  • dx (float): Translation distance in the x direction.
  • dy (float): Translation distance in the y direction.
  • reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
  • reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
Returns:

Batch: The resulting pattern as a Batch object.

def wallpaper_pmg( generator: Union[simetri.graphics.batch.Batch, simetri.graphics.shape.Shape, simetri.helpers.illustration.Tag], center_point: Sequence[float], dx: float, dy: float, reps1=4, reps2=4, horizontal=True) -> simetri.graphics.batch.Batch:
553def wallpaper_pmg(
554    generator: Union[Batch, Shape, Tag],
555    center_point: Point,
556    dx: float,
557    dy: float,
558    reps1=4,
559    reps2=4,
560    horizontal=True,
561) -> Batch:
562    """
563    Glided staggered symmetry.
564    IUC: pmg(p2mg)
565    Conway : 22*
566    Rectangular lattice
567    Point group: D2
568
569    Args:
570        generator (Union[Batch, Shape, Tag]): The repeating motif.
571        center_point (Point): The center point for the symmetry.
572        dx (float): Translation distance in the x direction.
573        dy (float): Translation distance in the y direction.
574        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
575        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
576        horizontal (bool, optional): If True, the mirror line is horizontal. Defaults to True.
577
578    Returns:
579        Batch: The resulting pattern as a Batch object.
580    """
581    x, y = center_point[:2]
582    if horizontal:
583        rotocenter = mid_point((x, y), (x, (y + dy) / 2))
584        mirror_line = ((x, y), (x + 1, y))
585    else:
586        rotocenter = mid_point((x, y), (-(x + dx) / 2, y))
587        mirror_line = ((x, y), (x, y + 1))
588    wallpaper = generator.rotate(pi, rotocenter, reps=1)
589    wallpaper.mirror(mirror_line, reps=1)
590    wallpaper.translate(dx, 0, reps=reps1)
591    wallpaper.translate(0, dy, reps=reps2)
592
593    return wallpaper

Glided staggered symmetry. IUC: pmg(p2mg) Conway : 22* Rectangular lattice Point group: D2

Arguments:
  • generator (Union[Batch, Shape, Tag]): The repeating motif.
  • center_point (Point): The center point for the symmetry.
  • dx (float): Translation distance in the x direction.
  • dy (float): Translation distance in the y direction.
  • reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
  • reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
  • horizontal (bool, optional): If True, the mirror line is horizontal. Defaults to True.
Returns:

Batch: The resulting pattern as a Batch object.

def wallpaper_pgg( generator: Union[simetri.graphics.batch.Batch, simetri.graphics.shape.Shape, simetri.helpers.illustration.Tag], rotocenter: Sequence[float], dx: float, dy: float, reps1: int = 4, reps2: int = 4, horizontal=True) -> simetri.graphics.batch.Batch:
596def wallpaper_pgg(
597    generator: Union[Batch, Shape, Tag],
598    rotocenter: Point,
599    dx: float,
600    dy: float,
601    reps1: int = 4,
602    reps2: int = 4,
603    horizontal=True,
604) -> Batch:
605    """
606    Double glide symmetry.
607    IUC: pgg(p2gg)
608    Conway : 22x
609    Rectangular lattice
610    Point group: D2
611
612    Args:
613        generator (Union[Batch, Shape, Tag]): The repeating motif.
614        rotocenter (Point): The center of rotation.
615        dx (float): Translation distance in the x direction.
616        dy (float): Translation distance in the y direction.
617        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
618        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
619        horizontal (bool, optional): If True, the glide reflection is horizontal. Defaults to True.
620
621    Returns:
622        Batch: The resulting pattern as a Batch object.
623    """
624    if horizontal:
625        dist = rotocenter[0] - generator.center[0]
626        wallpaper = generator.glide(generator.horiz_centerline, 2 * dist, reps=1)
627        wallpaper.rotate(pi, rotocenter, reps=1)
628    else:
629        dist = rotocenter[1] - generator.center[1]
630        wallpaper = generator.glide(generator.vert_centerline, 2 * dist, reps=1)
631        wallpaper.rotate(pi, rotocenter, reps=1)
632    wallpaper.translate(dx, 0, reps1)
633    wallpaper.translate(0, dy, reps2)
634
635    return wallpaper

Double glide symmetry. IUC: pgg(p2gg) Conway : 22x Rectangular lattice Point group: D2

Arguments:
  • generator (Union[Batch, Shape, Tag]): The repeating motif.
  • rotocenter (Point): The center of rotation.
  • dx (float): Translation distance in the x direction.
  • dy (float): Translation distance in the y direction.
  • reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
  • reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
  • horizontal (bool, optional): If True, the glide reflection is horizontal. Defaults to True.
Returns:

Batch: The resulting pattern as a Batch object.

def wallpaper_cmm( generator: Union[simetri.graphics.batch.Batch, simetri.graphics.shape.Shape, simetri.helpers.illustration.Tag], mirror_cross: Sequence[float], rhomb_size: float, reps1: int = 4, reps2: int = 4) -> simetri.graphics.batch.Batch:
638def wallpaper_cmm(
639    generator: Union[Batch, Shape, Tag],
640    mirror_cross: Point,
641    rhomb_size: float,
642    reps1: int = 4,
643    reps2: int = 4,
644) -> Batch:
645    """
646    Staggered double mirror symmetry.
647    IUC: cmm(c2mm)
648    Conway : 2*22
649    Rhombic lattice
650    Point group: D2
651
652    Args:
653        generator (Union[Batch, Shape, Tag]): The repeating motif.
654        mirror_cross (Point): The point where the mirror lines cross.
655        rhomb_size (float): The size of the rhombuses.
656        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
657        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
658
659    Returns:
660        Batch: The resulting pattern as a Batch object.
661    """
662    x, y = mirror_cross[:2]
663    mirror_line1 = ((x, y), (x + 1, y))
664    mirror_line2 = ((x, y), (x, y + 1))
665    wallpaper = generator.mirror(mirror_line1, reps=1)
666    wallpaper.mirror(mirror_line2, reps=1)
667    cover_rhombic(wallpaper, rhomb_size, reps1=reps1, reps2=reps2)
668
669    return wallpaper

Staggered double mirror symmetry. IUC: cmm(c2mm) Conway : 2*22 Rhombic lattice Point group: D2

Arguments:
  • generator (Union[Batch, Shape, Tag]): The repeating motif.
  • mirror_cross (Point): The point where the mirror lines cross.
  • rhomb_size (float): The size of the rhombuses.
  • reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
  • reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
Returns:

Batch: The resulting pattern as a Batch object.

def wallpaper_p4m( generator: Union[simetri.graphics.batch.Batch, simetri.graphics.shape.Shape, simetri.helpers.illustration.Tag], mirror_cross: Sequence[float], side_length: float, reps1: int = 4, reps2: int = 4) -> simetri.graphics.batch.Batch:
672def wallpaper_p4m(
673    generator: Union[Batch, Shape, Tag],
674    mirror_cross: Point,
675    side_length: float,
676    reps1: int = 4,
677    reps2: int = 4,
678) -> Batch:
679    """
680    Block symmetry.
681    IUC: p4m(p4mm)
682    Conway : *442
683    Square lattice
684    Point group: D4
685
686    Args:
687        generator (Union[Batch, Shape, Tag]): The repeating motif.
688        mirror_cross (Point): The point where the mirror lines cross.
689        side_length (float): The side length of the squares.
690        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
691        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
692
693    Returns:
694        Batch: The resulting pattern as a Batch object.
695    """
696    x, y = mirror_cross[:2]
697    mirror_line = ((x, y), (x, y + 1))
698    rotocenter = x, y
699    wallpaper = generator.mirror(mirror_line, reps=1)
700    wallpaper.rotate(pi / 2, rotocenter, reps=3)
701    wallpaper.translate(side_length, 0, reps=reps1)
702    wallpaper.translate(0, side_length, reps=reps2)
703
704    return wallpaper

Block symmetry. IUC: p4m(p4mm) Conway : *442 Square lattice Point group: D4

Arguments:
  • generator (Union[Batch, Shape, Tag]): The repeating motif.
  • mirror_cross (Point): The point where the mirror lines cross.
  • side_length (float): The side length of the squares.
  • reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
  • reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
Returns:

Batch: The resulting pattern as a Batch object.

def wallpaper_p4g( generator: Union[simetri.graphics.batch.Batch, simetri.graphics.shape.Shape, simetri.helpers.illustration.Tag], dist: float, reps1: int = 4, reps2: int = 4) -> simetri.graphics.batch.Batch:
707def wallpaper_p4g(
708    generator: Union[Batch, Shape, Tag], dist: float, reps1: int = 4, reps2: int = 4
709) -> Batch:
710    """
711    Mirrored pinwheel symmetry.
712    IUC: p4g(p4gm)
713    Conway : 4*2
714    Square lattice
715    Point group: D4
716
717    Args:
718        generator (Union[Batch, Shape, Tag]): The repeating motif.
719        dist (float): The distance between the centers of the squares.
720        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
721        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
722
723    Returns:
724        Batch: The resulting pattern as a Batch object.
725    """
726    # rotocenter should be (0, 0) and mirror_cross should be (d/4,d/4 )
727    # translations are (d, d)
728
729    wallpaper = generator.rotate(pi / 2, (0, 0), reps=3)
730    x, y = (dist / 4, dist / 4)
731    wallpaper.mirror(((x, y), (x + 1, y)), reps=1)
732    wallpaper.mirror(((x, y), (x, y + 1)), reps=1)
733    wallpaper.translate(dist, 0, reps=reps1)
734    wallpaper.translate(0, dist, reps=reps2)
735
736    return wallpaper

Mirrored pinwheel symmetry. IUC: p4g(p4gm) Conway : 4*2 Square lattice Point group: D4

Arguments:
  • generator (Union[Batch, Shape, Tag]): The repeating motif.
  • dist (float): The distance between the centers of the squares.
  • reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
  • reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
Returns:

Batch: The resulting pattern as a Batch object.

def wallpaper_p3m1( generator: Union[simetri.graphics.batch.Batch, simetri.graphics.shape.Shape, simetri.helpers.illustration.Tag], center_point: Sequence[float], hex_size: float, reps1: int = 4, reps2: int = 4) -> simetri.graphics.batch.Batch:
739def wallpaper_p3m1(
740    generator: Union[Batch, Shape, Tag],
741    center_point: Point,
742    hex_size: float,
743    reps1: int = 4,
744    reps2: int = 4,
745) -> Batch:
746    """
747    Mirror and three rotations.
748    IUC: p3m1
749    Conway : *333
750    Hexagonal lattice
751    Point group: D3
752
753    Args:
754        generator (Union[Batch, Shape, Tag]): The repeating motif.
755        center_point (Point): The center point for the symmetry.
756        hex_size (float): The size of the hexagons.
757        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
758        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
759
760    Returns:
761        Batch: The resulting pattern as a Batch object.
762    """
763    x, y = center_point[:2]
764    mirror_line = line_through_point_and_angle((x, y), 2 * pi / 3)
765    wallpaper = generator.mirror(mirror_line, reps=1)
766    wallpaper.rotate(2 * pi / 3, center_point, reps=2)
767    cover_hex(wallpaper, hex_size, reps1=reps1, reps2=reps2, flat=True)
768
769    return wallpaper

Mirror and three rotations. IUC: p3m1 Conway : *333 Hexagonal lattice Point group: D3

Arguments:
  • generator (Union[Batch, Shape, Tag]): The repeating motif.
  • center_point (Point): The center point for the symmetry.
  • hex_size (float): The size of the hexagons.
  • reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
  • reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
Returns:

Batch: The resulting pattern as a Batch object.

def wallpaper_p31m( generator: Union[simetri.graphics.batch.Batch, simetri.graphics.shape.Shape, simetri.helpers.illustration.Tag], center_point: Sequence[float], hex_size: float, reps1: int = 4, reps2: int = 4) -> simetri.graphics.batch.Batch:
772def wallpaper_p31m(
773    generator: Union[Batch, Shape, Tag],
774    center_point: Point,
775    hex_size: float,
776    reps1: int = 4,
777    reps2: int = 4,
778) -> Batch:
779    """
780    Three rotations and a mirror.
781    IUC: p31m
782    Conway : 3*3
783    Hexagonal lattice
784    Point group: D3
785
786    Args:
787        generator (Union[Batch, Shape, Tag]): The repeating motif.
788        center_point (Point): The center point for the symmetry.
789        hex_size (float): The size of the hexagons.
790        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
791        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
792
793    Returns:
794        Batch: The resulting pattern as a Batch object.
795    """
796    x, y = center_point[:2]
797    dy = 0.28866 * hex_size
798    mirror_line = ((x, y + dy), (x + 1, y + dy))
799    wallpaper = generator.rotate(2 * pi / 3, center_point, reps=2)
800    wallpaper.mirror(mirror_line, reps=1)
801
802    rotocenter = (x + hex_size / 2, y + dy)
803    wallpaper.rotate(2 * pi / 3, rotocenter, reps=2)
804    cover_hex(wallpaper, hex_size, reps1=reps1, reps2=reps2, flat=True)
805
806    return wallpaper

Three rotations and a mirror. IUC: p31m Conway : 3*3 Hexagonal lattice Point group: D3

Arguments:
  • generator (Union[Batch, Shape, Tag]): The repeating motif.
  • center_point (Point): The center point for the symmetry.
  • hex_size (float): The size of the hexagons.
  • reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
  • reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
Returns:

Batch: The resulting pattern as a Batch object.

def wallpaper_p6m( generator: Union[simetri.graphics.batch.Batch, simetri.graphics.shape.Shape, simetri.helpers.illustration.Tag], rotocenter: Sequence[float], mirror_cross: Sequence[float], hex_size: float, reps1: int = 4, reps2: int = 4, flat_hex: bool = False) -> simetri.graphics.batch.Batch:
809def wallpaper_p6m(
810    generator: Union[Batch, Shape, Tag],
811    rotocenter: Point,
812    mirror_cross: Point,
813    hex_size: float,
814    reps1: int = 4,
815    reps2: int = 4,
816    flat_hex: bool = False,
817) -> Batch:
818    """
819    Kaleidoscope.
820    IUC: p6m(p6mm)
821    Conway : *632
822    Hexagonal lattice
823    Point group: D6
824
825    Args:
826        generator (Union[Batch, Shape, Tag]): The repeating motif.
827        rotocenter (Point): The center of rotation.
828        mirror_cross (Point): The point where the mirror lines cross.
829        hex_size (float): The size of the hexagons.
830        reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
831        reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
832        flat_hex (bool, optional): If True, hexagons are flat-topped. Defaults to False.
833
834    Returns:
835        Batch: The resulting pattern as a Batch object.
836    """
837    x, y = mirror_cross[:2]
838    mirror1 = [(x, y), (x + 1, y)]
839    mirror2 = [(x, y), (x, y + 1)]
840    wallpaper = generator.mirror(mirror1, reps=1)
841    wallpaper.mirror(mirror2, reps=1)
842    wallpaper.rotate(pi / 3, rotocenter, reps=5)
843    wallpaper = wallpaper.merge_shapes(1, n_round=0)
844    if flat_hex:
845        cover_hex_flat(wallpaper, hex_size, reps1=reps1, reps2=reps2)
846    else:
847        cover_hex_pointy(wallpaper, hex_size, reps1=reps1, reps2=reps2)
848
849    return wallpaper

Kaleidoscope. IUC: p6m(p6mm) Conway : *632 Hexagonal lattice Point group: D6

Arguments:
  • generator (Union[Batch, Shape, Tag]): The repeating motif.
  • rotocenter (Point): The center of rotation.
  • mirror_cross (Point): The point where the mirror lines cross.
  • hex_size (float): The size of the hexagons.
  • reps1 (int, optional): Number of repetitions in the x direction. Defaults to 4.
  • reps2 (int, optional): Number of repetitions in the y direction. Defaults to 4.
  • flat_hex (bool, optional): If True, hexagons are flat-topped. Defaults to False.
Returns:

Batch: The resulting pattern as a Batch object.