Go to: Synopsis. Return value. Flags. MEL examples.

Synopsis

colorEditor [-alpha float] [-hsvValue float float float] [-mini] [-parent string] [-position int int] [-result] [-rgbValue float float float]

colorEditor is undoable, queryable, and NOT editable.

The colorEditor command displays a modal dialog that may be used to specify colors in RGB or HSV. The default behaviour when no arguments are specified is to provide an initial color of black (rgb 0.0 0.0 0.0).

The command will return the user's color component values along with a boolean to indicate whether the dialog was dismissed by pressing the "OK" button. As an alternative to responding to the colorEditor command's return string you can now query the -rgb/rgbValue, -hsv/hsvValue, and -r/result flags to get the same information.

Return value

stringThe string format is "float float float boolean". The first three float values correspond to the color components.

The final argument is 1 if the dialog's "OK" button was pressed, and 0 if the "Cancel" button was pressed.

In query mode, return type is based on queried flag.

Flags

alpha, hsvValue, mini, parent, position, result, rgbValue
Long name (short name) Argument types Properties
-alpha(-a) float createquery
Float values corresponding to the alpha transparency component, , which ranges from 0.0 to 1.0. Use this flag to specify the initial alpha value of the Color Editor, or query this flag to determine the alpha value set in the editor.
-hsvValue(-hsv) float float float createquery
Three float values corresponding to the hue, saturation, and value color components, where the hue value ranges from 0.0 to 360.0 and the saturation and value components range from 0.0 to 1.0. Use this flag to specify the initial color of the Color Editor, or query this flag to determine the color set in the editor.
-mini(-m) create
Enable the mini color editor mode.
-parent(-p) string create
Specify the parent window for the dialog. The dialog will be centered on this window and raise and lower with it's parent. By default, the dialog is not parented to a particular window and is simply centered on the screen.
-position(-pos) int int create
Specify the window position for the dialog.
-result(-r) query
This query only flag returns true if the dialog's "OK" button was pressed, false otherwise. If you query this flag immediately after showing the Color Editor then it will return the same value as the boolean value returned in the colorEditor command's return string.
-rgbValue(-rgb) float float float createquery
Three float values corresponding to the red, green, and blue color components, all of which range from 0.0 to 1.0. Use this flag to specify the initial color of the Color Editor, or query this flag to determine the color set in the editor.

Flag can appear in Create mode of command Flag can appear in Edit mode of command
Flag can appear in Query mode of command Flag can be used more than once in a command.

MEL examples

//    Example 1.
//
colorEditor;
if (`colorEditor -query -result`) {
    float $values[];
    $values = `colorEditor -query -rgb`;
    print ("RGB = " + $values[0] + " " + $values[1] + " " + $values[2] + "\n");
    $values = `colorEditor -query -hsv`;
    print ("HSV = " + $values[0] + " " + $values[1] + " " + $values[2] + "\n");

} else {
    print ("Editor was dismissed\n");
}

//    Example 2.
//
string $result, $buffer[];
$result = `colorEditor`;
tokenize($result, $buffer);
if ("1" == $buffer[3]) {
    print ("RGB = " + $buffer[0] + " " + $buffer[1] + " " + $buffer[2] + "\n");

} else {
    print ("Editor was dismissed\n");
}