def adjustBackground(*args):
    """
	Get the camera that is assigned to the current view.
	"""
    if not stereoCameraUtil.runCallbackChecks():
        return
    editor = ''
    if len(args):
        editor = args[0]
    else:
        panel = cmds.getPanel(withFocus=True)
        editor = panel + 'Editor'

    result = cmds.stereoCameraView(editor, query=True, viewColor=True)
    result = cmds.colorEditor(
        alpha=float(result[3]),
        rgbValue=[float(result[0]),
                  float(result[1]),
                  float(result[2])])
    buffer = result.split()
    if '1' == buffer[3]:
        values = cmds.colorEditor(query=True, rgb=True)
        alpha = cmds.colorEditor(query=True, alpha=True)
        cmds.stereoCameraView(
            editor,
            edit=True,
            viewColor=[values[0], values[1], values[2], alpha],
            useCustomBackground=True)
 def light_color_state(self, widget, attribute_label_text):
     cmds.colorEditor()
     if cmds.colorEditor(query=True, result=True):
         RGB_values = cmds.colorEditor(query=True, rgb=True)
         #print "RGB = " + str(RGB_values)
         r = RGB_values[0]
         g = RGB_values[1]
         b = RGB_values[2]
         RGB_values_tuple = (r, g, b)
     if attribute_label_text == 'lightColor':
         cmds.setAttr((self.current_chosen_light + ".lightColor"),
                      r,
                      g,
                      b,
                      type="double3")
     if attribute_label_text == 'rectText':
         cmds.setAttr((self.current_chosen_light + ".rectTex"),
                      r,
                      g,
                      b,
                      type="double3")
     r = (r * 255)
     g = (g * 255)
     b = (b * 255)
     color_string = "rgb(" + str(r) + "," + str(g) + "," + str(b) + ")"
     widget.setStyleSheet("QPushButton { background-color: %s}" %
                          color_string)
     return (RGB_values_tuple)
 def changecolor(self):
     global lastshader
     mc.colorEditor()
     rgb = mc.colorEditor(query=True, rgb=True)
     print 'RGB = ' + str(values)
     if rgb:
         mc.setAttr(lastshader + '.color', rgb[0], rgb[1], rgb[2])
Exemple #4
0
 def createEditor(self, _, __, index):
     dynamic_node = self._model.data(index, QtCore.Qt.UserRole)
     red, green, blue = map(float, cmds.colorEditor().split()[:3])
     if cmds.colorEditor(query=True, result=True) is False:
         return
     dynamic_node.set_color(red, green, blue)
     return
Exemple #5
0
 def pushButton_hit(self):
     original_color=self.attr.get()
     cmds.colorEditor(rgbValue=[original_color[0],original_color[1],original_color[2]])
     if cmds.colorEditor(query=True, result=True):
         values = cmds.colorEditor(query=True, rgb=True)
         self.attr.set(values)
         self.setSliderValue()
         self.setPushButtonColor()
Exemple #6
0
def colorPicker(light, index, *args):
	sel_light = cmds.listRelatives(cmds.textField(light + 'name', q=True, tx=True), s=True)[0]
	currColor = cmds.getAttr(sel_light + '.color')
	cmds.colorEditor(rgbValue=currColor[0])
	if cmds.colorEditor(query=True, result=True):
		values = cmds.colorEditor(query=True, rgb=True)
		cmds.setAttr(sel_light + '.color', *values)
		cmds.canvas(swatches[index], e=True, rgbValue=cmds.getAttr(sel_light + '.color')[0])
Exemple #7
0
 def set_color_from_dialogbox(self):
     cmds.colorEditor(rgb=[c / 255.0 for c in self.color])
     if not cmds.colorEditor(query=True, result=True):
         return
     r, g, b = [
         int(c * 255) for c in cmds.colorEditor(query=True, rgb=True)
     ]
     self.set_color(r, g, b)
    def set_button_color(self):
        cmds.colorEditor()
        if cmds.colorEditor(query=True, result=True):
            color = cmds.colorEditor(query=True, rgb=True)
            color_normalized = [value * 255 for value in color]
            if color_normalized != self.current_button_color:
                self._force_button_update(color=color_normalized)

            self.current_button_color = color_normalized
            self.current_assign_color = color
Exemple #9
0
 def _editColor(self):
     color = utility.LineartosRGB(
         cmds.canvas('colorDisplay', q=1, rgbValue=1))
     cmds.colorEditor(rgb=color)
     if cmds.colorEditor(query=True, result=True):
         rgbV = cmds.colorEditor(query=True, rgb=True)
         rgbV = utility.sRGBtoLinear(rgbV)
         cmds.canvas('colorDisplay', e=1, rgbValue=rgbV)
         functions.applyCurvesColor(utility.LineartosRGB(rgbV))
     else:
         print('Editor was dismissed')
Exemple #10
0
def Color(ButtonColor):
    couleurEditor = cmds.colorEditor()
    couleur = cmds.colorEditor(q=True, rgb=True)
    R = couleur[0]
    V = couleur[1]
    B = couleur[2]

    cmds.button(ButtonColor,
                edit=True,
                bgc=[couleur[0], couleur[1], couleur[2]],
                w=400)

    return R, V, B
Exemple #11
0
def color_picker(light, index, *args):
    """brings up the color picker UI to select a color for a light"""
    sel_light = cmds.listRelatives(cmds.textField(light + 'name',
                                                  q=True,
                                                  tx=True),
                                   s=True)[0]
    curr_color = cmds.getAttr(sel_light + '.color')
    cmds.colorEditor(rgbValue=curr_color[0])
    if cmds.colorEditor(query=True, result=True):
        values = cmds.colorEditor(query=True, rgb=True)
        cmds.setAttr(sel_light + '.color', *values)
        cmds.canvas(swatches[index],
                    e=True,
                    rgbValue=cmds.getAttr(sel_light + '.color')[0])
Exemple #12
0
 def get_color_from_editor(self, *args):
     u"""colorEditorから色を得る"""
     res = cmds.colorEditor()
     if "1" != res.split()[3]:
         return
     result = cmds.colorEditor(query=True, rgb=True)
     decimal_point = cmds.intFieldGrp(self.decimal_point_field,
                                      q=True,
                                      v1=True)
     r = round(result[0], decimal_point)
     g = round(result[1], decimal_point)
     b = round(result[2], decimal_point)
     bgc = self._COLOR_FORMAT.format(str(r), str(g), str(b))
     cmds.textFieldGrp(self.result_field, e=True, tx=bgc)
     cmds.text(self.color_preview, e=True, bgc=[r, g, b])
Exemple #13
0
 def show_color_editor(self):
     if dcc.is_maya():
         import maya.cmds as cmds
         cmds.colorEditor(rgbValue=(self._color.redF(),
                                    self._color.greenF(),
                                    self._color.blueF()))
         if not cmds.colorEditor(query=True, result=True):
             return
         new_color = cmds.colorEditor(query=True, rgbValue=True)
         self.color = QColor.fromRgbF(new_color[0], new_color[1],
                                      new_color[2])
         self.colorChanged.emit()
     else:
         raise RuntimeError(
             'Code Editor is not available for DCC: {}'.format(
                 dcc.get_name()))
 def on_custom_color_change(self):
     btn = None
     for button in self.custom_buttons:
         if button.isChecked():
             btn = button
             break
     if not btn:
         om.MGlobal.displayWarning("No swatch selected. Please select one.")
     # Turn off color management temporarily before opening colorEditor
     else:
         cmds.colorManagementPrefs(e=True, cme=False)
         color_pick = cmds.colorEditor()
         values = cmds.colorEditor(query=True, rgb=True)
         btn.color = values
         all_buttons = self.update_color_buttons()
         cmds.colorManagementPrefs(e=True, cme=True)
Exemple #15
0
 def kPipette(self):
     shPrefix = mc.textField(self.shPrefix, text=True, q=True)
     shSuffix = mc.textField(self.shSuffix, text=True, q=True)
     shType = self.initShaderType()
     self.pickColor += 1
     colorName = shPrefix + "Picker" + shType + str(
         self.pickColor) + shSuffix
     selectionList = mc.ls(selection=True, type="transform")
     if selectionList:
         mc.colorEditor(mini=False)
         kColor = mc.colorEditor(query=True, rgb=True)
         self.applyShaderColor(name=colorName,
                               R=kColor[0],
                               G=kColor[1],
                               B=kColor[2])
     else:
         print ">> No selection"
Exemple #16
0
    def mouseReleaseEvent(self, event):
        """
		triggered by clicking
		"""

        #create maya color editor
        self.colorMenu = mc.colorEditor(rgb=(self.rgb[0], self.rgb[1],
                                             self.rgb[2]))

        #get value maya color editor
        if mc.colorEditor(query=1, result=1):

            self.rgb = mc.colorEditor(query=1, rgb=1)
            self.check()
            self.setColor()

        super(UnPicker_SelectColorUI, self).mouseReleaseEvent(event)
    def mayaColorPicker(self):
        """Open maya color picker"""
        cmds.colorEditor()
        if cmds.colorEditor(query=True, result=True):
            value = []
            values = cmds.colorEditor(query=True, rgb=True)
            value.append(values[0])
            value.append(values[1])
            value.append(values[2])

            if self.colorType == PropertyWidget.RGBA:
                value.append(color.alphaF())

            self.controller.mainEditor.propertyChanged(
                dict(propname=self.paramName, default=False, value=value))
            color = QColor(value[0] * 255, value[1] * 255, value[2] * 255)
            self.updatePalette(color)
            self.suspended_color = self.colorBtn.palette()
Exemple #18
0
def pickColor():
    # open color picker
    result = cmds.colorEditor()
    buffer = result.split()
    # if done picking a color, get the colors values
    if '1' == buffer[3]:
        values = cmds.colorEditor(query=True, rgb=True)
        # picked colors become markRGB plus rounded markup
        rFloat = values[0]
        gFloat = values[1]
        bFloat = values[2]

        rPick = round(rFloat * 255)
        gPick = round(gFloat * 255)
        bPick = round(bFloat * 255)

        return rPick, gPick, bPick
    else:
        print 'Editor was dismissed'
def pickColor():
    # open color picker
    result = cmds.colorEditor()
    buffer = result.split()
    # if done picking a color, get the colors values
    if '1' == buffer[3]:
        values = cmds.colorEditor(query=True, rgb=True)
        # picked colors become markRGB plus rounded markup
        rFloat = values[0]
        gFloat = values[1]
        bFloat = values[2]

        rPick = round(rFloat * 255)
        gPick = round(gFloat * 255)
        bPick = round(bFloat * 255)

        return rPick, gPick, bPick
    else:
        print 'Editor was dismissed'
    def setColor(self, widget):
        '''Sets the color of all the lights in the rig'''
        lightColor = self.getAttr('color')[0]
        color = cmd.colorEditor(rgbValue=lightColor)
        r, g, b, a = [float(c) for c in color.split()]
        color = (r, g, b)

        for i in self.info.keys():
            cmd.setAttr('%s.color' % i, r, g, b)
        self.setButtonColor(widget, color)
Exemple #21
0
    def color(self, button, *args):
        """
        change color of button
        """
        result = cmds.colorEditor()
        color = result.split(" ")
        color = [float(x) for x in color if x]
        color = color[:-1]

        cmds.button(button, e=True, backgroundColor=color)

        return color
Exemple #22
0
    def showColorEditor(self, *args):

        rgbaColor = cmds.colorEditor()

        test = rgbaColor.split("  ")
        color_R = test[0]
        color_G = test[1]
        color_B = test[2].partition(" ")[0]

        cmds.canvas(self.widgets["swatch"],
                    edit=1,
                    rgbValue=(float(color_R), float(color_G), float(color_B)))
Exemple #23
0
 def colorConnectedDoubleClick(self, widget):
     # todo: add to button under double click, this version differs in the mini=False cmds flag
     pos = QtGui.QCursor.pos()
     rgb = colour.rgbIntToFloat(self._color)
     posX = pos.x() + utils.dpiScale(-220)
     posY = pos.y() + utils.dpiScale(-130)
     linearColorResult = cmds.colorEditor(mini=False,
                                          position=[posX, posY],
                                          rgbValue=rgb[:3])
     linearColorResult = linearColorResult.strip().replace("  ",
                                                           " ").split(" ")
     linearColorResult = map(float, linearColorResult)
     rgbColorResult = colour.convertColorLinearToSrgb(
         linearColorResult)  # color is 0-1 float style
     self.setColorSrgbInt(
         colour.rgbFloatToInt(rgbColorResult))  # expects 255 color style
def set_control_color(rgb_input, input_object=None):
    """
    Sets an override color value to an object or shape node for the purpose of
    distinctions of controls in a rig.

    Args:
        rgb_input (str) or (list[float, float, float]): Assigns a color value to
            set for a shape node.  If string, it must be compatible with the
            keys in rgb_dictionary.  If list, it must have 3 float values that
            correspond with the desired color values in range 0 to 1.
        input_object (str): Object/Shape name that is being affected.  Shape
            nodes will perform best.

    """
    if not input_object:
        input_object = cmds.ls(selection=True)[0]
    # setting the color value based on the passed argument
    if type(rgb_input) is list:
        if len(rgb_input) != 3:
            cmds.warning('Color value input list is not the proper size!  '
                         'Input 3 floats between 0 and 1 to assign a color.')
            return
        rgb = rgb_input
    elif rgb_input in rgb_actuals:
        rgb = rgb_actuals[rgb_input]
    else:
        # This condition will only work when called directly, never when called
        # from the add_curve_shape function
        rgb = cmds.colorEditor(query=True, rgb=True)

    if type(input_object) is list:
        for shape in input_object:
            cmds.setAttr(shape + '.overrideEnabled', 1)
            cmds.setAttr(shape + '.overrideRGBColors', 1)
            cmds.setAttr(shape + '.overrideColorR', rgb[0])
            cmds.setAttr(shape + '.overrideColorG', rgb[1])
            cmds.setAttr(shape + '.overrideColorB', rgb[2])
    else:
        cmds.setAttr(input_object + '.overrideEnabled', 1)
        cmds.setAttr(input_object + '.overrideRGBColors', 1)
        cmds.setAttr(input_object + '.overrideColorR', rgb[0])
        cmds.setAttr(input_object + '.overrideColorG', rgb[1])
        cmds.setAttr(input_object + '.overrideColorB', rgb[2])
    def setColor(self, Btn=None):
        # 获取灯光的颜色
        styleSheet = self.IK_CTRL_ColorBtn.styleSheet().split("(")[1].split(
            ",")
        r = float(styleSheet[0]) / 255
        g = float(styleSheet[1]) / 255
        b = float(styleSheet[2].split(")")[0]) / 255
        Btn_Color = (r, g, b)

        # 打开 Maya 的颜色编辑器
        color = cmds.colorEditor(rgbValue=Btn_Color)

        # Maya 返回了字符串
        # 我们需要手动将其转换为可用的变量
        r, g, b, a = [float(c) for c in color.split()]

        # 设置新的颜色值
        Btn.setStyleSheet('background-color:rgb(%s,%s,%s)' %
                          (r * 255, g * 255, b * 255))
        self.Save_Json_File()
Exemple #26
0
 def colorConnected(self, widget):
     # todo: the window position should compensate if on the edge of the screen.
     self.colorClicked.emit()
     if self.disableState:
         return
     pos = QtGui.QCursor.pos()
     srgb = colour.rgbIntToFloat(self._color)
     linearRgb = colour.convertColorSrgbToLinear(srgb)
     posX = pos.x() + utils.dpiScale(-220)
     posY = pos.y() + utils.dpiScale(-130)
     linearColorResult = cmds.colorEditor(mini=True,
                                          position=[posX, posY],
                                          rgbValue=linearRgb[:3])
     linearColorResult = linearColorResult.strip().replace("  ",
                                                           " ").split(" ")
     linearColorResult = [float(i) for i in linearColorResult]
     rgbColorResult = colour.convertColorLinearToSrgb(
         linearColorResult)  # color is 0-1 float style
     self.setColorSrgbInt(
         colour.rgbFloatToInt(rgbColorResult))  # expects 255 color style
import maya.cmds as cmds
cmds.colorEditor()
uis = []
#rgbCol =  []
targetWindows = ["MayaWindow"] #'mainWindow', 'graphEditor', 
if cmds.colorEditor(q=1, result=1): 
    rgbCol = cmds.colorEditor(q=1, rgb=1)
    uis = cmds.lsUI(windows=1)
    print uis
for ui in uis:
    if any([t in ui for t in targetWindows]):
        print t
        cmds.window(ui, e=1, bgc=rgbCol)
Exemple #28
0
def change_theme(theme, USERPATH):

    PATH_ICONS = USERPATH + r"\icon"
    sys.path.append(USERPATH)
    sys.path.append(PATH_ICONS)

    theme_color = [0.286, 0.286, 0.286]
    analogue_color = [0.2, 0.2, 0.2]
    complementary_color = [0.792, 0.195, 0.203]
    theme_code = ""

    # THEME VALUES:
    # *********************************************************************
    if theme == "day":
        theme_color = [0.63, 0.80, 0.85]
        analogue_color = [1, 0.98, 0.9]
        complementary_color = [0.96, 0.58, 0.11]
        theme_code = "theme01_"

    elif theme == "night":
        theme_color = [0.03, 0.14, 0.25]
        analogue_color = [0.1, 0.29, 0.45]
        complementary_color = [0.12, 0.44, 0.65]
        theme_code = "theme02_"

    # User Settings parameter:
    # ***************************************************
    elif theme == "user":
        cmds.colorEditor()
        if cmds.colorEditor(query=True, rgb=True):
            r, g, b = cmds.colorEditor(query=True, rgb=True)
        else:
            cmds.warning("Process Delete")

        # distribute colors:
        # *******************************
        if r + g + b <= 0.4:
            theme_color = [r, g, b]
            analogue_color = [(r + 0.1) * 2, (g + 0.1) * 2, (b + 0.1) * 2]
            complementary_color = [(r + 0.1) * 4, (g + 0.1) * 4, (b + 0.1) * 4]
            theme_code = "theme04_"

        elif r + g + b >= 2.4:
            theme_color = [r * 0.7, g * 0.7, b * 0.7]
            analogue_color = [r * 0.8, g * 0.8, b * 0.8]
            complementary_color = [r * 0.55, g * 0.55, b * 0.55]
            theme_code = "theme03_"

        else:
            theme_color = [r / 2, g / 2, b / 2]
            analogue_color = [r, g, b]
            complementary_color = [r * 2, r * 2, r * 2]
            theme_code = "theme03_"

    # CHANGE BUTTONS THEME:
    # ********************************************************************
    buttons = [
        "button_day", "button_night", "button_user", "button_default",
        "useless_stuff_button", "useless_random_button", "useless_credits",
        "useless_number"
    ]

    for button in buttons:
        path_icon = cmds.iconTextButton(button, query=True, image=True)

        if path_icon:
            icon = path_icon.split("\\")[-1]
            if "theme" in icon:
                icon = icon.replace("theme", "")[3:]
            cmds.iconTextButton(button,
                                edit=True,
                                backgroundColor=analogue_color,
                                image=PATH_ICONS + "\\" + theme_code + icon)

        else:
            cmds.iconTextButton(button,
                                edit=True,
                                backgroundColor=analogue_color)

    # CHANGE OTHER UI ELEMENTS:
    # ********************************************************************
    separators = [
        "theme_separator", "title_separator", "stuff_separator",
        "buttons_separator", "end_separator"
    ]

    for separator in separators:
        cmds.separator(separator, query=True, backgroundColor=True)
        cmds.separator(separator,
                       edit=True,
                       backgroundColor=complementary_color)

    # CHANGE MAIN WINDOW UI ELEMENTS:
    # ********************************************************************
    cmds.formLayout("useless_form_layout", query=True, backgroundColor=True)
    cmds.formLayout("useless_form_layout",
                    edit=True,
                    backgroundColor=theme_color)
Exemple #29
0
from maya import cmds

'''
This script is for coloring nurbs controllers,
as there could be various of shape under the 
nurbs obj. Manual functions is not effecient.
-Junru Tao 2021
'''
def setRGBColor(shape, color = (1,1,1,1)):
    rgb = ("R","G","B")
    cmds.setAttr(shape + ".overrideEnabled",1)
    cmds.setAttr(shape + ".overrideRGBColors",1)
    for channel, color in zip(rgb, color):
        cmds.setAttr(shape + ".overrideColor%s" %channel, color)

cmds.colorEditor()
if cmds.colorEditor(query=True, result=True):
    values = cmds.colorEditor(query=True, rgb=True)
    print str(values)
    sel = cmds.ls(selection=True)
    shapes = ()
    if sel:
        shapes = cmds.listRelatives(sel[0],shapes=True)
        if shapes:
            for item in shapes:
                full_name = sel[0] + "|" + item
                setRGBColor(full_name,values)
        else:
            print "[Error] No shapes in this object"
    else:
        print "[Error] No selection"
Exemple #30
0
	def applyColor2(self, *args):
		tempVal = cmds.colorEditor(rgb=[1,0,0])
		tempColors = [float(x) for x in tempVal.split()]
		self.colorVal = tempColors[0:3]
		if( tempColors[-1] ):
			cmds.button(self.btnName, edit=True, bgc=self.colorVal)
 def SelectColor(self):
     cmds.colorEditor()
     if cmds.colorEditor(query = True, result = True):
         self.RGBValues = cmds.colorEditor(query = True, rgb = True)
         print(self.RGBValues)
 def applyColor2(self, *args):
     tempVal = cmds.colorEditor(rgb=[1, 0, 0])
     tempColors = [float(x) for x in tempVal.split()]
     self.colorVal = tempColors[0:3]
     if tempColors[-1]:
         cmds.button(self.btnName, edit=True, bgc=self.colorVal)
Exemple #33
-1
def color_picker(light, index, *args):
    """brings up the color picker UI to select a color for a light"""
    sel_light = cmds.listRelatives(cmds.textField(light + 'name', q=True, tx=True), s=True)[0]
    curr_color = cmds.getAttr(sel_light + '.color')
    cmds.colorEditor(rgbValue=curr_color[0])
    if cmds.colorEditor(query=True, result=True):
        values = cmds.colorEditor(query=True, rgb=True)
        cmds.setAttr(sel_light + '.color', *values)
        cmds.canvas(swatches[index], e=True, rgbValue=cmds.getAttr(sel_light + '.color')[0])
Exemple #34
-1
 def updateColour2(self):
     '''
     Opens a colour picker to allow the user to select a colour for the 1nd canvas
     '''
     cmds.colorEditor(rgb=cmds.canvas(self.colour2,q=1,rgb=1))
     if cmds.colorEditor(q=1,r=1):
         rgb=cmds.colorEditor(q=1,rgb=1)
         cmds.canvas(self.colour2,e=1,rgb=rgb)
     else:
         return