FBX: reformat props.
[blender-addons.git] / paint_palette.py
blob7c95fd3e5644677313feef40a217c9c04ccf7889
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"
374 color_index = IntProperty()
376 def invoke(self, context, event):
377 palette_props = bpy.context.scene.palette_props
378 palette_props.current_color_index = self.color_index
380 update_panels()
381 return {'FINISHED'}
384 def color_palette_draw(self, context):
385 palette_props = bpy.context.scene.palette_props
388 layout = self.layout
391 bpy.types.PALETTE_MT_menu.preset_subdir = palette_props.presets_folder
392 row = layout.row(align=True)
393 row.menu("PALETTE_MT_menu", text=palette_props.palette_name.rstrip())
394 row.operator("palette.preset_add", text="", icon="ZOOMIN")
395 row.operator("palette.preset_add", text="", icon="ZOOMOUT").remove_active = True
396 col = layout.column(align=True)
397 row = col.row(align=True)
398 row.operator("palette_props.add_color", icon="ZOOMIN")
399 row.prop(palette_props, "index")
400 row.operator("palette_props.remove_color", icon="PANEL_CLOSE")
401 row = col.row(align=True)
402 row.prop(palette_props, "columns")
403 if palette_props.colors.items():
404 layout = col.box()
405 row = layout.row(align=True)
406 row.prop(palette_props, "color_name")
407 row.operator("palette_props.sample_tool_color", icon="COLOR")
409 laycol = layout.column(align=False)
411 if palette_props.columns:
412 columns = palette_props.columns
413 else :
414 columns = 16
415 for i, color in enumerate(palette_props.colors):
416 if not i % columns:
417 row1 = laycol.row(align=True)
418 row1.scale_y = 0.8
419 row2 = laycol.row(align=True)
420 row2.scale_y = 0.5
422 if i == palette_props.current_color_index:
424 row1.prop(palette_props.colors[i], "color", event=True, toggle=True)
425 row2.operator("paint.select_color", emboss=False).color_index = i
426 else :
427 row1.prop(palette_props.colors[i], "color", event=True, toggle=True)
428 row2.operator("paint.select_color").color_index = i
430 layout = self.layout
431 row = layout.row()
432 row.prop(palette_props, "presets_folder", text="")
434 pass
437 class BrushButtonsPanel():
438 bl_space_type = 'IMAGE_EDITOR'
439 bl_region_type = 'UI'
441 @classmethod
442 def poll(cls, context):
443 sima = context.space_data
444 toolsettings = context.tool_settings.image_paint
445 return sima.show_paint and toolsettings.brush
448 class PaintPanel():
449 bl_space_type = 'VIEW_3D'
450 bl_region_type = 'TOOLS'
451 bl_category = 'Tools'
453 @staticmethod
454 def paint_settings(context):
455 ts = context.tool_settings
457 if context.vertex_paint_object:
458 return ts.vertex_paint
459 elif context.weight_paint_object:
460 return ts.weight_paint
461 elif context.texture_paint_object:
462 return ts.image_paint
463 return None
466 class IMAGE_PT_color_palette(BrushButtonsPanel, bpy.types.Panel):
467 bl_label = "Color Palette"
468 bl_options = {'DEFAULT_CLOSED'}
470 def draw(self, context):
471 color_palette_draw(self, context)
474 class VIEW3D_PT_color_palette(PaintPanel, bpy.types.Panel):
475 bl_label = "Color Palette"
476 bl_options = {'DEFAULT_CLOSED'}
478 @classmethod
479 def poll(cls, context):
480 return (context.image_paint_object or context.vertex_paint_object)
482 def draw(self, context):
483 color_palette_draw(self, context)
486 class VIEW3D_OT_select_weight(bpy.types.Operator):
487 bl_label = ""
488 bl_description = "Select this weight"
489 bl_idname = "paint.select_weight"
491 weight_index = IntProperty()
493 def current_weight(self):
494 pp = bpy.context.scene.palette_props
495 if self.weight_index == 0:
496 weight = pp.weight_0
497 elif self.weight_index == 1:
498 weight = pp.weight_1
499 elif self.weight_index == 2:
500 weight = pp.weight_2
501 elif self.weight_index == 3:
502 weight = pp.weight_3
503 elif self.weight_index == 4:
504 weight = pp.weight_4
505 elif self.weight_index == 5:
506 weight = pp.weight_5
507 elif self.weight_index == 6:
508 weight = pp.weight_6
509 elif self.weight_index == 7:
510 weight = pp.weight_7
511 elif self.weight_index == 8:
512 weight = pp.weight_8
513 elif self.weight_index == 9:
514 weight = pp.weight_9
515 elif self.weight_index == 10:
516 weight = pp.weight_10
517 return weight
519 def invoke(self, context, event):
520 palette_props = bpy.context.scene.palette_props
522 palette_props.current_weight_index = self.weight_index
524 if self.weight_index == 0:
525 weight = palette_props.weight_0
526 elif self.weight_index == 1:
527 weight = palette_props.weight_1
528 elif self.weight_index == 2:
529 weight = palette_props.weight_2
530 elif self.weight_index == 3:
531 weight = palette_props.weight_3
532 elif self.weight_index == 4:
533 weight = palette_props.weight_4
534 elif self.weight_index == 5:
535 weight = palette_props.weight_5
536 elif self.weight_index == 6:
537 weight = palette_props.weight_6
538 elif self.weight_index == 7:
539 weight = palette_props.weight_7
540 elif self.weight_index == 8:
541 weight = palette_props.weight_8
542 elif self.weight_index == 9:
543 weight = palette_props.weight_9
544 elif self.weight_index == 10:
545 weight = palette_props.weight_10
546 palette_props.weight = weight
547 #bpy.context.tool_settings.vertex_group_weight = weight
548 return {'FINISHED'}
551 class VIEW3D_OT_reset_weight_palette(bpy.types.Operator):
552 bl_label = ""
553 bl_idname = "paint.reset_weight_palette"
556 def execute(self, context):
557 palette_props = context.scene.palette_props
559 if palette_props.current_weight_index == 0:
560 palette_props.weight = 0.0
561 palette_props.weight_0 = 0.0
563 palette_props.weight_1 = 0.1
564 if palette_props.current_weight_index == 1:
565 palette_props.weight = 0.1
567 if palette_props.current_weight_index == 2:
568 palette_props.weight = 0.25
569 palette_props.weight_2 = 0.25
571 if palette_props.current_weight_index == 3:
572 palette_props.weight = 0.3333
573 palette_props.weight_3 = 0.3333
575 if palette_props.current_weight_index == 4:
576 palette_props.weight = 0.4
577 palette_props.weight_4 = 0.4
579 if palette_props.current_weight_index == 5:
580 palette_props.weight = 0.5
581 palette_props.weight_5 = 0.5
583 if palette_props.current_weight_index == 6:
584 palette_props.weight = 0.6
585 palette_props.weight_6 = 0.6
587 if palette_props.current_weight_index == 7:
588 palette_props.weight = 0.6666
589 palette_props.weight_7 = 0.6666
591 if palette_props.current_weight_index == 8:
592 palette_props.weight = 0.75
593 palette_props.weight_8 = 0.75
595 if palette_props.current_weight_index == 9:
596 palette_props.weight = 0.9
597 palette_props.weight_9 = 0.9
599 if palette_props.current_weight_index == 10:
600 palette_props.weight = 1.0
601 palette_props.weight_10 = 1.0
602 return {'FINISHED'}
604 class VIEW3D_PT_weight_palette(PaintPanel, bpy.types.Panel):
605 bl_label = "Weight Palette"
606 bl_options = {'DEFAULT_CLOSED'}
608 @classmethod
609 def poll(cls, context):
610 return context.weight_paint_object
612 def draw(self, context):
613 palette_props = bpy.context.scene.palette_props
614 #vertex_group_weight = bpy.context.tool_settings.unified_paint_settings.weight
616 layout = self.layout
617 row = layout.row()
618 row.prop(palette_props, "weight", slider=True)
619 box = layout.box()
621 row = box.row()
622 if palette_props.current_weight_index == 0:
623 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_0,
624 emboss=False).weight_index = 0
625 else :
626 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_0,
627 emboss=True).weight_index = 0
629 row = box.row(align=True)
630 if palette_props.current_weight_index == 1:
631 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_1,
632 emboss=False).weight_index = 1
633 else :
634 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_1,
635 emboss=True).weight_index = 1
637 if palette_props.current_weight_index == 2:
638 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_2,
639 emboss=False).weight_index = 2
640 else :
641 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_2,
642 emboss=True).weight_index = 2
644 if palette_props.current_weight_index == 3:
645 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_3,
646 emboss=False).weight_index = 3
647 else :
648 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_3,
649 emboss=True).weight_index = 3
651 row = box.row(align=True)
652 if palette_props.current_weight_index == 4:
653 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_4,
654 emboss=False).weight_index = 4
655 else :
656 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_4,
657 emboss=True).weight_index = 4
659 if palette_props.current_weight_index == 5:
660 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_5,
661 emboss=False).weight_index = 5
662 else :
663 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_5,
664 emboss=True).weight_index = 5
666 if palette_props.current_weight_index == 6:
667 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_6,
668 emboss=False).weight_index = 6
669 else :
670 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_6,
671 emboss=True).weight_index = 6
673 row = box.row(align=True)
674 if palette_props.current_weight_index == 7:
675 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_7,
676 emboss=False).weight_index = 7
677 else :
678 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_7,
679 emboss=True).weight_index = 7
681 if palette_props.current_weight_index == 8:
682 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_8,
683 emboss=False).weight_index = 8
684 else :
685 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_8,
686 emboss=True).weight_index = 8
688 if palette_props.current_weight_index == 9:
689 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_9,
690 emboss=False).weight_index = 9
691 else :
692 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_9,
693 emboss=True).weight_index = 9
695 row = box.row(align=True)
696 if palette_props.current_weight_index == 10:
697 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_10,
698 emboss=False).weight_index = 10
699 else :
700 row.operator("paint.select_weight", text="%.2f" % palette_props.weight_10,
701 emboss=True).weight_index = 10
703 row = layout.row()
704 row.operator("paint.reset_weight_palette", text="Reset")
707 class Colors(bpy.types.PropertyGroup):
708 """Class for colors CollectionProperty"""
709 color = bpy.props.FloatVectorProperty(
710 name="", description="", default=(0.8, 0.8, 0.8), min=0, max=1,
711 step=1, precision=3, subtype='COLOR_GAMMA', size=3)
714 class Weights(bpy.types.PropertyGroup):
715 """Class for Weights Collection Property"""
717 weight = bpy.props.FloatProperty(
718 default=0.0, min=0.0, max=1.0, precision=3)
721 class PaletteProps(bpy.types.PropertyGroup):
723 def update_color_name(self, context):
724 pp = bpy.context.scene.palette_props
725 pp.colors[pp.current_color_index].name = pp.color_name
726 return None
728 def move_color(self, context):
729 pp = bpy.context.scene.palette_props
730 if pp.colors.items() and pp.current_color_index != pp.index:
731 if pp.index >= pp.colors.__len__():
732 pp.index = pp.colors.__len__() - 1
733 pp.colors.move(pp.current_color_index, pp.index)
734 pp.current_color_index = pp.index
735 return None
737 def update_weight(self, context):
738 pp = context.scene.palette_props
739 weight = pp.weight
740 if pp.current_weight_index == 0:
741 pp.weight_0 = weight
742 elif pp.current_weight_index == 1:
743 pp.weight_1 = weight
744 elif pp.current_weight_index == 2:
745 pp.weight_2 = weight
746 elif pp.current_weight_index == 3:
747 pp.weight_3 = weight
748 elif pp.current_weight_index == 4:
749 pp.weight_4 = weight
750 elif pp.current_weight_index == 5:
751 pp.weight_5 = weight
752 elif pp.current_weight_index == 6:
753 pp.weight_6 = weight
754 elif pp.current_weight_index == 7:
755 pp.weight_7 = weight
756 elif pp.current_weight_index == 8:
757 pp.weight_8 = weight
758 elif pp.current_weight_index == 9:
759 pp.weight_9 = weight
760 elif pp.current_weight_index == 10:
761 pp.weight_10 = weight
762 bpy.context.tool_settings.unified_paint_settings.weight = weight
763 #bpy.context.tool_settings.vertex_group_weight = weight
764 return None
766 palette_name = StringProperty(
767 name="Palette Name", default="Preset", subtype='FILE_NAME')
769 color_name = StringProperty(
770 name="", description="Color Name", default="Untitled", update=update_color_name)
772 columns = IntProperty(
773 name="Columns",
774 description="Number of Columns",
775 min=0, max=16, default=0)
777 index = IntProperty(
778 name="Index",
779 description="Move Selected Color",
780 min=0,
781 update=move_color)
783 notes = StringProperty(
784 name="Palette Notes", default="#\n")
786 current_color_index = IntProperty(
787 name="Current Color Index", description="", default=0, min=0)
789 current_weight_index = IntProperty(
790 name="Current Color Index", description="", default=10, min=-1)
792 presets_folder = StringProperty(name="",
793 description="Palettes Folder",
794 subtype="DIR_PATH")
796 colors = bpy.props.CollectionProperty(type=Colors)
798 weight = bpy.props.FloatProperty(name="Weight",
799 default=0.0, min=0.0, max=1.0, precision=3, update=update_weight)
801 weight_0 = bpy.props.FloatProperty(
802 default=0.0, min=0.0, max=1.0, precision=3)
803 weight_1 = bpy.props.FloatProperty(
804 default=0.1, min=0.0, max=1.0, precision=3)
805 weight_2 = bpy.props.FloatProperty(
806 default=0.25, min=0.0, max=1.0, precision=3)
807 weight_3 = bpy.props.FloatProperty(
808 default=0.333, min=0.0, max=1.0, precision=3)
809 weight_4 = bpy.props.FloatProperty(
810 default=0.4, min=0.0, max=1.0, precision=3)
811 weight_5 = bpy.props.FloatProperty(
812 default=0.5, min=0.0, max=1.0, precision=3)
813 weight_6 = bpy.props.FloatProperty(
814 default=0.6, min=0.0, max=1.0, precision=3)
815 weight_7 = bpy.props.FloatProperty(
816 default=0.6666, min=0.0, max=1.0, precision=3)
817 weight_8 = bpy.props.FloatProperty(
818 default=0.75, min=0.0, max=1.0, precision=3)
819 weight_9 = bpy.props.FloatProperty(
820 default=0.9, min=0.0, max=1.0, precision=3)
821 weight_10 = bpy.props.FloatProperty(
822 default=1.0, min=0.0, max=1.0, precision=3)
823 pass
825 def register():
826 bpy.utils.register_module(__name__)
828 bpy.types.Scene.palette_props = PointerProperty(
829 type=PaletteProps, name="Palette Props", description="")
830 pass
833 def unregister():
834 bpy.utils.unregister_module(__name__)
836 del bpy.types.Scene.palette_props
837 pass
840 if __name__ == "__main__":
841 register()
844 # To Do List
845 # ToDo1 Overiting the current file
846 # ToDo3 Foreground Background