only apply modifiers if the mesh has modifiers
[blender-addons.git] / paint_palette.py
blob92de64b0c888eac38371221f40930833598f2a7e
1 # paint_palette.py (c) 2011 Dany Lebel (Axon_D)
3 # ***** BEGIN GPL LICENSE BLOCK *****
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software Foundation,
18 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # ***** END GPL LICENCE BLOCK *****
23 bl_info = {
24 "name": "Paint Palettes",
25 "author": "Dany Lebel (Axon D)",
26 "version": (0, 9, 1),
27 "blender": (2, 63, 0),
28 "location": "Image Editor and 3D View > Any Paint mode > Color Palette or Weight Palette panel",
29 "description": "Palettes for color and weight paint modes",
30 "warning": "",
31 "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Paint/Palettes",
32 "tracker_url": "http://projects.blender.org/tracker/index.php?func=detail&aid=25908",
33 "category": "Paint"}
35 """
36 This addon brings palettes to the paint modes.
38 * Color Palette for Image Painting, Texture Paint and Vertex Paint modes.
39 * Weight Palette for the Weight Paint mode.
41 Set a number of colors (or weights according to the mode) and then associate it
42 with the brush by using the button under the color.
43 """
45 import bpy
46 from bpy.props import *
49 def update_panels():
50 pp = bpy.context.scene.palette_props
51 current_color = pp.colors[pp.current_color_index].color
52 pp.color_name = pp.colors[pp.current_color_index].name
53 brush = current_brush()
54 brush.color = current_color
55 pp.index = pp.current_color_index
57 def sample():
58 pp = bpy.context.scene.palette_props
59 current_color = pp.colors[pp.current_color_index]
60 brush = current_brush()
61 current_color.color = brush.color
62 return None
64 def current_brush():
65 context = bpy.context
66 if context.area.type == 'VIEW_3D' and context.vertex_paint_object:
67 brush = context.tool_settings.vertex_paint.brush
68 elif context.area.type == 'VIEW_3D' and context.image_paint_object:
69 brush = context.tool_settings.image_paint.brush
70 elif context.area.type == 'IMAGE_EDITOR' and context.space_data.mode == 'PAINT':
71 brush = context.tool_settings.image_paint.brush
72 else :
73 brush = None
74 return brush
77 def update_weight_value():
78 pp = bpy.context.scene.palette_props
79 tt = bpy.context.tool_settings
80 tt.unified_paint_settings.weight = pp.weight_value
81 return None
84 class PALETTE_MT_menu(bpy.types.Menu):
85 bl_label = "Presets"
86 preset_subdir = ""
87 preset_operator = "palette.load_gimp_palette"
89 def path_menu(self, searchpaths, operator, props_default={}):
90 layout = self.layout
91 # hard coded to set the operators 'filepath' to the filename.
92 import os
93 import bpy.utils
95 layout = self.layout
96 if not searchpaths[0]:
97 layout.label("* Missing Paths *")
99 # collect paths
100 else :
101 files = []
102 for directory in searchpaths:
103 files.extend([(f, os.path.join(directory, f)) for f in os.listdir(directory)])
105 files.sort()
107 for f, filepath in files:
109 if f.startswith("."):
110 continue
112 preset_name = bpy.path.display_name(f)
113 props = layout.operator(operator, text=preset_name)
115 for attr, value in props_default.items():
116 setattr(props, attr, value)
118 props.filepath = filepath
119 if operator == "palette.load_gimp_palette":
120 props.menu_idname = self.bl_idname
122 def draw_preset(self, context):
123 """Define these on the subclass
124 - preset_operator
125 - preset_subdir
127 import bpy
128 self.path_menu([bpy.context.scene.palette_props.presets_folder], self.preset_operator)
130 draw = draw_preset
133 class LoadGimpPalette(bpy.types.Operator):
134 """Execute a preset"""
135 bl_idname = "palette.load_gimp_palette"
136 bl_label = "Load a Gimp palette"
138 filepath = bpy.props.StringProperty(name="Path",
139 description="Path of the Python file to execute",
140 maxlen=512, default="")
141 menu_idname = bpy.props.StringProperty(name="Menu ID Name",
142 description="ID name of the menu this was called from", default="")
144 def execute(self, context):
145 from os.path import basename
146 filepath = self.filepath
148 palette_props = bpy.context.scene.palette_props
149 palette_props.current_color_index = 0
151 # change the menu title to the most recently chosen option
152 preset_class = getattr(bpy.types, self.menu_idname)
153 preset_class.bl_label = bpy.path.display_name(basename(filepath))
156 ts = bpy.context.tool_settings
157 palette_props.columns = 0
158 if filepath[-4:] == ".gpl":
159 gpl = open(filepath, "r")
160 lines = gpl.readlines()
161 palette_props.notes = ''
162 has_color = False
163 for index_0, line in enumerate(lines):
164 if not line or (line[:12] == "GIMP Palette"):
165 pass
166 elif line[:5] == "Name:":
167 palette_props.palette_name = line[5:]
168 elif line[:8] == "Columns:":
169 palette_props.columns = int(line[8:])
170 elif line[0] == "#":
171 palette_props.notes += line
172 else :
173 has_color = True
174 #index_0 = i
175 break
176 i = -1
177 if has_color:
178 for i, ln in enumerate(lines[index_0:]):
179 try:
180 palette_props.colors[i]
181 except IndexError:
182 palette_props.colors.add()
183 color = [float(rgb)/255 for rgb in [ln[0:3], ln[4:7], ln[8:11]]]
185 palette_props.colors[i].color = color
187 palette_props.colors[i].name = ln[12:-1]
189 exceeding = i + 1
190 while palette_props.colors.__len__() > exceeding:
191 palette_props.colors.remove(exceeding)
193 if has_color:
194 update_panels()
195 gpl.close()
196 pass
197 else :
198 self.report({'INFO'}, "Not a supported palette format")
200 return {'FINISHED'}
203 class WriteGimpPalette():
204 """Base preset class, only for subclassing
205 subclasses must define
206 - preset_values
207 - preset_subdir """
208 bl_options = {'REGISTER'} # only because invoke_props_popup requires.
212 name = bpy.props.StringProperty(name="Name",
213 description="Name of the preset, used to make the path name",
214 maxlen=64, default="")
215 remove_active = bpy.props.BoolProperty(default=False, options={'HIDDEN'})
217 @staticmethod
218 def as_filename(name): # could reuse for other presets
219 for char in " !@#$%^&*(){}:\";'[]<>,.\\/?":
220 name = name.replace(char, '_')
221 return name.lower().strip()
223 def execute(self, context):
224 import os
225 pp = bpy.context.scene.palette_props
227 if hasattr(self, "pre_cb"):
228 self.pre_cb(context)
230 preset_menu_class = getattr(bpy.types, self.preset_menu)
232 if not self.remove_active:
234 if not self.name:
235 return {'FINISHED'}
237 filename = self.as_filename(self.name)
238 target_path = pp.presets_folder
240 if not target_path:
241 self.report({'WARNING'}, "Failed to create presets path")
242 return {'CANCELLED'}
244 filepath = os.path.join(target_path, filename) + ".gpl"
245 file_preset = open(filepath, 'wb')
246 gpl = "GIMP Palette\n"
247 gpl += "Name: %s\n" % filename
248 gpl += "Columns: %d\n" % pp.columns
249 gpl += pp.notes
250 if pp.colors.items():
251 for i, color in enumerate(pp.colors):
252 gpl += "%3d%4d%4d %s" % (color.color.r * 255, color.color.g * 255, color.color.b * 255, color.name + '\n')
253 file_preset.write(bytes(gpl, 'UTF-8'))
255 file_preset.close()
257 pp.palette_name = filename
259 else:
260 preset_active = preset_menu_class.bl_label
262 # fairly sloppy but convenient.
263 filepath = bpy.utils.preset_find(preset_active, self.preset_subdir)
265 if not filepath:
266 filepath = bpy.utils.preset_find(preset_active,
267 self.preset_subdir, display_name=True)
269 if not filepath:
270 return {'CANCELLED'}
272 if hasattr(self, "remove"):
273 self.remove(context, filepath)
274 else:
275 try:
276 os.remove(filepath)
277 except:
278 import traceback
279 traceback.print_exc()
281 # XXX, stupid!
282 preset_menu_class.bl_label = "Presets"
284 if hasattr(self, "post_cb"):
285 self.post_cb(context)
287 return {'FINISHED'}
289 def check(self, context):
290 self.name = self.as_filename(self.name)
292 def invoke(self, context, event):
293 if not self.remove_active:
294 wm = context.window_manager
295 return wm.invoke_props_dialog(self)
296 else:
297 return self.execute(context)
300 class AddPresetPalette(WriteGimpPalette, bpy.types.Operator):
301 """Add a Palette Preset"""
302 bl_idname = "palette.preset_add"
303 bl_label = "Add Palette Preset"
304 preset_menu = "PALETTE_MT_menu"
306 preset_defines = []
307 preset_values = []
308 preset_subdir = "palette"
311 class PALETTE_OT_add_color(bpy.types.Operator):
312 bl_label = ""
313 bl_description = "Add a Color to the Palette"
314 bl_idname = "palette_props.add_color"
317 def execute(self, context):
318 pp = bpy.context.scene.palette_props
319 new_index = 0
320 if pp.colors.items():
321 new_index = pp.current_color_index + 1
322 pp.colors.add()
324 last = pp.colors.__len__() - 1
327 pp.colors.move(last, new_index)
328 pp.current_color_index = new_index
329 sample()
330 update_panels()
331 return {'FINISHED'}
334 class PALETTE_OT_remove_color(bpy.types.Operator):
335 bl_label = ""
336 bl_description = "Remove Selected Color"
337 bl_idname = "palette_props.remove_color"
339 @classmethod
340 def poll(cls, context):
341 pp = bpy.context.scene.palette_props
342 return bool(pp.colors.items())
345 def execute(self, context):
346 pp = bpy.context.scene.palette_props
347 i = pp.current_color_index
348 pp.colors.remove(i)
350 if pp.current_color_index >= pp.colors.__len__():
351 pp.index = pp.current_color_index = pp.colors.__len__() - 1
352 return {'FINISHED'}
355 class PALETTE_OT_sample_tool_color(bpy.types.Operator):
356 bl_label = ""
357 bl_description = "Sample Tool Color"
358 bl_idname = "palette_props.sample_tool_color"
360 def execute(self, context):
361 pp = bpy.context.scene.palette_props
362 brush = current_brush()
363 pp.colors[pp.current_color_index].color = brush.color
364 return {'FINISHED'}
367 class IMAGE_OT_select_color(bpy.types.Operator):
368 bl_label = ""
369 bl_description = "Select this color"
370 bl_idname = "paint.select_color"
373 color_index = IntProperty()
375 def invoke(self, context, event):
376 palette_props = bpy.context.scene.palette_props
377 palette_props.current_color_index = self.color_index
379 update_panels()
380 return {'FINISHED'}
383 def color_palette_draw(self, context):
384 palette_props = bpy.context.scene.palette_props
387 layout = self.layout
390 bpy.types.PALETTE_MT_menu.preset_subdir = palette_props.presets_folder
391 row = layout.row(align=True)
392 row.menu("PALETTE_MT_menu", text=palette_props.palette_name.rstrip())
393 row.operator("palette.preset_add", text="", icon="ZOOMIN")
394 row.operator("palette.preset_add", text="", icon="ZOOMOUT").remove_active = True
395 col = layout.column(align=True)
396 row = col.row(align=True)
397 row.operator("palette_props.add_color", icon="ZOOMIN")
398 row.prop(palette_props, "index")
399 row.operator("palette_props.remove_color", icon="PANEL_CLOSE")
400 row = col.row(align=True)
401 row.prop(palette_props, "columns")
402 if palette_props.colors.items():
403 layout = col.box()
404 row = layout.row(align=True)
405 row.prop(palette_props, "color_name")
406 row.operator("palette_props.sample_tool_color", icon="COLOR")
408 laycol = layout.column(align=False)
410 if palette_props.columns:
411 columns = palette_props.columns
412 else :
413 columns = 16
414 for i, color in enumerate(palette_props.colors):
415 if not i % columns:
416 row1 = laycol.row(align=True)
417 row1.scale_y = 0.8
418 row2 = laycol.row(align=True)
419 row2.scale_y = 0.5
421 if i == palette_props.current_color_index:
423 row1.prop(palette_props.colors[i], "color", event=True, toggle=True)
424 row2.operator("paint.select_color", emboss=False).color_index = i
425 else :
426 row1.prop(palette_props.colors[i], "color", event=True, toggle=True)
427 row2.operator("paint.select_color").color_index = i
429 layout = self.layout
430 row = layout.row()
431 row.prop(palette_props, "presets_folder", text="")
433 pass
436 class BrushButtonsPanel():
437 bl_space_type = 'IMAGE_EDITOR'
438 bl_region_type = 'UI'
440 @classmethod
441 def poll(cls, context):
442 sima = context.space_data
443 toolsettings = context.tool_settings.image_paint
444 return sima.show_paint and toolsettings.brush
447 class PaintPanel():
448 bl_space_type = 'VIEW_3D'
449 bl_region_type = 'TOOLS'
451 @staticmethod
452 def paint_settings(context):
453 ts = context.tool_settings
455 if context.vertex_paint_object:
456 return ts.vertex_paint
457 elif context.weight_paint_object:
458 return ts.weight_paint
459 elif context.texture_paint_object:
460 return ts.image_paint
461 return None
464 class IMAGE_PT_color_palette(BrushButtonsPanel, bpy.types.Panel):
465 bl_label = "Color Palette"
466 bl_options = {'DEFAULT_CLOSED'}
468 def draw(self, context):
469 color_palette_draw(self, context)
472 class VIEW3D_PT_color_palette(PaintPanel, bpy.types.Panel):
473 bl_label = "Color Palette"
474 bl_options = {'DEFAULT_CLOSED'}
476 @classmethod
477 def poll(cls, context):
478 return (context.image_paint_object or context.vertex_paint_object)
480 def draw(self, context):
481 color_palette_draw(self, context)
484 class VIEW3D_OT_select_weight(bpy.types.Operator):
485 bl_label = ""
486 bl_description = "Select this weight"
487 bl_idname = "paint.select_weight"
489 weight_index = IntProperty()
491 def current_weight(self):
492 pp = bpy.context.scene.palette_props
493 if self.weight_index == 0:
494 weight = pp.weight_0
495 elif self.weight_index == 1:
496 weight = pp.weight_1
497 elif self.weight_index == 2:
498 weight = pp.weight_2
499 elif self.weight_index == 3:
500 weight = pp.weight_3
501 elif self.weight_index == 4:
502 weight = pp.weight_4
503 elif self.weight_index == 5:
504 weight = pp.weight_5
505 elif self.weight_index == 6:
506 weight = pp.weight_6
507 elif self.weight_index == 7:
508 weight = pp.weight_7
509 elif self.weight_index == 8:
510 weight = pp.weight_8
511 elif self.weight_index == 9:
512 weight = pp.weight_9
513 elif self.weight_index == 10:
514 weight = pp.weight_10
515 return weight
517 def invoke(self, context, event):
518 palette_props = bpy.context.scene.palette_props
520 palette_props.current_weight_index = self.weight_index
522 if self.weight_index == 0:
523 weight = palette_props.weight_0
524 elif self.weight_index == 1:
525 weight = palette_props.weight_1
526 elif self.weight_index == 2:
527 weight = palette_props.weight_2
528 elif self.weight_index == 3:
529 weight = palette_props.weight_3
530 elif self.weight_index == 4:
531 weight = palette_props.weight_4
532 elif self.weight_index == 5:
533 weight = palette_props.weight_5
534 elif self.weight_index == 6:
535 weight = palette_props.weight_6
536 elif self.weight_index == 7:
537 weight = palette_props.weight_7
538 elif self.weight_index == 8:
539 weight = palette_props.weight_8
540 elif self.weight_index == 9:
541 weight = palette_props.weight_9
542 elif self.weight_index == 10:
543 weight = palette_props.weight_10
544 palette_props.weight = weight
545 #bpy.context.tool_settings.vertex_group_weight = weight
546 return {'FINISHED'}
549 class VIEW3D_OT_reset_weight_palette(bpy.types.Operator):
550 bl_label = ""
551 bl_idname = "paint.reset_weight_palette"
554 def execute(self, context):
555 palette_props = context.scene.palette_props
557 if palette_props.current_weight_index == 0:
558 palette_props.weight = 0.0
559 palette_props.weight_0 = 0.0
561 palette_props.weight_1 = 0.1
562 if palette_props.current_weight_index == 1:
563 palette_props.weight = 0.1
565 if palette_props.current_weight_index == 2:
566 palette_props.weight = 0.25
567 palette_props.weight_2 = 0.25
569 if palette_props.current_weight_index == 3:
570 palette_props.weight = 0.3333
571 palette_props.weight_3 = 0.3333
573 if palette_props.current_weight_index == 4:
574 palette_props.weight = 0.4
575 palette_props.weight_4 = 0.4
577 if palette_props.current_weight_index == 5:
578 palette_props.weight = 0.5
579 palette_props.weight_5 = 0.5
581 if palette_props.current_weight_index == 6:
582 palette_props.weight = 0.6
583 palette_props.weight_6 = 0.6
585 if palette_props.current_weight_index == 7:
586 palette_props.weight = 0.6666
587 palette_props.weight_7 = 0.6666
589 if palette_props.current_weight_index == 8:
590 palette_props.weight = 0.75
591 palette_props.weight_8 = 0.75
593 if palette_props.current_weight_index == 9:
594 palette_props.weight = 0.9
595 palette_props.weight_9 = 0.9
597 if palette_props.current_weight_index == 10:
598 palette_props.weight = 1.0
599 palette_props.weight_10 = 1.0
600 return {'FINISHED'}
602 class VIEW3D_PT_weight_palette(PaintPanel, bpy.types.Panel):
603 bl_label = "Weight Palette"
604 bl_options = {'DEFAULT_CLOSED'}
606 @classmethod
607 def poll(cls, context):
608 return context.weight_paint_object
610 def draw(self, context):
611 palette_props = bpy.context.scene.palette_props
612 #vertex_group_weight = bpy.context.tool_settings.unified_paint_settings.weight
614 layout = self.layout
615 row = layout.row()
616 row.prop(palette_props, "weight", slider=True)
617 box = layout.box()
619 row = box.row()
620 if palette_props.current_weight_index == 0:
621 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_0,
622 emboss=False).weight_index = 0
623 else :
624 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_0,
625 emboss=True).weight_index = 0
627 row = box.row(align=True)
628 if palette_props.current_weight_index == 1:
629 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_1,
630 emboss=False).weight_index = 1
631 else :
632 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_1,
633 emboss=True).weight_index = 1
635 if palette_props.current_weight_index == 2:
636 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_2,
637 emboss=False).weight_index = 2
638 else :
639 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_2,
640 emboss=True).weight_index = 2
642 if palette_props.current_weight_index == 3:
643 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_3,
644 emboss=False).weight_index = 3
645 else :
646 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_3,
647 emboss=True).weight_index = 3
649 row = box.row(align=True)
650 if palette_props.current_weight_index == 4:
651 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_4,
652 emboss=False).weight_index = 4
653 else :
654 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_4,
655 emboss=True).weight_index = 4
657 if palette_props.current_weight_index == 5:
658 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_5,
659 emboss=False).weight_index = 5
660 else :
661 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_5,
662 emboss=True).weight_index = 5
664 if palette_props.current_weight_index == 6:
665 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_6,
666 emboss=False).weight_index = 6
667 else :
668 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_6,
669 emboss=True).weight_index = 6
671 row = box.row(align=True)
672 if palette_props.current_weight_index == 7:
673 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_7,
674 emboss=False).weight_index = 7
675 else :
676 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_7,
677 emboss=True).weight_index = 7
679 if palette_props.current_weight_index == 8:
680 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_8,
681 emboss=False).weight_index = 8
682 else :
683 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_8,
684 emboss=True).weight_index = 8
686 if palette_props.current_weight_index == 9:
687 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_9,
688 emboss=False).weight_index = 9
689 else :
690 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_9,
691 emboss=True).weight_index = 9
693 row = box.row(align=True)
694 if palette_props.current_weight_index == 10:
695 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_10,
696 emboss=False).weight_index = 10
697 else :
698 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_10,
699 emboss=True).weight_index = 10
701 row = layout.row()
702 row.operator("paint.reset_weight_palette", text="Reset")
705 class Colors(bpy.types.PropertyGroup):
706 """Class for colors CollectionProperty"""
707 color = bpy.props.FloatVectorProperty(
708 name="", description="", default=(0.8, 0.8, 0.8), min=0, max=1,
709 step=1, precision=3, subtype='COLOR_GAMMA', size=3)
712 class Weights(bpy.types.PropertyGroup):
713 """Class for Weights Collection Property"""
715 weight = bpy.props.FloatProperty(
716 default=0.0, min=0.0, max=1.0, precision=3)
719 class PaletteProps(bpy.types.PropertyGroup):
721 def update_color_name(self, context):
722 pp = bpy.context.scene.palette_props
723 pp.colors[pp.current_color_index].name = pp.color_name
724 return None
726 def move_color(self, context):
727 pp = bpy.context.scene.palette_props
728 if pp.colors.items() and pp.current_color_index != pp.index:
729 if pp.index >= pp.colors.__len__():
730 pp.index = pp.colors.__len__() - 1
731 pp.colors.move(pp.current_color_index, pp.index)
732 pp.current_color_index = pp.index
733 return None
735 def update_weight(self, context):
736 pp = context.scene.palette_props
737 weight = pp.weight
738 if pp.current_weight_index == 0:
739 pp.weight_0 = weight
740 elif pp.current_weight_index == 1:
741 pp.weight_1 = weight
742 elif pp.current_weight_index == 2:
743 pp.weight_2 = weight
744 elif pp.current_weight_index == 3:
745 pp.weight_3 = weight
746 elif pp.current_weight_index == 4:
747 pp.weight_4 = weight
748 elif pp.current_weight_index == 5:
749 pp.weight_5 = weight
750 elif pp.current_weight_index == 6:
751 pp.weight_6 = weight
752 elif pp.current_weight_index == 7:
753 pp.weight_7 = weight
754 elif pp.current_weight_index == 8:
755 pp.weight_8 = weight
756 elif pp.current_weight_index == 9:
757 pp.weight_9 = weight
758 elif pp.current_weight_index == 10:
759 pp.weight_10 = weight
760 bpy.context.tool_settings.unified_paint_settings.weight = weight
761 #bpy.context.tool_settings.vertex_group_weight = weight
762 return None
764 palette_name = StringProperty(
765 name="Palette Name", default="Preset", subtype='FILE_NAME')
767 color_name = StringProperty(
768 name="", description="Color Name", default="Untitled", update=update_color_name)
770 columns = IntProperty(
771 name="Columns",
772 description="Number of Columns",
773 min=0, max=16, default=0)
775 index = IntProperty(
776 name="Index",
777 description="Move Selected Color",
778 min=0,
779 update=move_color)
781 notes = StringProperty(
782 name="Palette Notes", default="#\n")
784 current_color_index = IntProperty(
785 name="Current Color Index", description="", default=0, min=0)
787 current_weight_index = IntProperty(
788 name="Current Color Index", description="", default=10, min=-1)
790 presets_folder = StringProperty(name="",
791 description="Palettes Folder",
792 subtype="DIR_PATH")
794 colors = bpy.props.CollectionProperty(type=Colors)
796 weight = bpy.props.FloatProperty(name="Weight",
797 default=0.0, min=0.0, max=1.0, precision=3, update=update_weight)
799 weight_0 = bpy.props.FloatProperty(
800 default=0.0, min=0.0, max=1.0, precision=3)
801 weight_1 = bpy.props.FloatProperty(
802 default=0.1, min=0.0, max=1.0, precision=3)
803 weight_2 = bpy.props.FloatProperty(
804 default=0.25, min=0.0, max=1.0, precision=3)
805 weight_3 = bpy.props.FloatProperty(
806 default=0.333, min=0.0, max=1.0, precision=3)
807 weight_4 = bpy.props.FloatProperty(
808 default=0.4, min=0.0, max=1.0, precision=3)
809 weight_5 = bpy.props.FloatProperty(
810 default=0.5, min=0.0, max=1.0, precision=3)
811 weight_6 = bpy.props.FloatProperty(
812 default=0.6, min=0.0, max=1.0, precision=3)
813 weight_7 = bpy.props.FloatProperty(
814 default=0.6666, min=0.0, max=1.0, precision=3)
815 weight_8 = bpy.props.FloatProperty(
816 default=0.75, min=0.0, max=1.0, precision=3)
817 weight_9 = bpy.props.FloatProperty(
818 default=0.9, min=0.0, max=1.0, precision=3)
819 weight_10 = bpy.props.FloatProperty(
820 default=1.0, min=0.0, max=1.0, precision=3)
821 pass
823 def register():
824 bpy.utils.register_module(__name__)
826 bpy.types.Scene.palette_props = PointerProperty(
827 type=PaletteProps, name="Palette Props", description="")
828 pass
831 def unregister():
832 bpy.utils.unregister_module(__name__)
834 del bpy.types.Scene.palette_props
835 pass
838 if __name__ == "__main__":
839 register()
842 # To Do List
843 # ToDo1 Overiting the current file
844 # ToDo3 Foreground Background