blendfile: Python modules shouldn't set their own log level.
[blender-addons.git] / paint_palette.py
blobc343978bb7bfb3c51ed0464bee1ded9251114f35
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/"
32 "Scripts/Paint/Palettes",
33 "category": "Paint",
36 """
37 This addon brings palettes to the paint modes.
39 * Color Palette for Image Painting, Texture Paint and Vertex Paint modes.
40 * Weight Palette for the Weight Paint mode.
42 Set a number of colors (or weights according to the mode) and then associate it
43 with the brush by using the button under the color.
44 """
46 import bpy
47 from bpy.props import *
50 def update_panels():
51 pp = bpy.context.scene.palette_props
52 current_color = pp.colors[pp.current_color_index].color
53 pp.color_name = pp.colors[pp.current_color_index].name
54 brush = current_brush()
55 brush.color = current_color
56 pp.index = pp.current_color_index
58 def sample():
59 pp = bpy.context.scene.palette_props
60 current_color = pp.colors[pp.current_color_index]
61 brush = current_brush()
62 current_color.color = brush.color
63 return None
65 def current_brush():
66 context = bpy.context
67 if context.area.type == 'VIEW_3D' and context.vertex_paint_object:
68 brush = context.tool_settings.vertex_paint.brush
69 elif context.area.type == 'VIEW_3D' and context.image_paint_object:
70 brush = context.tool_settings.image_paint.brush
71 elif context.area.type == 'IMAGE_EDITOR' and context.space_data.mode == 'PAINT':
72 brush = context.tool_settings.image_paint.brush
73 else :
74 brush = None
75 return brush
78 def update_weight_value():
79 pp = bpy.context.scene.palette_props
80 tt = bpy.context.tool_settings
81 tt.unified_paint_settings.weight = pp.weight_value
82 return None
85 class PALETTE_MT_menu(bpy.types.Menu):
86 bl_label = "Presets"
87 preset_subdir = ""
88 preset_operator = "palette.load_gimp_palette"
90 def path_menu(self, searchpaths, operator, props_default={}):
91 layout = self.layout
92 # hard coded to set the operators 'filepath' to the filename.
93 import os
94 import bpy.utils
96 layout = self.layout
97 if not searchpaths[0]:
98 layout.label("* Missing Paths *")
100 # collect paths
101 else :
102 files = []
103 for directory in searchpaths:
104 files.extend([(f, os.path.join(directory, f)) for f in os.listdir(directory)])
106 files.sort()
108 for f, filepath in files:
110 if f.startswith("."):
111 continue
113 preset_name = bpy.path.display_name(f)
114 props = layout.operator(operator, text=preset_name)
116 for attr, value in props_default.items():
117 setattr(props, attr, value)
119 props.filepath = filepath
120 if operator == "palette.load_gimp_palette":
121 props.menu_idname = self.bl_idname
123 def draw_preset(self, context):
124 """Define these on the subclass
125 - preset_operator
126 - preset_subdir
128 import bpy
129 self.path_menu([bpy.context.scene.palette_props.presets_folder], self.preset_operator)
131 draw = draw_preset
134 class LoadGimpPalette(bpy.types.Operator):
135 """Execute a preset"""
136 bl_idname = "palette.load_gimp_palette"
137 bl_label = "Load a Gimp palette"
139 filepath = bpy.props.StringProperty(name="Path",
140 description="Path of the Python file to execute",
141 maxlen=512, default="")
142 menu_idname = bpy.props.StringProperty(name="Menu ID Name",
143 description="ID name of the menu this was called from", default="")
145 def execute(self, context):
146 from os.path import basename
147 filepath = self.filepath
149 palette_props = bpy.context.scene.palette_props
150 palette_props.current_color_index = 0
152 # change the menu title to the most recently chosen option
153 preset_class = getattr(bpy.types, self.menu_idname)
154 preset_class.bl_label = bpy.path.display_name(basename(filepath))
157 ts = bpy.context.tool_settings
158 palette_props.columns = 0
159 if filepath[-4:] == ".gpl":
160 gpl = open(filepath, "r")
161 lines = gpl.readlines()
162 palette_props.notes = ''
163 has_color = False
164 for index_0, line in enumerate(lines):
165 if not line or (line[:12] == "GIMP Palette"):
166 pass
167 elif line[:5] == "Name:":
168 palette_props.palette_name = line[5:]
169 elif line[:8] == "Columns:":
170 palette_props.columns = int(line[8:])
171 elif line[0] == "#":
172 palette_props.notes += line
173 else :
174 has_color = True
175 #index_0 = i
176 break
177 i = -1
178 if has_color:
179 for i, ln in enumerate(lines[index_0:]):
180 try:
181 palette_props.colors[i]
182 except IndexError:
183 palette_props.colors.add()
184 color = [float(rgb)/255 for rgb in [ln[0:3], ln[4:7], ln[8:11]]]
186 palette_props.colors[i].color = color
188 palette_props.colors[i].name = ln[12:-1]
190 exceeding = i + 1
191 while palette_props.colors.__len__() > exceeding:
192 palette_props.colors.remove(exceeding)
194 if has_color:
195 update_panels()
196 gpl.close()
197 pass
198 else :
199 self.report({'INFO'}, "Not a supported palette format")
201 return {'FINISHED'}
204 class WriteGimpPalette():
205 """Base preset class, only for subclassing
206 subclasses must define
207 - preset_values
208 - preset_subdir """
209 bl_options = {'REGISTER'} # only because invoke_props_popup requires.
213 name = bpy.props.StringProperty(name="Name",
214 description="Name of the preset, used to make the path name",
215 maxlen=64, default="")
216 remove_active = bpy.props.BoolProperty(default=False, options={'HIDDEN'})
218 @staticmethod
219 def as_filename(name): # could reuse for other presets
220 for char in " !@#$%^&*(){}:\";'[]<>,.\\/?":
221 name = name.replace(char, '_')
222 return name.lower().strip()
224 def execute(self, context):
225 import os
226 pp = bpy.context.scene.palette_props
228 if hasattr(self, "pre_cb"):
229 self.pre_cb(context)
231 preset_menu_class = getattr(bpy.types, self.preset_menu)
233 if not self.remove_active:
235 if not self.name:
236 return {'FINISHED'}
238 filename = self.as_filename(self.name)
239 target_path = pp.presets_folder
241 if not target_path:
242 self.report({'WARNING'}, "Failed to create presets path")
243 return {'CANCELLED'}
245 filepath = os.path.join(target_path, filename) + ".gpl"
246 file_preset = open(filepath, 'wb')
247 gpl = "GIMP Palette\n"
248 gpl += "Name: %s\n" % filename
249 gpl += "Columns: %d\n" % pp.columns
250 gpl += pp.notes
251 if pp.colors.items():
252 for i, color in enumerate(pp.colors):
253 gpl += "%3d%4d%4d %s" % (color.color.r * 255, color.color.g * 255, color.color.b * 255, color.name + '\n')
254 file_preset.write(bytes(gpl, 'UTF-8'))
256 file_preset.close()
258 pp.palette_name = filename
260 else:
261 preset_active = preset_menu_class.bl_label
263 # fairly sloppy but convenient.
264 filepath = bpy.utils.preset_find(preset_active, self.preset_subdir)
266 if not filepath:
267 filepath = bpy.utils.preset_find(preset_active,
268 self.preset_subdir, display_name=True)
270 if not filepath:
271 return {'CANCELLED'}
273 if hasattr(self, "remove"):
274 self.remove(context, filepath)
275 else:
276 try:
277 os.remove(filepath)
278 except:
279 import traceback
280 traceback.print_exc()
282 # XXX, stupid!
283 preset_menu_class.bl_label = "Presets"
285 if hasattr(self, "post_cb"):
286 self.post_cb(context)
288 return {'FINISHED'}
290 def check(self, context):
291 self.name = self.as_filename(self.name)
293 def invoke(self, context, event):
294 if not self.remove_active:
295 wm = context.window_manager
296 return wm.invoke_props_dialog(self)
297 else:
298 return self.execute(context)
301 class AddPresetPalette(WriteGimpPalette, bpy.types.Operator):
302 """Add a Palette Preset"""
303 bl_idname = "palette.preset_add"
304 bl_label = "Add Palette Preset"
305 preset_menu = "PALETTE_MT_menu"
307 preset_defines = []
308 preset_values = []
309 preset_subdir = "palette"
312 class PALETTE_OT_add_color(bpy.types.Operator):
313 bl_label = ""
314 bl_description = "Add a Color to the Palette"
315 bl_idname = "palette_props.add_color"
318 def execute(self, context):
319 pp = bpy.context.scene.palette_props
320 new_index = 0
321 if pp.colors.items():
322 new_index = pp.current_color_index + 1
323 pp.colors.add()
325 last = pp.colors.__len__() - 1
328 pp.colors.move(last, new_index)
329 pp.current_color_index = new_index
330 sample()
331 update_panels()
332 return {'FINISHED'}
335 class PALETTE_OT_remove_color(bpy.types.Operator):
336 bl_label = ""
337 bl_description = "Remove Selected Color"
338 bl_idname = "palette_props.remove_color"
340 @classmethod
341 def poll(cls, context):
342 pp = bpy.context.scene.palette_props
343 return bool(pp.colors.items())
346 def execute(self, context):
347 pp = bpy.context.scene.palette_props
348 i = pp.current_color_index
349 pp.colors.remove(i)
351 if pp.current_color_index >= pp.colors.__len__():
352 pp.index = pp.current_color_index = pp.colors.__len__() - 1
353 return {'FINISHED'}
356 class PALETTE_OT_sample_tool_color(bpy.types.Operator):
357 bl_label = ""
358 bl_description = "Sample Tool Color"
359 bl_idname = "palette_props.sample_tool_color"
361 def execute(self, context):
362 pp = bpy.context.scene.palette_props
363 brush = current_brush()
364 pp.colors[pp.current_color_index].color = brush.color
365 return {'FINISHED'}
368 class IMAGE_OT_select_color(bpy.types.Operator):
369 bl_label = ""
370 bl_description = "Select this color"
371 bl_idname = "paint.select_color"
372 bl_options = {'UNDO'}
375 color_index = IntProperty()
377 def invoke(self, context, event):
378 palette_props = bpy.context.scene.palette_props
379 palette_props.current_color_index = self.color_index
381 update_panels()
382 return {'FINISHED'}
385 def color_palette_draw(self, context):
386 palette_props = bpy.context.scene.palette_props
389 layout = self.layout
392 bpy.types.PALETTE_MT_menu.preset_subdir = palette_props.presets_folder
393 row = layout.row(align=True)
394 row.menu("PALETTE_MT_menu", text=palette_props.palette_name.rstrip())
395 row.operator("palette.preset_add", text="", icon="ZOOMIN")
396 row.operator("palette.preset_add", text="", icon="ZOOMOUT").remove_active = True
397 col = layout.column(align=True)
398 row = col.row(align=True)
399 row.operator("palette_props.add_color", icon="ZOOMIN")
400 row.prop(palette_props, "index")
401 row.operator("palette_props.remove_color", icon="PANEL_CLOSE")
402 row = col.row(align=True)
403 row.prop(palette_props, "columns")
404 if palette_props.colors.items():
405 layout = col.box()
406 row = layout.row(align=True)
407 row.prop(palette_props, "color_name")
408 row.operator("palette_props.sample_tool_color", icon="COLOR")
410 laycol = layout.column(align=False)
412 if palette_props.columns:
413 columns = palette_props.columns
414 else :
415 columns = 16
416 for i, color in enumerate(palette_props.colors):
417 if not i % columns:
418 row1 = laycol.row(align=True)
419 row1.scale_y = 0.8
420 row2 = laycol.row(align=True)
421 row2.scale_y = 0.5
423 if i == palette_props.current_color_index:
425 row1.prop(palette_props.colors[i], "color", event=True, toggle=True)
426 row2.operator("paint.select_color", emboss=False).color_index = i
427 else :
428 row1.prop(palette_props.colors[i], "color", event=True, toggle=True)
429 row2.operator("paint.select_color").color_index = i
431 layout = self.layout
432 row = layout.row()
433 row.prop(palette_props, "presets_folder", text="")
435 pass
438 class BrushButtonsPanel():
439 bl_space_type = 'IMAGE_EDITOR'
440 bl_region_type = 'UI'
442 @classmethod
443 def poll(cls, context):
444 sima = context.space_data
445 toolsettings = context.tool_settings.image_paint
446 return sima.show_paint and toolsettings.brush
449 class PaintPanel():
450 bl_space_type = 'VIEW_3D'
451 bl_region_type = 'TOOLS'
452 bl_category = 'Tools'
454 @staticmethod
455 def paint_settings(context):
456 ts = context.tool_settings
458 if context.vertex_paint_object:
459 return ts.vertex_paint
460 elif context.weight_paint_object:
461 return ts.weight_paint
462 elif context.texture_paint_object:
463 return ts.image_paint
464 return None
467 class IMAGE_PT_color_palette(BrushButtonsPanel, bpy.types.Panel):
468 bl_label = "Color Palette"
469 bl_options = {'DEFAULT_CLOSED'}
471 def draw(self, context):
472 color_palette_draw(self, context)
475 class VIEW3D_PT_color_palette(PaintPanel, bpy.types.Panel):
476 bl_label = "Color Palette"
477 bl_options = {'DEFAULT_CLOSED'}
479 @classmethod
480 def poll(cls, context):
481 return (context.image_paint_object or context.vertex_paint_object)
483 def draw(self, context):
484 color_palette_draw(self, context)
487 class VIEW3D_OT_select_weight(bpy.types.Operator):
488 bl_label = ""
489 bl_description = "Select this weight"
490 bl_idname = "paint.select_weight"
491 bl_options = {'UNDO'}
493 weight_index = IntProperty()
495 def current_weight(self):
496 pp = bpy.context.scene.palette_props
497 if self.weight_index == 0:
498 weight = pp.weight_0
499 elif self.weight_index == 1:
500 weight = pp.weight_1
501 elif self.weight_index == 2:
502 weight = pp.weight_2
503 elif self.weight_index == 3:
504 weight = pp.weight_3
505 elif self.weight_index == 4:
506 weight = pp.weight_4
507 elif self.weight_index == 5:
508 weight = pp.weight_5
509 elif self.weight_index == 6:
510 weight = pp.weight_6
511 elif self.weight_index == 7:
512 weight = pp.weight_7
513 elif self.weight_index == 8:
514 weight = pp.weight_8
515 elif self.weight_index == 9:
516 weight = pp.weight_9
517 elif self.weight_index == 10:
518 weight = pp.weight_10
519 return weight
521 def invoke(self, context, event):
522 palette_props = bpy.context.scene.palette_props
524 palette_props.current_weight_index = self.weight_index
526 if self.weight_index == 0:
527 weight = palette_props.weight_0
528 elif self.weight_index == 1:
529 weight = palette_props.weight_1
530 elif self.weight_index == 2:
531 weight = palette_props.weight_2
532 elif self.weight_index == 3:
533 weight = palette_props.weight_3
534 elif self.weight_index == 4:
535 weight = palette_props.weight_4
536 elif self.weight_index == 5:
537 weight = palette_props.weight_5
538 elif self.weight_index == 6:
539 weight = palette_props.weight_6
540 elif self.weight_index == 7:
541 weight = palette_props.weight_7
542 elif self.weight_index == 8:
543 weight = palette_props.weight_8
544 elif self.weight_index == 9:
545 weight = palette_props.weight_9
546 elif self.weight_index == 10:
547 weight = palette_props.weight_10
548 palette_props.weight = weight
549 #bpy.context.tool_settings.vertex_group_weight = weight
550 return {'FINISHED'}
553 class VIEW3D_OT_reset_weight_palette(bpy.types.Operator):
554 bl_label = ""
555 bl_idname = "paint.reset_weight_palette"
558 def execute(self, context):
559 palette_props = context.scene.palette_props
561 if palette_props.current_weight_index == 0:
562 palette_props.weight = 0.0
563 palette_props.weight_0 = 0.0
565 palette_props.weight_1 = 0.1
566 if palette_props.current_weight_index == 1:
567 palette_props.weight = 0.1
569 if palette_props.current_weight_index == 2:
570 palette_props.weight = 0.25
571 palette_props.weight_2 = 0.25
573 if palette_props.current_weight_index == 3:
574 palette_props.weight = 0.3333
575 palette_props.weight_3 = 0.3333
577 if palette_props.current_weight_index == 4:
578 palette_props.weight = 0.4
579 palette_props.weight_4 = 0.4
581 if palette_props.current_weight_index == 5:
582 palette_props.weight = 0.5
583 palette_props.weight_5 = 0.5
585 if palette_props.current_weight_index == 6:
586 palette_props.weight = 0.6
587 palette_props.weight_6 = 0.6
589 if palette_props.current_weight_index == 7:
590 palette_props.weight = 0.6666
591 palette_props.weight_7 = 0.6666
593 if palette_props.current_weight_index == 8:
594 palette_props.weight = 0.75
595 palette_props.weight_8 = 0.75
597 if palette_props.current_weight_index == 9:
598 palette_props.weight = 0.9
599 palette_props.weight_9 = 0.9
601 if palette_props.current_weight_index == 10:
602 palette_props.weight = 1.0
603 palette_props.weight_10 = 1.0
604 return {'FINISHED'}
606 class VIEW3D_PT_weight_palette(PaintPanel, bpy.types.Panel):
607 bl_label = "Weight Palette"
608 bl_options = {'DEFAULT_CLOSED'}
610 @classmethod
611 def poll(cls, context):
612 return context.weight_paint_object
614 def draw(self, context):
615 palette_props = bpy.context.scene.palette_props
616 #vertex_group_weight = bpy.context.tool_settings.unified_paint_settings.weight
618 layout = self.layout
619 row = layout.row()
620 row.prop(palette_props, "weight", slider=True)
621 box = layout.box()
623 row = box.row()
624 if palette_props.current_weight_index == 0:
625 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_0,
626 emboss=False).weight_index = 0
627 else :
628 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_0,
629 emboss=True).weight_index = 0
631 row = box.row(align=True)
632 if palette_props.current_weight_index == 1:
633 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_1,
634 emboss=False).weight_index = 1
635 else :
636 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_1,
637 emboss=True).weight_index = 1
639 if palette_props.current_weight_index == 2:
640 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_2,
641 emboss=False).weight_index = 2
642 else :
643 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_2,
644 emboss=True).weight_index = 2
646 if palette_props.current_weight_index == 3:
647 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_3,
648 emboss=False).weight_index = 3
649 else :
650 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_3,
651 emboss=True).weight_index = 3
653 row = box.row(align=True)
654 if palette_props.current_weight_index == 4:
655 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_4,
656 emboss=False).weight_index = 4
657 else :
658 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_4,
659 emboss=True).weight_index = 4
661 if palette_props.current_weight_index == 5:
662 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_5,
663 emboss=False).weight_index = 5
664 else :
665 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_5,
666 emboss=True).weight_index = 5
668 if palette_props.current_weight_index == 6:
669 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_6,
670 emboss=False).weight_index = 6
671 else :
672 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_6,
673 emboss=True).weight_index = 6
675 row = box.row(align=True)
676 if palette_props.current_weight_index == 7:
677 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_7,
678 emboss=False).weight_index = 7
679 else :
680 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_7,
681 emboss=True).weight_index = 7
683 if palette_props.current_weight_index == 8:
684 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_8,
685 emboss=False).weight_index = 8
686 else :
687 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_8,
688 emboss=True).weight_index = 8
690 if palette_props.current_weight_index == 9:
691 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_9,
692 emboss=False).weight_index = 9
693 else :
694 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_9,
695 emboss=True).weight_index = 9
697 row = box.row(align=True)
698 if palette_props.current_weight_index == 10:
699 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_10,
700 emboss=False).weight_index = 10
701 else :
702 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_10,
703 emboss=True).weight_index = 10
705 row = layout.row()
706 row.operator("paint.reset_weight_palette", text="Reset")
709 class Colors(bpy.types.PropertyGroup):
710 """Class for colors CollectionProperty"""
711 color = bpy.props.FloatVectorProperty(
712 name="", description="", default=(0.8, 0.8, 0.8), min=0, max=1,
713 step=1, precision=3, subtype='COLOR_GAMMA', size=3)
716 class Weights(bpy.types.PropertyGroup):
717 """Class for Weights Collection Property"""
719 weight = bpy.props.FloatProperty(
720 default=0.0, min=0.0, max=1.0, precision=3)
723 class PaletteProps(bpy.types.PropertyGroup):
725 def update_color_name(self, context):
726 pp = bpy.context.scene.palette_props
727 pp.colors[pp.current_color_index].name = pp.color_name
728 return None
730 def move_color(self, context):
731 pp = bpy.context.scene.palette_props
732 if pp.colors.items() and pp.current_color_index != pp.index:
733 if pp.index >= pp.colors.__len__():
734 pp.index = pp.colors.__len__() - 1
735 pp.colors.move(pp.current_color_index, pp.index)
736 pp.current_color_index = pp.index
737 return None
739 def update_weight(self, context):
740 pp = context.scene.palette_props
741 weight = pp.weight
742 if pp.current_weight_index == 0:
743 pp.weight_0 = weight
744 elif pp.current_weight_index == 1:
745 pp.weight_1 = weight
746 elif pp.current_weight_index == 2:
747 pp.weight_2 = weight
748 elif pp.current_weight_index == 3:
749 pp.weight_3 = weight
750 elif pp.current_weight_index == 4:
751 pp.weight_4 = weight
752 elif pp.current_weight_index == 5:
753 pp.weight_5 = weight
754 elif pp.current_weight_index == 6:
755 pp.weight_6 = weight
756 elif pp.current_weight_index == 7:
757 pp.weight_7 = weight
758 elif pp.current_weight_index == 8:
759 pp.weight_8 = weight
760 elif pp.current_weight_index == 9:
761 pp.weight_9 = weight
762 elif pp.current_weight_index == 10:
763 pp.weight_10 = weight
764 bpy.context.tool_settings.unified_paint_settings.weight = weight
765 #bpy.context.tool_settings.vertex_group_weight = weight
766 return None
768 palette_name = StringProperty(
769 name="Palette Name", default="Preset", subtype='FILE_NAME')
771 color_name = StringProperty(
772 name="", description="Color Name", default="Untitled", update=update_color_name)
774 columns = IntProperty(
775 name="Columns",
776 description="Number of Columns",
777 min=0, max=16, default=0)
779 index = IntProperty(
780 name="Index",
781 description="Move Selected Color",
782 min=0,
783 update=move_color)
785 notes = StringProperty(
786 name="Palette Notes", default="#\n")
788 current_color_index = IntProperty(
789 name="Current Color Index", description="", default=0, min=0)
791 current_weight_index = IntProperty(
792 name="Current Color Index", description="", default=10, min=-1)
794 presets_folder = StringProperty(name="",
795 description="Palettes Folder",
796 subtype="DIR_PATH")
798 colors = bpy.props.CollectionProperty(type=Colors)
800 weight = bpy.props.FloatProperty(name="Weight",
801 default=0.0, min=0.0, max=1.0, precision=3, update=update_weight)
803 weight_0 = bpy.props.FloatProperty(
804 default=0.0, min=0.0, max=1.0, precision=3)
805 weight_1 = bpy.props.FloatProperty(
806 default=0.1, min=0.0, max=1.0, precision=3)
807 weight_2 = bpy.props.FloatProperty(
808 default=0.25, min=0.0, max=1.0, precision=3)
809 weight_3 = bpy.props.FloatProperty(
810 default=0.333, min=0.0, max=1.0, precision=3)
811 weight_4 = bpy.props.FloatProperty(
812 default=0.4, min=0.0, max=1.0, precision=3)
813 weight_5 = bpy.props.FloatProperty(
814 default=0.5, min=0.0, max=1.0, precision=3)
815 weight_6 = bpy.props.FloatProperty(
816 default=0.6, min=0.0, max=1.0, precision=3)
817 weight_7 = bpy.props.FloatProperty(
818 default=0.6666, min=0.0, max=1.0, precision=3)
819 weight_8 = bpy.props.FloatProperty(
820 default=0.75, min=0.0, max=1.0, precision=3)
821 weight_9 = bpy.props.FloatProperty(
822 default=0.9, min=0.0, max=1.0, precision=3)
823 weight_10 = bpy.props.FloatProperty(
824 default=1.0, min=0.0, max=1.0, precision=3)
825 pass
827 def register():
828 bpy.utils.register_module(__name__)
830 bpy.types.Scene.palette_props = PointerProperty(
831 type=PaletteProps, name="Palette Props", description="")
832 pass
835 def unregister():
836 bpy.utils.unregister_module(__name__)
838 del bpy.types.Scene.palette_props
839 pass
842 if __name__ == "__main__":
843 register()
846 # To Do List
847 # ToDo1 Overiting the current file
848 # ToDo3 Foreground Background