forked from CT83/handwriting-synthesis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.py
40 lines (30 loc) · 1.14 KB
/
demo.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
import time
from hand import Hand
from utils.string_utils import accomodate_list_to_character_limit
def generate_handwriting(text, style=8, bias=0.8, strokes_width=0.9,
line_height=40, view_width=2000, character_limit=75,
lines_per_page=10):
print("Started generating.")
start_time = time.time() # start time of the loop
hand = Hand()
# usage demo
lines = text.split(sep='\n')
lines = [x for x in lines if len(x) > 0]
lines = accomodate_list_to_character_limit(lines, character_limit=character_limit)
biases = [bias for i in lines]
styles = [style for i in lines]
stroke_colors = ['black' for i in lines]
stroke_widths = [strokes_width for i in lines]
hand.write(
filename='img/generiran_rukopis',
lines=lines,
biases=biases,
styles=styles,
stroke_colors=stroke_colors,
stroke_widths=stroke_widths,
line_height=line_height,
view_width=view_width,
align_center=False,
lines_per_page=lines_per_page
)
print("Time Taken: ", (time.time() - start_time) / 60, " Minutes")