0% found this document useful (0 votes)
18 views1 page

Color Palette

Uploaded by

sbougnane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views1 page

Color Palette

Uploaded by

sbougnane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import bpy

class PaletteDemoPanel(bpy.types.Panel):
"""Creates a Panel in the tool panel of image editor"""
bl_label = "Palette Demo"
bl_idname = "IMAGE_PT_palette"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "material"

def draw(self, context):


layout = self.layout

ts = context.tool_settings
if ts.image_paint.palette:
layout.template_palette(ts.image_paint, "palette", color=True)

def register():
bpy.utils.register_class(PaletteDemoPanel)

def unregister():
bpy.utils.unregister_class(PaletteDemoPanel)

if __name__ == "__main__":
register()

# put some test code here to create palette etc


# add a new pallete
pal = bpy.data.palettes.get("CustomPalette")
if pal is None:
pal = bpy.data.palettes.new("CustomPalette")
# add a color to that palette
yellow = pal.colors.new()
yellow.color = (1, 1, 0)
yellow.weight = 1.0

red = pal.colors.new()
red.color = (1, 0, 0)

# make red active


pal.colors.active = red

ts = bpy.context.tool_settings
ts.image_paint.palette = pal

You might also like