-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path__init__.py
More file actions
166 lines (141 loc) · 5.36 KB
/
__init__.py
File metadata and controls
166 lines (141 loc) · 5.36 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import bpy
from .operators import *
bl_info = {
"name": "Grease Writer",
"description": "Automatic hand-drawn text animation",
"author": "doakey3",
"version": (0, 0, 1),
"blender": (2, 80, 0),
"wiki_url": "https://github.com/doakey3/GreaseDraw",
"tracker_url": "https://github.com/doakey3/GreaseDraw/issues",
"category": "Animation",
"location": "Properties, Grease Pencil Data"
}
class GREASEPENCIL_PT_greasewriter(bpy.types.Panel):
bl_label = "Grease Writer"
bl_idname = "GREASEPENCIL_PT_greasewriter"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "data"
@classmethod
def poll(self, context):
if type(context.active_object.data).__name__ == "GreasePencil":
return True
else:
return False
def draw(self, context):
scene = context.scene
gpencil = context.active_object.data
layout = self.layout
layout.prop(gpencil, 'draw_speed')
layout.prop(gpencil, 'kerning')
layout.prop(gpencil, 'line_height')
layout.prop(gpencil, 'write_thickness')
layout.prop(gpencil, 'write_color')
#layout.prop(gpencil, 'interpolation_mode')
layout.prop(gpencil, 'font')
row = layout.row()
row.operator("grease_writer.write", icon="FILE_TEXT")
row.prop_search(gpencil, 'source_text', bpy.data, "texts", text="")
row = layout.row()
row.operator("grease_writer.decorate", icon="LIGHT_SUN")
row.prop(gpencil, "decorator_style", text="")
layout.operator("grease_writer.reanimate", icon="HAND")
row = layout.row()
row.operator("grease_writer.trace", icon="PIVOT_CURSOR")
row.prop_search(gpencil, 'tracer_obj', scene, "objects", text="")
def init_props():
bpy.types.GreasePencil.draw_speed = bpy.props.FloatProperty(
name="Draw Speed",
description="The distance a stroke lengthens with each frame of animation",
default=0.1,
min=0.01
)
bpy.types.GreasePencil.kerning = bpy.props.FloatProperty(
name="Kerning",
description="Affects the distance between characters. Default is 0.5 x the width of letter M",
default=0.5,
min=0
)
bpy.types.GreasePencil.line_height = bpy.props.FloatProperty(
name="Line Height",
description="Affects the height of a line. Default is 1.25 x the height of the letter M",
default=1.25,
min=0
)
bpy.types.GreasePencil.write_thickness = bpy.props.IntProperty(
name="Thickness",
description="Affects the default line thickness.",
default=100,
min=1
)
bpy.types.GreasePencil.write_color = bpy.props.FloatVectorProperty(
subtype='COLOR_GAMMA',
name="Color",
description="Color to use when writing",
size=3,
default=(0, 0, 0),
min=0.0,
max=1.0
)
"""
It might be cool to someday have different interpolation modes.
For now, linear is ok
interpolation_modes = [
("linear", "Linear", "Draw all strokes at the given draw speed"),
("derivative", "Derivative", "Draw strokes at a rate that varies based on the stroke's rate of change in direction; the more curvaceous, the slower the draw"),
("random", "Random", "Draw with a random speed that is +/- the given draw speed"),
]
bpy.types.GreasePencil.interpolation_mode = bpy.props.EnumProperty(
name="Interpolation",
items=interpolation_modes,
description="Select a mode for calculating how fast strokes should be drawn",
default="linear",
)
"""
fonts = [
("consolas", "Consolas", "A monospace font based on Consolas")
]
bpy.types.GreasePencil.font = bpy.props.EnumProperty(
name="Font",
items=fonts,
description="The font to be used for writing",
default="consolas",
)
bpy.types.GreasePencil.source_text = bpy.props.StringProperty(
name="source_text",
description="The text to be written with grease pencil"
)
decorators = [
("underline", "Underline", "Draw an underline beneath the grease pencil layer"),
("over-underline", "Over-underline", "Draw an overline and underline"),
("box", "Box", "Draw a box around the grease pencil layer"),
("ellipse", "Ellipse", "Draw an ellipse around the grease pencil layer"),
("circle", "Circle", "Draw a circle around the grease pencil layer"),
("strike-through", "Strike-through", "Horizontally strike out the grease pencil layer"),
("x-out", "X-out", "X out the grease pencil layer"),
("helioid", "Helioid", "Make a sun-like decorator (spiked ellipse)")
]
bpy.types.GreasePencil.decorator_style = bpy.props.EnumProperty(
name="Decorators",
items=decorators,
description="The decorator to draw",
default="underline",
)
bpy.types.GreasePencil.tracer_obj = bpy.props.StringProperty()
classes = [
GREASEPENCIL_PT_greasewriter,
GREASEPENCIL_OT_reanimate,
GREASEPENCIL_OT_write,
GREASEPENCIL_OT_trace,
GREASEPENCIL_OT_decorate
]
def register():
init_props()
from bpy.utils import register_class
for cls in classes:
register_class(cls)
def unregister():
from bpy.utils import unregister_class
for cls in reversed(classes):
unregister_class(cls)