-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdraw_glyph.py
More file actions
executable file
·84 lines (68 loc) · 2.82 KB
/
draw_glyph.py
File metadata and controls
executable file
·84 lines (68 loc) · 2.82 KB
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
81
82
83
import bpy
from .process_stroke_verts_linearly import process_stroke_verts_linearly
def draw_glyph(obj, glyph_strokes, thicknesses=None):
scene = bpy.context.scene
gpencil = obj.data
speed = scene.gw_speed / 10
thickness = scene.gw_thickness
if len(gpencil.layers) > 0:
layer = gpencil.layers[0]
layer.clear()
else:
layer = gpencil.layers.new('strokes', set_active=True)
frame = layer.frames.new(bpy.context.scene.frame_current)
bpy.context.scene.frame_current += 1
mat_index = None
remaining = 0
for i in range(len(glyph_strokes)):
stroke_verts = glyph_strokes[i]
framed_strokes, remaining = process_stroke_verts_linearly(stroke_verts, speed, remaining=remaining)
# Give extra frames between strokes
if i > 0:
last_vert = glyph_strokes[i - 1][-1]
new_vert = glyph_strokes[i][0]
count = len(process_stroke_verts_linearly([last_vert, new_vert], speed)) - 1
bpy.context.scene.frame_current += count
stopper = 0
if i == len(glyph_strokes) - 1:
stopper = 1
for x in range(len(framed_strokes) - stopper):
frame = layer.frames.new(bpy.context.scene.frame_current)
for y in range(i):
stroke = frame.strokes.new()
if thicknesses == None:
stroke.line_width = thickness
else:
stroke.line_width = thicknesses[i]
stroke.display_mode = '3DSPACE'
for vert in glyph_strokes[y]:
stroke.points.add(1)
stroke.points[-1].co.x = vert[0]
stroke.points[-1].co.y = vert[1]
stroke.points[-1].co.z = vert[2]
stroke = frame.strokes.new()
if thicknesses == None:
stroke.line_width = thickness
else:
stroke.line_width = thicknesses[i]
stroke.display_mode = '3DSPACE'
for vert in framed_strokes[x]:
stroke.points.add(1)
stroke.points[-1].co.x = vert[0]
stroke.points[-1].co.y = vert[1]
stroke.points[-1].co.z = vert[2]
bpy.context.scene.frame_current += 1
frame = layer.frames.new(bpy.context.scene.frame_current)
for i in range(len(glyph_strokes)):
stroke_verts = glyph_strokes[i]
stroke = frame.strokes.new()
if thicknesses == None:
stroke.line_width = thickness
else:
stroke.line_width = thicknesses[i]
stroke.display_mode = '3DSPACE'
for vert in stroke_verts:
stroke.points.add(1)
stroke.points[-1].co.x = vert[0]
stroke.points[-1].co.y = vert[1]
stroke.points[-1].co.z = vert[2]