properties_data_shaderfx.py 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. # ##### BEGIN GPL LICENSE BLOCK #####
  2. #
  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.
  7. #
  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.
  12. #
  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.
  16. #
  17. # ##### END GPL LICENSE BLOCK #####
  18. # <pep8 compliant>
  19. from bpy.types import Panel
  20. class ShaderFxButtonsPanel:
  21. bl_space_type = 'PROPERTIES'
  22. bl_region_type = 'WINDOW'
  23. bl_context = "shaderfx"
  24. bl_options = {'HIDE_HEADER'}
  25. class DATA_PT_shader_fx(ShaderFxButtonsPanel, Panel):
  26. bl_label = "Effects"
  27. # Unused: always show for now.
  28. # @classmethod
  29. # def poll(cls, context):
  30. # ob = context.object
  31. # return ob and ob.type == 'GPENCIL'
  32. def draw(self, context):
  33. layout = self.layout
  34. ob = context.object
  35. layout.operator_menu_enum("object.shaderfx_add", "type")
  36. for fx in ob.shader_effects:
  37. box = layout.template_shaderfx(fx)
  38. if box:
  39. # match enum type to our functions, avoids a lookup table.
  40. getattr(self, fx.type)(box, fx)
  41. # the mt.type enum is (ab)used for a lookup on function names
  42. # ...to avoid lengthy if statements
  43. # so each type must have a function here.
  44. def FX_BLUR(self, layout, fx):
  45. layout.prop(fx, "factor", text="Factor")
  46. layout.prop(fx, "samples", text="Samples")
  47. layout.separator()
  48. layout.prop(fx, "use_dof_mode")
  49. if fx.use_dof_mode:
  50. layout.prop(fx, "coc")
  51. def FX_COLORIZE(self, layout, fx):
  52. layout.prop(fx, "mode", text="Mode")
  53. if fx.mode == 'BITONE':
  54. layout.prop(fx, "low_color", text="Low Color")
  55. if fx.mode == 'CUSTOM':
  56. layout.prop(fx, "low_color", text="Color")
  57. if fx.mode == 'BITONE':
  58. layout.prop(fx, "high_color", text="High Color")
  59. if fx.mode in {'BITONE', 'CUSTOM', 'TRANSPARENT'}:
  60. layout.prop(fx, "factor")
  61. def FX_WAVE(self, layout, fx):
  62. row = layout.row(align=True)
  63. row.prop(fx, "orientation", expand=True)
  64. layout.separator()
  65. layout.prop(fx, "amplitude")
  66. layout.prop(fx, "period")
  67. layout.prop(fx, "phase")
  68. def FX_PIXEL(self, layout, fx):
  69. layout.prop(fx, "size", text="Size")
  70. def FX_RIM(self, layout, fx):
  71. layout.prop(fx, "offset", text="Offset")
  72. layout.prop(fx, "rim_color")
  73. layout.prop(fx, "mask_color")
  74. layout.prop(fx, "mode")
  75. layout.prop(fx, "blur")
  76. layout.prop(fx, "samples")
  77. def FX_SHADOW(self, layout, fx):
  78. layout.prop(fx, "offset", text="Offset")
  79. layout.prop(fx, "shadow_color")
  80. layout.prop(fx, "scale")
  81. layout.prop(fx, "rotation")
  82. layout.separator()
  83. layout.prop(fx, "blur")
  84. layout.prop(fx, "samples")
  85. layout.separator()
  86. layout.prop(fx, "use_object", text="Use Object As Pivot")
  87. if fx.use_object:
  88. row = layout.row()
  89. row.prop(fx, "object", text="Object")
  90. layout.separator()
  91. layout.prop(fx, "use_wave", text="Use Wave Effect")
  92. if fx.use_wave is True:
  93. row = layout.row(align=True)
  94. row.prop(fx, "orientation", expand=True)
  95. layout.prop(fx, "amplitude")
  96. layout.prop(fx, "period")
  97. layout.prop(fx, "phase")
  98. def FX_GLOW(self, layout, fx):
  99. layout.prop(fx, "mode")
  100. layout.prop(fx, "glow_color")
  101. if fx.mode == 'LUMINANCE':
  102. layout.prop(fx, "threshold")
  103. else:
  104. layout.prop(fx, "select_color")
  105. layout.separator()
  106. layout.prop(fx, "radius")
  107. layout.prop(fx, "samples")
  108. layout.prop(fx, "use_alpha_mode", text="Use Alpha Mode")
  109. def FX_SWIRL(self, layout, fx):
  110. layout.prop(fx, "object", text="Object")
  111. layout.prop(fx, "radius")
  112. layout.prop(fx, "angle")
  113. layout.prop(fx, "use_transparent")
  114. def FX_FLIP(self, layout, fx):
  115. layout.prop(fx, "flip_horizontal")
  116. layout.prop(fx, "flip_vertical")
  117. def FX_LIGHT(self, layout, fx):
  118. layout.prop(fx, "object", text="Object")
  119. layout.prop(fx, "energy")
  120. layout.prop(fx, "ambient")
  121. classes = (
  122. DATA_PT_shader_fx,
  123. )
  124. if __name__ == "__main__": # only for live edit.
  125. from bpy.utils import register_class
  126. for cls in classes:
  127. register_class(cls)