-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathgrid3.py
42 lines (34 loc) · 1008 Bytes
/
grid3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from __future__ import annotations
import svg
STROKE_LEN = 10
GAP = 10
WIDTH = 400
HEIGHT = 400
SHIFT = int(STROKE_LEN / 2)
STEP = STROKE_LEN + GAP
def draw() -> svg.SVG:
elements: list[svg.Element] = []
do_shift = True
for y in range(STROKE_LEN, HEIGHT, STEP):
do_shift = not do_shift
start_x = STROKE_LEN
if do_shift:
start_x += STROKE_LEN
for x in range(start_x, WIDTH, STEP):
for angle in (0, 60, -60):
elements.append(svg.Path(
stroke="#2c3e50",
stroke_width=1,
stroke_linecap="round",
transform=[svg.Rotate(angle, x, y)],
d=[
svg.M(x - SHIFT, y),
svg.L(x + SHIFT, y),
],
))
return svg.SVG(
viewBox=svg.ViewBoxSpec(0, 0, WIDTH, HEIGHT),
elements=elements,
)
if __name__ == '__main__':
print(draw())