adds palette support
This commit is contained in:
parent
feb1887a7d
commit
c16e4c268b
7 changed files with 59 additions and 35 deletions
|
|
@ -1 +1 @@
|
|||
1.1.0+build.1
|
||||
1.2.0+build.1
|
||||
|
|
@ -47,7 +47,8 @@ class BakeToIDMapOperator(bpy.types.Operator):
|
|||
return source.get_targets([context.active_object])
|
||||
|
||||
if props.selection_mode == 'MULTIPLE_COMBINED':
|
||||
return source.get_targets(context.selected_objects)
|
||||
filtered_object = filter(lambda x: x.type == 'MESH', context.selected_objects)
|
||||
return source.get_targets(list(filtered_object))
|
||||
|
||||
if props.selection_mode == 'MULTIPLE_SEPARATE':
|
||||
result = []
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import textwrap
|
|||
|
||||
import bpy
|
||||
|
||||
from ..types.colors import get_color
|
||||
from .. types.sources import get_source
|
||||
from .. types.targets import get_target
|
||||
|
||||
|
|
@ -23,21 +24,33 @@ class BakeToIDOptionsPanel(bpy.types.Panel):
|
|||
|
||||
layout.prop(props, "source")
|
||||
source = get_source(props.source)
|
||||
|
||||
if len(source.connected_properties) > 0:
|
||||
source_settings_box = layout.box()
|
||||
for setting in source.connected_properties:
|
||||
source_settings_box.prop(props, setting)
|
||||
self.draw_options(context, layout, props, source)
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.prop(props, "target")
|
||||
target = get_target(props.target)
|
||||
if len(target.connected_properties) > 0:
|
||||
target_settings_box = layout.box()
|
||||
for setting in target.connected_properties:
|
||||
target_settings_box.prop(props, setting)
|
||||
self.draw_options(context, layout, props, target)
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.prop(props, "colors")
|
||||
color = get_color(props.colors)
|
||||
self.draw_options(context, layout, props, color)
|
||||
|
||||
def draw_options(self, context, layout, props, element):
|
||||
|
||||
has_render_ui = 'render_ui' in dir(element)
|
||||
has_connected_properties = 'connected_properties' in dir(element) and len(element.connected_properties) > 0
|
||||
|
||||
if not has_render_ui and not has_connected_properties:
|
||||
return
|
||||
|
||||
object_box = layout.box()
|
||||
|
||||
if has_render_ui:
|
||||
element.render_ui(context, object_box, props)
|
||||
return
|
||||
|
||||
for setting in element.connected_properties:
|
||||
object_box.prop(props, setting)
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
from bpy.types import (PropertyGroup)
|
||||
from bpy.props import (EnumProperty, BoolProperty, IntProperty, StringProperty)
|
||||
from bpy.types import (PropertyGroup, Palette)
|
||||
from bpy.props import (EnumProperty, BoolProperty, IntProperty, StringProperty, PointerProperty)
|
||||
|
||||
from src.types.colors import get_color_enum
|
||||
from src.types.sources import get_source_enum
|
||||
|
|
@ -55,23 +55,8 @@ class BakeToIDProperties(PropertyGroup):
|
|||
description="If set true, the attribute will be deleted and recreated, if it already exists. If set false, the data will just be overwritten."
|
||||
)
|
||||
|
||||
adv_total_hues: IntProperty(
|
||||
name="Total Hues",
|
||||
default=10,
|
||||
min=1,
|
||||
soft_max=360,
|
||||
)
|
||||
|
||||
adv_total_satuations: IntProperty(
|
||||
name="Total Satuations",
|
||||
default=10,
|
||||
min=1,
|
||||
soft_max=100,
|
||||
)
|
||||
|
||||
adv_total_brightnesses: IntProperty(
|
||||
name="Total Brightnesses",
|
||||
default=10,
|
||||
min=1,
|
||||
soft_max=100,
|
||||
colors_color_palette_palette: PointerProperty(
|
||||
type=Palette,
|
||||
name='Color Palette',
|
||||
description="The Color Palette used for colors"
|
||||
)
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
from . import generated
|
||||
from . import generated, color_palette
|
||||
|
||||
_colors = [
|
||||
generated
|
||||
generated,
|
||||
color_palette
|
||||
]
|
||||
|
||||
|
||||
|
|
|
|||
25
src/types/colors/color_palette.py
Normal file
25
src/types/colors/color_palette.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
color_id = 'COLOR_PALETTE'
|
||||
name = 'Palette'
|
||||
description = "The color palette is specified by the user"
|
||||
|
||||
|
||||
def get_colors(props):
|
||||
if not props.colors_color_palette_palette:
|
||||
return []
|
||||
|
||||
return list(map(lambda x: x.color, props.colors_color_palette_palette.colors))
|
||||
|
||||
|
||||
def get_count(props):
|
||||
if not props.colors_color_palette_palette:
|
||||
return 0
|
||||
|
||||
return len(props.colors_color_palette_palette.colors)
|
||||
|
||||
|
||||
def render_ui(context, layout, props):
|
||||
layout.template_ID(props, "colors_color_palette_palette")
|
||||
if props.colors_color_palette_palette:
|
||||
row = layout.column()
|
||||
row.enabled = False
|
||||
row.template_palette(props, "colors_color_palette_palette", color=True)
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
import colorsys
|
||||
import math
|
||||
|
||||
color_id = 'GENERATED'
|
||||
name = 'Generated'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue