1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
21 from bpy.types import Panel
24 class ShaderFxButtonsPanel:
25 bl_space_type = 'PROPERTIES'
26 bl_region_type = 'WINDOW'
27 bl_context = "shaderfx"
28 bl_options = {'HIDE_HEADER'}
31 class DATA_PT_shader_fx(ShaderFxButtonsPanel, Panel):
35 def poll(cls, context):
38 return ob and ob.type == 'GPENCIL'
40 def draw(self, context):
45 layout.operator_menu_enum("object.shaderfx_add", "type")
47 for fx in ob.shader_effects:
48 box = layout.template_shaderfx(fx)
50 # match enum type to our functions, avoids a lookup table.
51 getattr(self, fx.type)(box, fx)
53 # the mt.type enum is (ab)used for a lookup on function names
54 # ...to avoid lengthy if statements
55 # so each type must have a function here.
57 def FX_BLUR(self, layout, fx):
59 layout.prop(fx, "factor", text="Factor")
60 layout.prop(fx, "samples", text="Samples")
63 layout.prop(fx, "use_dof_mode")
65 layout.prop(fx, "coc")
67 def FX_COLORIZE(self, layout, fx):
68 layout.prop(fx, "mode", text="Mode")
70 if fx.mode == 'BITONE':
71 layout.prop(fx, "low_color", text="Low Color")
72 if fx.mode == 'CUSTOM':
73 layout.prop(fx, "low_color", text="Color")
75 if fx.mode == 'BITONE':
76 layout.prop(fx, "high_color", text="High Color")
78 if fx.mode in {'BITONE', 'CUSTOM', 'TRANSPARENT'}:
79 layout.prop(fx, "factor")
81 def FX_WAVE(self, layout, fx):
82 row = layout.row(align=True)
83 row.prop(fx, "orientation", expand=True)
86 layout.prop(fx, "amplitude")
87 layout.prop(fx, "period")
88 layout.prop(fx, "phase")
90 def FX_PIXEL(self, layout, fx):
91 layout.prop(fx, "size", text="Size")
93 def FX_RIM(self, layout, fx):
94 layout.prop(fx, "offset", text="Offset")
96 layout.prop(fx, "rim_color")
97 layout.prop(fx, "mask_color")
98 layout.prop(fx, "mode")
99 layout.prop(fx, "blur")
100 layout.prop(fx, "samples")
102 def FX_SHADOW(self, layout, fx):
103 layout.prop(fx, "offset", text="Offset")
105 layout.prop(fx, "shadow_color")
106 layout.prop(fx, "scale")
107 layout.prop(fx, "rotation")
110 layout.prop(fx, "blur")
111 layout.prop(fx, "samples")
114 layout.prop(fx, "use_object", text="Use object as pivot")
117 row.prop(fx, "object", text="Object")
120 layout.prop(fx, "use_wave", text="Use Wave effect")
121 if fx.use_wave is True:
122 row = layout.row(align=True)
123 row.prop(fx, "orientation", expand=True)
124 layout.prop(fx, "amplitude")
125 layout.prop(fx, "period")
126 layout.prop(fx, "phase")
128 def FX_GLOW(self, layout, fx):
129 layout.prop(fx, "mode")
130 layout.prop(fx, "glow_color")
131 if fx.mode == 'LUMINANCE':
132 layout.prop(fx, "threshold")
134 layout.prop(fx, "select_color")
137 layout.prop(fx, "radius")
138 layout.prop(fx, "samples")
139 layout.prop(fx, "use_alpha_mode", text="Use alpha mode")
141 def FX_SWIRL(self, layout, fx):
142 layout.prop(fx, "object", text="Object")
144 layout.prop(fx, "radius")
145 layout.prop(fx, "angle")
147 layout.prop(fx, "transparent")
149 def FX_FLIP(self, layout, fx):
150 layout.prop(fx, "flip_horizontal")
151 layout.prop(fx, "flip_vertical")
153 def FX_LIGHT(self, layout, fx):
154 layout.prop(fx, "object", text="Object")
156 layout.prop(fx, "energy")
157 layout.prop(fx, "ambient")
164 if __name__ == "__main__": # only for live edit.
165 from bpy.utils import register_class