-
Notifications
You must be signed in to change notification settings - Fork 35
/
main.py
80 lines (67 loc) · 1.98 KB
/
main.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import numpy as np
from handwriting_synthesis import Hand
all_star = """Somebody once told me the world is gonna roll me
I ain't the sharpest tool in the shed
She was looking kind of dumb with her finger and her thumb
In the shape of an "L" on her forehead"""
downtown = """Making my way downtown
Walking fast
Faces pass
And I'm home-bound"""
give_up = """Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you"""
lines = [
"Father time, I'm running late",
"I'm winding down, I'm growing tired",
"Seconds drift into the night",
"The clock just ticks till my time expires",
]
if __name__ == '__main__':
hand = Hand()
# usage demo
biases = [.75 for i in lines]
styles = [9 for i in lines]
stroke_colors = ['red', 'green', 'black', 'blue']
stroke_widths = [1, 2, 1, 2]
hand.write(
filename='img/usage_demo.svg',
lines=lines,
biases=biases,
styles=styles,
stroke_colors=stroke_colors,
stroke_widths=stroke_widths
)
# demo number 1 - fixed bias, fixed style
lines = all_star.split("\n")
biases = [.75 for i in lines]
styles = [12 for i in lines]
hand.write(
filename='img/all_star.svg',
lines=lines,
biases=biases,
styles=styles,
)
# demo number 2 - fixed bias, varying style
lines = downtown.split("\n")
biases = [.75 for i in lines]
styles = np.cumsum(np.array([len(i) for i in lines]) == 0).astype(int)
hand.write(
filename='img/downtown.svg',
lines=lines,
biases=biases,
styles=styles,
)
# demo number 3 - varying bias, fixed style
lines = give_up.split("\n")
biases = .2 * np.flip(np.cumsum([len(i) == 0 for i in lines]), 0)
styles = [7 for i in lines]
hand.write(
filename='img/give_up.svg',
lines=lines,
biases=biases,
styles=styles,
)