-
Notifications
You must be signed in to change notification settings - Fork 0
/
grid.py
37 lines (32 loc) · 835 Bytes
/
grid.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
from plot import Plot
import math
SQRT_2 = 1.41421356237
def rotate(x, y, angle):
x -= 50
y -= 50
point = (
x*math.cos(angle) - y*math.sin(angle),
x*math.sin(angle) + y*math.cos(angle),
)
return (
point[0]+50,
point[1]+50,
)
def main(p: Plot):
p.plot_size = 8
p.setup()
p.draw_bounding_box()
num_rows = 100
num_cols = 100
for r in range(num_rows+1):
y = 1 + r * (98/num_rows)
p.goto(*rotate(1, y, 0.4))
for c in range(num_cols+1):
x = 1 + c * (98/num_cols)
p.lineto(*rotate(x, y, 0.4))
for c in range(num_cols+1):
x = 1 + c * (98/num_cols)
p.goto(*rotate(x, 1, 0.4))
for r in range(num_rows+1):
y = 1 + r * (98/num_rows)
p.lineto(*rotate(x, y, 0.4))