Skip to content

Commit 0779047

Browse files
committed
initial commit
0 parents  commit 0779047

File tree

114 files changed

+1154
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+1154
-0
lines changed

.gitignore

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
linker.py
7+
8+
# C extensions
9+
*.so
10+
11+
# Distribution / packaging
12+
.Python
13+
env/
14+
build/
15+
develop-eggs/
16+
dist/
17+
downloads/
18+
eggs/
19+
.eggs/
20+
lib/
21+
lib64/
22+
parts/
23+
sdist/
24+
var/
25+
wheels/
26+
*.egg-info/
27+
.installed.cfg
28+
*.egg
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
.hypothesis/
50+
51+
# Translations
52+
*.mo
53+
*.pot
54+
55+
# Django stuff:
56+
*.log
57+
local_settings.py
58+
59+
# Flask stuff:
60+
instance/
61+
.webassets-cache
62+
63+
# Scrapy stuff:
64+
.scrapy
65+
66+
# Sphinx documentation
67+
docs/_build/
68+
69+
# PyBuilder
70+
target/
71+
72+
# Jupyter Notebook
73+
.ipynb_checkpoints
74+
75+
# pyenv
76+
.python-version
77+
78+
# celery beat schedule file
79+
celerybeat-schedule
80+
81+
# SageMath parsed files
82+
*.sage.py
83+
84+
# dotenv
85+
.env
86+
87+
# virtualenv
88+
.venv
89+
venv/
90+
ENV/
91+
92+
# Spyder project settings
93+
.spyderproject
94+
.spyproject
95+
96+
# Rope project settings
97+
.ropeproject
98+
99+
# mkdocs documentation
100+
/site
101+
102+
# mypy
103+
.mypy_cache/

README.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
.. image:: https://i.imgur.com/VKEhIx3.gif
2+
3+
Installation
4+
============
5+
**This only works on Blender 2.8**
6+
7+
1. Download the latest .zip file from the releases_ page
8+
2. Open Blender and go to Edit > Preferences > Install Add-on from File... Then navigate to the .zip file you downloaded and select it
9+
3. Check the box that appears next to "Grease Writer"
10+
11+
.. _releases: https://www.github.com/doakey3/GreaseWriter/releases
12+
13+
Usage
14+
=====
15+
Writing
16+
-------
17+
1. Create a new Grease Pencil object in the 3D view (Shift + A > Grease Pencil > Blank)
18+
2. With the Grease Pencil object selected, go to the data section of the Properties window where you will find the Grease Writer panel.
19+
3. Create a text file with the desired text
20+
21+
- Right-click at the edge of a window and split the area
22+
- Change the Window's view to the Text Editor
23+
- click the "New" button to start editing a text file
24+
25+
.. image:: https://i.imgur.com/YqZd5Ji.gif
26+
27+
4. Enter the name of the Text file in the source text property in the Grease Writer panel
28+
5. Adjust settings and click the "Write" button
29+
6. Optionally add a decorator to the added text
30+
31+
.. image:: https://i.imgur.com/LpXjgNk.gif
32+
33+
Animating
34+
---------
35+
If you draw on a grease pencil object, you can automatically animate it by clicking the "Reanimate" button. Strokes will be drawn in the order they were created.
36+
37+
Tracing
38+
-------
39+
Select a tracer object and click trace. The tracer object's X and Y position will change to keep up with the animated grease pencil as it is being drawn.
40+
41+
.. image:: https://i.imgur.com/2XGSq6H.gif

__init__.py

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
import bpy
2+
3+
from .operators import *
4+
5+
bl_info = {
6+
"name": "Grease Writer",
7+
"description": "Automatic hand-drawn text animation",
8+
"author": "doakey3",
9+
"version": (0, 0, 1),
10+
"blender": (2, 80, 0),
11+
"wiki_url": "https://github.com/doakey3/GreaseDraw",
12+
"tracker_url": "https://github.com/doakey3/GreaseDraw/issues",
13+
"category": "Animation",
14+
"location": "Properties, Grease Pencil Data"
15+
}
16+
17+
class GREASEPENCIL_PT_greasewriter(bpy.types.Panel):
18+
bl_label = "Grease Writer"
19+
bl_idname = "GREASEPENCIL_PT_greasewriter"
20+
bl_space_type = "PROPERTIES"
21+
bl_region_type = "WINDOW"
22+
bl_context = "data"
23+
24+
@classmethod
25+
def poll(self, context):
26+
if type(context.active_object.data).__name__ == "GreasePencil":
27+
return True
28+
else:
29+
return False
30+
31+
def draw(self, context):
32+
scene = context.scene
33+
gpencil = context.active_object.data
34+
layout = self.layout
35+
layout.prop(gpencil, 'draw_speed')
36+
layout.prop(gpencil, 'kerning')
37+
layout.prop(gpencil, 'line_height')
38+
layout.prop(gpencil, 'write_thickness')
39+
layout.prop(gpencil, 'write_color')
40+
#layout.prop(gpencil, 'interpolation_mode')
41+
layout.prop(gpencil, 'font')
42+
row = layout.row()
43+
row.operator("grease_writer.write", icon="FILE_TEXT")
44+
row.prop_search(gpencil, 'source_text', bpy.data, "texts", text="")
45+
row = layout.row()
46+
row.operator("grease_writer.decorate", icon="LIGHT_SUN")
47+
row.prop(gpencil, "decorator_style", text="")
48+
layout.operator("grease_writer.reanimate", icon="HAND")
49+
row = layout.row()
50+
row.operator("grease_writer.trace", icon="PIVOT_CURSOR")
51+
row.prop_search(gpencil, 'tracer_obj', scene, "objects", text="")
52+
53+
54+
def init_props():
55+
bpy.types.GreasePencil.draw_speed = bpy.props.FloatProperty(
56+
name="Draw Speed",
57+
description="The distance a stroke lengthens with each frame of animation",
58+
default=0.1,
59+
min=0.01
60+
)
61+
62+
bpy.types.GreasePencil.kerning = bpy.props.FloatProperty(
63+
name="Kerning",
64+
description="Affects the distance between characters. Default is 0.5 x the width of letter M",
65+
default=0.5,
66+
min=0
67+
)
68+
69+
bpy.types.GreasePencil.line_height = bpy.props.FloatProperty(
70+
name="Line Height",
71+
description="Affects the height of a line. Default is 1.25 x the height of the letter M",
72+
default=1.25,
73+
min=0
74+
)
75+
76+
bpy.types.GreasePencil.write_thickness = bpy.props.IntProperty(
77+
name="Thickness",
78+
description="Affects the default line thickness.",
79+
default=100,
80+
min=1
81+
)
82+
83+
bpy.types.GreasePencil.write_color = bpy.props.FloatVectorProperty(
84+
subtype='COLOR_GAMMA',
85+
name="Color",
86+
description="Color to use when writing",
87+
size=3,
88+
default=(0, 0, 0),
89+
min=0.0,
90+
max=1.0
91+
)
92+
93+
"""
94+
It might be cool to someday have different interpolation modes.
95+
For now, linear is ok
96+
97+
interpolation_modes = [
98+
("linear", "Linear", "Draw all strokes at the given draw speed"),
99+
("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"),
100+
("random", "Random", "Draw with a random speed that is +/- the given draw speed"),
101+
]
102+
103+
bpy.types.GreasePencil.interpolation_mode = bpy.props.EnumProperty(
104+
name="Interpolation",
105+
items=interpolation_modes,
106+
description="Select a mode for calculating how fast strokes should be drawn",
107+
default="linear",
108+
)
109+
"""
110+
111+
fonts = [
112+
("consolas", "Consolas", "A monospace font based on Consolas")
113+
]
114+
115+
bpy.types.GreasePencil.font = bpy.props.EnumProperty(
116+
name="Font",
117+
items=fonts,
118+
description="The font to be used for writing",
119+
default="consolas",
120+
)
121+
122+
bpy.types.GreasePencil.source_text = bpy.props.StringProperty(
123+
name="source_text",
124+
description="The text to be written with grease pencil"
125+
)
126+
127+
decorators = [
128+
("underline", "Underline", "Draw an underline beneath the grease pencil layer"),
129+
("over-underline", "Over-underline", "Draw an overline and underline"),
130+
("box", "Box", "Draw a box around the grease pencil layer"),
131+
("ellipse", "Ellipse", "Draw an ellipse around the grease pencil layer"),
132+
("circle", "Circle", "Draw a circle around the grease pencil layer"),
133+
("strike-through", "Strike-through", "Horizontally strike out the grease pencil layer"),
134+
("x-out", "X-out", "X out the grease pencil layer"),
135+
("helioid", "Helioid", "Make a sun-like decorator (spiked ellipse)")
136+
]
137+
138+
bpy.types.GreasePencil.decorator_style = bpy.props.EnumProperty(
139+
name="Decorators",
140+
items=decorators,
141+
description="The decorator to draw",
142+
default="underline",
143+
)
144+
145+
bpy.types.GreasePencil.tracer_obj = bpy.props.StringProperty()
146+
147+
148+
classes = [
149+
GREASEPENCIL_PT_greasewriter,
150+
GREASEPENCIL_OT_reanimate,
151+
GREASEPENCIL_OT_write,
152+
GREASEPENCIL_OT_trace,
153+
GREASEPENCIL_OT_decorate
154+
]
155+
156+
def register():
157+
init_props()
158+
159+
from bpy.utils import register_class
160+
for cls in classes:
161+
register_class(cls)
162+
163+
def unregister():
164+
from bpy.utils import unregister_class
165+
for cls in reversed(classes):
166+
unregister_class(cls)

extra/make_grease.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import bpy
2+
from mathutils import Vector
3+
4+
gpencil = bpy.data.grease_pencil.new('gpencil')
5+
6+
layer = gpencil.layers.new("alayer", set_active=True)
7+
frame = layer.frames.new(bpy.context.scene.frame_current)
8+
stroke = frame.strokes.new()
9+
stroke.line_width = 300
10+
stroke.display_mode = '3DSPACE'
11+
stroke.material_index = 0
12+
13+
14+
points = [
15+
[2, 0],
16+
[8, 5]
17+
]
18+
19+
for point in points:
20+
stroke.points.add(gpencil, 1)
21+
stroke.points[-1].co.x = point[0]
22+
stroke.points[-1].co.y = point[1]
23+
24+
obj = bpy.data.objects.new('agobject', gpencil)
25+
bpy.context.scene.collection.objects.link(obj)
26+
mat = bpy.data.materials.new('mymaterial')
27+
bpy.data.materials.create_gpencil_data(mat)
28+
obj.data.materials.append(mat)

operators/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from .reanimate import GREASEPENCIL_OT_reanimate
2+
from .write import GREASEPENCIL_OT_write
3+
from .trace import GREASEPENCIL_OT_trace
4+
from .decorate import GREASEPENCIL_OT_decorate

0 commit comments

Comments
 (0)