def setBackColorVec(self, color): if not self.changesEnabled: return None vColor = Vec4(color[0] / 1.0, color[1] / 1.0, color[2] / 1.0, 1) iColor = [ int(vColor[0] * 127.5), int(vColor[1] * 127.5), int(vColor[2] * 127.5)] if self.todMgr.shadowLight: self.todMgr.setBackLightColor(vColor) self.backLightLabel['bg'] = getTkColorString(self.clipLightValue(iColor)) todState = self.todVar.get() if self.holdBackColor != vColor: if self.holdBackColor != None: button = self.todButtonDict.get(todState) if button: button['bg'] = getTkColorString(self.uncommitedColor) self.holdBackColor = vColor self.saveChanges['state'] = 'normal' if self.editor and self.editor.TODPanelLoaded: self.editor.objectMgr.currEditedObjInfo.setTodModified(True) self.backLightLabel['text'] = '\n%.4s | %.4s | %.4s' % (vColor[0], vColor[1], vColor[2])
def checkButtonsForChange(self): changedColor = Vec4(0.0, 255.0, 255.0, 255.0) defaultColor = Vec4(255.0, 255.0, 255.0, 255.0) if self.editor: alteredTODs = self.todMgr.listAlteredTODs(TODGlobals.ENV_DATAFILE) else: alteredTODs = self.todMgr.listAlteredTODs(self.todMgr.environment) for key in self.todButtonDict: button = self.todButtonDict[key] text = TODGlobals.StateDict.get(key) if text: if text in alteredTODs: button['bg'] = getTkColorString(self.changedColor) else: button['bg'] = getTkColorString(self.defaultColor) frontSwitch = self.todMgr.lightSwitch[0] ambientSwitch = self.todMgr.lightSwitch[1] backSwitch = self.todMgr.lightSwitch[2] self.frontSwitchVar.set(frontSwitch) self.ambientSwitchVar.set(ambientSwitch) self.backSwitchVar.set(backSwitch) self.fogTypeVar.set(self.todMgr.fogType) self.todSkyTypeVar.set(int(self.todMgr.skyGroup.lastSky)) alteredTODs = self.todMgr.listAlteredTODs(self.todMgr.environment) alteredTime = 0 stateId = self.todMgr.currentState for entry in alteredTODs: if entry == stateId: alteredTime = 1 if alteredTime and self.selectedCycleDuration == 0 or 1: self.removeChanges['state'] = 'normal' else: self.removeChanges['state'] = 'disabled'
def setAmbientColorVec(self, color): if not self.changesEnabled: return None vColor = Vec4(color[0] / 1.0, color[1] / 1.0, color[2] / 1.0, 1) iColor = [ int(vColor[0] * 255.0), int(vColor[1] * 255.0), int(vColor[2] * 255.0)] self.todMgr.setFillLightColor(vColor) self.ambientLabel['bg'] = getTkColorString(iColor) todState = self.todVar.get() if self.holdAmbientColor != vColor: if self.holdAmbientColor != None: button = self.todButtonDict.get(todState) if button: button['bg'] = getTkColorString(self.uncommitedColor) self.holdAmbientColor = vColor self.saveChanges['state'] = 'normal' if self.holdDirectionColor: self.todMgr.setFrontLightColor(self.holdDirectionColor) if self.holdBackColor: self.todMgr.setBackLightColor(self.holdBackColor) if self.editor and self.editor.TODPanelLoaded: self.editor.objectMgr.currEditedObjInfo.setTodModified(True) self.ambientLabel['text'] = '\n%.4s | %.4s | %.4s' % (vColor[0], vColor[1], vColor[2])
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)
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)
def setFogColorVec(self, color): if not self.changesEnabled: return vColor = Vec4(color[0] / 1.0, color[1] / 1.0, color[2] / 1.0, 0) iColor = [int(vColor[0] * 255.0), int(vColor[1] * 255.0), int(vColor[2] * 255.0)] todState = self.todVar.get() self.todMgr.setFogColor(vColor) self.fogLabel['bg'] = getTkColorString(iColor) if self.holdFogColor != vColor: if self.holdFogColor != None: button = self.todButtonDict.get(todState) if button: button['bg'] = getTkColorString(self.uncommitedColor) self.holdFogColor = vColor self.saveChanges['state'] = 'normal' if (self.editor and self).editor.TODPanelLoaded: self.editor.objectMgr.currEditedObjInfo.setTodModified(True) return
def lightRGBPanel(light, style = 'mini'): # Color picker for lights def popupColorPicker(): # Can pass in current color with: color = (255, 0, 0) color = 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
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
def setBackColorVec(self, color): if not self.changesEnabled: return vColor = Vec4(color[0] / 1.0, color[1] / 1.0, color[2] / 1.0, 1) iColor = [int(vColor[0] * 127.5), int(vColor[1] * 127.5), int(vColor[2] * 127.5)] if self.todMgr.shadowLight: self.todMgr.setBackLightColor(vColor) self.backLightLabel['bg'] = getTkColorString(self.clipLightValue(iColor)) todState = self.todVar.get() if self.holdBackColor != vColor: if self.holdBackColor != None: button = self.todButtonDict.get(todState) if button: button['bg'] = getTkColorString(self.uncommitedColor) self.holdBackColor = vColor self.saveChanges['state'] = 'normal' if (self.editor and self).editor.TODPanelLoaded: self.editor.objectMgr.currEditedObjInfo.setTodModified(True) self.backLightLabel['text'] = '\n%.4s | %.4s | %.4s' % (vColor[0], vColor[1], vColor[2]) return
def changeSky(self): if not self.changesEnabled: return newSkyValue = self.todSkyTypeVar.get() skyValue = self.todMgr.skyGroup.lastSky todState = self.todVar.get() if skyValue != newSkyValue: button = self.todButtonDict.get(todState) if button: button['bg'] = getTkColorString(self.uncommitedColor) self.saveChanges['state'] = 'normal' self.todMgr.setSkyType(newSkyValue)
def switchBack(self): if not self.changesEnabled: return backSwitch = self.backSwitchVar.get() lightSwitch = self.todMgr.lightSwitch newSwitch = [lightSwitch[0], lightSwitch[1], backSwitch] todState = self.todVar.get() if lightSwitch != newSwitch: button = self.todButtonDict.get(todState) if button: button['bg'] = getTkColorString(self.uncommitedColor) self.saveChanges['state'] = 'normal' self.todMgr.setLightSwitch(newSwitch)
def setFogType(self): if not self.changesEnabled: return newFogType = self.fogTypeVar.get() fogType = self.todMgr.fogType todState = self.todVar.get() if fogType != newFogType: button = self.todButtonDict.get(todState) if button: button['bg'] = getTkColorString(self.uncommitedColor) self.saveChanges['state'] = 'normal' self.todMgr.setFogType(newFogType) self.repackFog()
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
def setFogColorVec(self, color): if not self.changesEnabled: return None vColor = Vec4(color[0] / 1.0, color[1] / 1.0, color[2] / 1.0, 0) iColor = [ int(vColor[0] * 255.0), int(vColor[1] * 255.0), int(vColor[2] * 255.0)] todState = self.todVar.get() self.todMgr.setFogColor(vColor) self.fogLabel['bg'] = getTkColorString(iColor) if self.holdFogColor != vColor: if self.holdFogColor != None: button = self.todButtonDict.get(todState) if button: button['bg'] = getTkColorString(self.uncommitedColor) self.holdFogColor = vColor self.saveChanges['state'] = 'normal' if self.editor and self.editor.TODPanelLoaded: self.editor.objectMgr.currEditedObjInfo.setTodModified(True)
def changeSky(self): if not self.changesEnabled: return None newSkyValue = self.todSkyTypeVar.get() skyValue = self.todMgr.skyGroup.lastSky todState = self.todVar.get() if skyValue != newSkyValue: button = self.todButtonDict.get(todState) if button: button['bg'] = getTkColorString(self.uncommitedColor) self.saveChanges['state'] = 'normal' self.todMgr.setSkyType(newSkyValue)
def setAmbientColorVec(self, color): if not self.changesEnabled: return vColor = Vec4(color[0] / 1.0, color[1] / 1.0, color[2] / 1.0, 1) iColor = [int(vColor[0] * 255.0), int(vColor[1] * 255.0), int(vColor[2] * 255.0)] self.todMgr.setFillLightColor(vColor) self.ambientLabel['bg'] = getTkColorString(iColor) todState = self.todVar.get() if self.holdAmbientColor != vColor: if self.holdAmbientColor != None: button = self.todButtonDict.get(todState) if button: button['bg'] = getTkColorString(self.uncommitedColor) self.holdAmbientColor = vColor self.saveChanges['state'] = 'normal' if self.holdDirectionColor: self.todMgr.setFrontLightColor(self.holdDirectionColor) if self.holdBackColor: self.todMgr.setBackLightColor(self.holdBackColor) if (self.editor and self).editor.TODPanelLoaded: self.editor.objectMgr.currEditedObjInfo.setTodModified(True) self.ambientLabel['text'] = '\n%.4s | %.4s | %.4s' % (vColor[0], vColor[1], vColor[2]) return
def checkButtonsForChange(self): changedColor = Vec4(0.0, 255.0, 255.0, 255.0) defaultColor = Vec4(255.0, 255.0, 255.0, 255.0) if self.editor: alteredTODs = self.todMgr.listAlteredTODs(TODGlobals.ENV_DATAFILE) else: alteredTODs = self.todMgr.listAlteredTODs(self.todMgr.environment) for key in self.todButtonDict: button = self.todButtonDict[key] text = TODGlobals.StateDict.get(key) if text: if text in alteredTODs: button['bg'] = getTkColorString(self.changedColor) else: button['bg'] = getTkColorString(self.defaultColor) text in alteredTODs frontSwitch = self.todMgr.lightSwitch[0] ambientSwitch = self.todMgr.lightSwitch[1] backSwitch = self.todMgr.lightSwitch[2] self.frontSwitchVar.set(frontSwitch) self.ambientSwitchVar.set(ambientSwitch) self.backSwitchVar.set(backSwitch) self.fogTypeVar.set(self.todMgr.fogType) self.todSkyTypeVar.set(int(self.todMgr.skyGroup.lastSky)) alteredTODs = self.todMgr.listAlteredTODs(self.todMgr.environment) alteredTime = 0 stateId = self.todMgr.currentState for entry in alteredTODs: if entry == stateId: alteredTime = 1 continue if alteredTime or self.selectedCycleDuration == 0 or 1: self.removeChanges['state'] = 'normal' else: self.removeChanges['state'] = 'disabled'
def setFogType(self): if not self.changesEnabled: return None newFogType = self.fogTypeVar.get() fogType = self.todMgr.fogType todState = self.todVar.get() if fogType != newFogType: button = self.todButtonDict.get(todState) if button: button['bg'] = getTkColorString(self.uncommitedColor) self.saveChanges['state'] = 'normal' self.todMgr.setFogType(newFogType) self.repackFog()
def setFogRangeVec(self, range): if not self.changesEnabled: return self.todMgr.setFogExpDensity(range[0]) todState = self.todVar.get() if self.holdFogExp != range[0]: if self.holdFogExp != None: button = self.todButtonDict.get(todState) if button: button['bg'] = getTkColorString(self.uncommitedColor) self.holdFogExp = range[0] self.saveChanges['state'] = 'normal' if (self.editor and self).editor.TODPanelLoaded: self.editor.objectMgr.currEditedObjInfo.setTodModified(True) return
def setSunDirection(self, direction): if not self.changesEnabled: return todState = self.todVar.get() newDirection = Vec3(direction[0], direction[1], direction[2]) direction = newDirection self.todMgr.skyGroup.setSunTrueAngle(direction) if self.holdSunDirection != direction: if self.holdSunDirection != None: button = self.todButtonDict.get(todState) if button: button['bg'] = getTkColorString(self.uncommitedColor) self.holdSunDirection = direction self.saveChanges['state'] = 'normal' if (self.editor and self).editor.TODPanelLoaded: self.editor.objectMgr.currEditedObjInfo.setTodModified(True) return
def setFogRangeVec(self, range): if not self.changesEnabled: return None self.todMgr.setFogExpDensity(range[0]) todState = self.todVar.get() if self.holdFogExp != range[0]: if self.holdFogExp != None: button = self.todButtonDict.get(todState) if button: button['bg'] = getTkColorString(self.uncommitedColor) self.holdFogExp = range[0] self.saveChanges['state'] = 'normal' if self.editor and self.editor.TODPanelLoaded: self.editor.objectMgr.currEditedObjInfo.setTodModified(True)
def switchBack(self): if not self.changesEnabled: return None backSwitch = self.backSwitchVar.get() lightSwitch = self.todMgr.lightSwitch newSwitch = [ lightSwitch[0], lightSwitch[1], backSwitch] todState = self.todVar.get() if lightSwitch != newSwitch: button = self.todButtonDict.get(todState) if button: button['bg'] = getTkColorString(self.uncommitedColor) self.saveChanges['state'] = 'normal' self.todMgr.setLightSwitch(newSwitch)
def setFogLinearRange(self, range): if not self.changesEnabled: return self.todMgr.setLinearFogOnset(range[0]) self.todMgr.setLinearFogPeak(range[1]) todState = self.todVar.get() if self.holdLinearRanges != (range[0], range[1]): if self.holdLinearRanges != None: button = self.todButtonDict.get(todState) if button: button['bg'] = getTkColorString(self.uncommitedColor) self.holdLinearRanges = ( range[0], range[1]) self.saveChanges['state'] = 'normal' if (self.editor and self).editor.TODPanelLoaded: if not self.editor.switchingToDrive: self.todMgr.linearFog.setLinearRange(range[0], range[1]) self.editor.objectMgr.currEditedObjInfo.setTodModified(True) return
def setSunDirection(self, direction): if not self.changesEnabled: return None todState = self.todVar.get() newDirection = Vec3(direction[0], direction[1], direction[2]) direction = newDirection self.todMgr.skyGroup.setSunTrueAngle(direction) if self.holdSunDirection != direction: if self.holdSunDirection != None: button = self.todButtonDict.get(todState) if button: button['bg'] = getTkColorString(self.uncommitedColor) self.holdSunDirection = direction self.saveChanges['state'] = 'normal' if self.editor and self.editor.TODPanelLoaded: self.editor.objectMgr.currEditedObjInfo.setTodModified(True)
def setFogLinearRange(self, range): if not self.changesEnabled: return None self.todMgr.setLinearFogOnset(range[0]) self.todMgr.setLinearFogPeak(range[1]) todState = self.todVar.get() if self.holdLinearRanges != (range[0], range[1]): if self.holdLinearRanges != None: button = self.todButtonDict.get(todState) if button: button['bg'] = getTkColorString(self.uncommitedColor) self.holdLinearRanges = (range[0], range[1]) self.saveChanges['state'] = 'normal' if self.editor and self.editor.TODPanelLoaded: if not self.editor.switchingToDrive: self.todMgr.linearFog.setLinearRange(range[0], range[1]) self.editor.objectMgr.currEditedObjInfo.setTodModified(True)
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 = 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
def getTkColorFromVec4(self, v, mult = 255): return getTkColorString([ int(v[0] * mult), int(v[1] * mult), int(v[2] * mult)])
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)
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 = 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
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)
def getTkColorFromVec4(self, v, mult=255): return getTkColorString([int(v[0] * mult), int(v[1] * mult), int(v[2] * mult)])