Ejemplo n.º 1
0
 def setNodePathColor(color):
     nodePath.setColor(color[0]/255.0, color[1]/255.0,
                       color[2]/255.0, color[3]/255.0)
     # Update color chip button
     pButton['bg'] = getTkColorString(color)
     # Execute callback to pass along color info
     if callback:
         callback(color)
Ejemplo n.º 2
0
def lightRGBPanel(light, style = 'mini'):
    # Color picker for lights
    def popupColorPicker():
        # Can pass in current color with: color = (255, 0, 0)
        color = tkColorChooser.askcolor(
            parent = vgp.interior(),
            # Initialize it to current color
            initialcolor = tuple(vgp.get()[:3]))[0]
        if color:
            vgp.set((color[0], color[1], color[2], vgp.getAt(3)))
    def printToLog():
        n = light.getName()
        c=light.getColor()
        print n + (".setColor(Vec4(%.3f, %.3f, %.3f, %.3f))" %
                   (c[0], c[1], c[2], c[3]))
    # Check init color
    initColor = light.getColor() * 255.0
    # Create entry scale group
    vgp = ValuatorGroupPanel(title = 'RGBA Panel: ' + light.getName(),
                             dim = 4,
                             labels = ['R','G','B','A'],
                             value = [int(initColor[0]),
                                      int(initColor[1]),
                                      int(initColor[2]),
                                      int(initColor[3])],
                             type = 'slider',
                             valuator_style = style,
                             valuator_min = 0,
                             valuator_max = 255,
                             valuator_resolution = 1,
                             # Destroy not withdraw panel on dismiss
                             fDestroy = 1)
    # Update menu button
    vgp.component('menubar').component('Valuator Group-button')['text'] = (
        'Light Control Panel')
    # Add a print button which will also serve as a color tile
    pButton = Button(vgp.interior(), text = 'Print to Log',
                     bg = getTkColorString(initColor),
                     command = printToLog)
    pButton.pack(expand = 1, fill = BOTH)
    # Update menu
    menu = vgp.component('menubar').component('Valuator Group-menu')
    # System color picker
    menu.insert_command(index = 4, label = 'Popup Color Picker',
                        command = popupColorPicker)
    menu.insert_command(index = 5, label = 'Print to log',
                        command = printToLog)
    def setLightColor(color):
        light.setColor(Vec4(color[0]/255.0, color[1]/255.0,
                            color[2]/255.0, color[3]/255.0))
        # Update color chip button
        pButton['bg'] = getTkColorString(color)
    vgp['command'] = setLightColor
    return vgp
Ejemplo n.º 3
0
 def setLightColor(color):
     light.setColor(Vec4(color[0]/255.0, color[1]/255.0,
                         color[2]/255.0, color[3]/255.0))
     # Update color chip button
     pButton['bg'] = getTkColorString(color)
Ejemplo n.º 4
0
def rgbPanel(nodePath, callback = None, style = 'mini'):
    def onRelease(r, g, b, a, nodePath = nodePath):
        messenger.send('RGBPanel_setColor', [nodePath, r, g, b, a])

    def popupColorPicker():
        # Can pass in current color with: color = (255, 0, 0)
        color = tkColorChooser.askcolor(
            parent = vgp.interior(),
            # Initialize it to current color
            initialcolor = tuple(vgp.get()[:3]))[0]
        if color:
            vgp.set((color[0], color[1], color[2], vgp.getAt(3)))

    def printToLog():
        c=nodePath.getColor()
        print "Vec4(%.3f, %.3f, %.3f, %.3f)"%(c[0], c[1], c[2], c[3])

    # Check init color
    if nodePath.hasColor():
        initColor = nodePath.getColor() * 255.0
    else:
        initColor = Vec4(255)
    # Create entry scale group
    vgp = ValuatorGroupPanel(title = 'RGBA Panel: ' + nodePath.getName(),
                             dim = 4,
                             labels = ['R','G','B','A'],
                             value = [int(initColor[0]),
                                      int(initColor[1]),
                                      int(initColor[2]),
                                      int(initColor[3])],
                             type = 'slider',
                             valuator_style = style,
                             valuator_min = 0,
                             valuator_max = 255,
                             valuator_resolution = 1,
                             # Destroy not withdraw panel on dismiss
                             fDestroy = 1)
    # Update menu button
    vgp.component('menubar').component('Valuator Group-button')['text'] = (
        'RGBA Panel')

    # Set callback
    vgp['postCallback'] = onRelease

    # Add a print button which will also serve as a color tile
    pButton = Button(vgp.interior(), text = 'Print to Log',
                     bg = getTkColorString(initColor),
                     command = printToLog)
    pButton.pack(expand = 1, fill = BOTH)

    # Update menu
    menu = vgp.component('menubar').component('Valuator Group-menu')
    # Some helper functions
    # Clear color
    menu.insert_command(index = 1, label = 'Clear Color',
                        command = lambda: nodePath.clearColor())
    # Set Clear Transparency
    menu.insert_command(index = 2, label = 'Set Transparency',
                        command = lambda: nodePath.setTransparency(1))
    menu.insert_command(
        index = 3, label = 'Clear Transparency',
        command = lambda: nodePath.clearTransparency())


    # System color picker
    menu.insert_command(index = 4, label = 'Popup Color Picker',
                        command = popupColorPicker)

    menu.insert_command(index = 5, label = 'Print to log',
                        command = printToLog)

    def setNodePathColor(color):
        nodePath.setColor(color[0]/255.0, color[1]/255.0,
                          color[2]/255.0, color[3]/255.0)
        # Update color chip button
        pButton['bg'] = getTkColorString(color)
        # Execute callback to pass along color info
        if callback:
            callback(color)
    vgp['command'] = setNodePathColor

    return vgp