-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrenderer.py
More file actions
33 lines (28 loc) · 901 Bytes
/
renderer.py
File metadata and controls
33 lines (28 loc) · 901 Bytes
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
from turtle import (
speed,
pensize,
done,
)
def render_pattern(pattern, draw_instructions, line_thickness=2):
"""Renderizza `pattern` usando la mappa `draw_pattern` (symbol -> callable).
draw_pattern deve essere un dizionario che mappa singoli caratteri
a funzioni che eseguono le azioni di disegno (ad es. funzioni Turtle).
"""
speed(10)
pensize(line_thickness)
for chr in pattern:
action = draw_instructions.get(chr)
if action:
action()
done()
def render_parametric_pattern(pattern, draw_instructions, line_thickness=2):
"""Renderizza un pattern parametric usando una mappa symbol -> callable(value)."""
speed(10)
pensize(line_thickness)
#begin_fill()
for symbol, value in pattern:
action = draw_instructions.get(symbol)
if action:
action(value)
#end_fill()
done()