https://en.wikipedia.org/wiki/RGB_color_model#Numeric_representations

Maya's color values are floating point (as far as I know)

On Mon, Oct 5, 2015 at 10:27 AM Crest Christopher <
[email protected]> wrote:

> How do you know what color 0,0,1.0 is ?
>
> Justin Israel wrote:
>
> The switch statement has some limitations for your application. You can’t
> use an array as a switch expression, and you can’t use vector variables as
> switch cases…
>
> Vector with switch:
>
> vector $myColor = <<0, 0, 1.0>>;
>
> switch ($myColor){
>     case <<1.0, 0, 0>>:
>         print "RED!";
>         break;
>     case <<1.0, 1.0, 1.0>>:
>         print "WHITE!";
>         break;
>
>     case <<0, 0, 1.0>>:
>         print "'merica!";
>         break;
>
>     default:
>         print "nada.";
>         break;
>
> }
>
> Array with if-else:
>
> int $redColor[3] = {255, 0, 0};
> int $whiteColor[3] = {255, 255, 255};
>
> int $blueColor[3] = {0, 0, 255};
>
> $myColor2 = $blueColor;
>
> // Because I barely know MEL these days and I don't know
> // a better way to compare int arrays.
> proc int equalColors(int $left[], int $right[]) {
>     if (size($left) != 3) {
>         return false;
>     }
>     if (size($right) != 3) {
>         return false;
>     }
>
>     int $i;
>     for ($i=0; $i < 3; $i++) {
>         if ($left[$i] != $right[$i]) {
>             return false;
>         }
>     }
>     return true;
> }
>
> if (equalColors($myColor2, $redColor)) {
>     print "RED!";
> } else if (equalColors($myColor2, $whiteColor)) {
>     print "WHITE!";
> } else if (equalColors($myColor2, $blueColor)) {
>     print "'merica!";
> } else {
>     print "nada.";
> }
>
> You are probably better off with an if-else.
>
> Justin
>
> On Mon, Oct 5, 2015 at 8:27 AM Christopher. [email protected]
> <http://mailto:[email protected]> wrote:
>
>> The color values should be in an array ?
>> $color = [22,204,61],[34,56,165];
>>
>>
>> On Sunday, October 4, 2015 at 2:51:55 PM UTC-4, Justin Israel wrote:
>>
>>> Arrays:
>>>
>>> http://download.autodesk.com/global/docs/maya2014/en_us/files/Arrays_vectors_and_matrices_Arrays.htm
>>>
>>> Vectors:
>>>
>>> http://download.autodesk.com/global/docs/maya2014/en_us/index.html?url=files/Arrays_vectors_and_matrices_Vectors.htm,topicNumber=d30e790326
>>>
>>> On Mon, 5 Oct 2015 7:15 AM Christopher. <[email protected]> wrote:
>>>
>>>> I want to change the color of a sphere using Switch in MEL this is what
>>>> I have thus far, it is not working ?
>>>>
>>>> Can you store RGB values in a int ?
>>>>
>>>> string $obj_sphere = pSphere1;
>>>> int $color = 22, 204, 61;
>>>> switch ($color) {
>>>>     case $obj_sphere: 104,160,60;
>>>>     break;
>>>>     }
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Python Programming for Autodesk Maya" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/python_inside_maya/c7e7983f-99f3-4ba2-805e-111f9c614144%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/python_inside_maya/c7e7983f-99f3-4ba2-805e-111f9c614144%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>> --
>> You received this message because you are subscribed to the Google Groups
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/python_inside_maya/3a3b5ef5-467d-47c4-9548-97e600f0ecef%40googlegroups.com
>> <https://groups.google.com/d/msgid/python_inside_maya/3a3b5ef5-467d-47c4-9548-97e600f0ecef%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> ​
> --
>
> You received this message because you are subscribed to a topic in the
> Google Groups "Python Programming for Autodesk Maya" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/python_inside_maya/Xxm27BNbA6s/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA262Aq812pPSDwgWJZcWZbGmpAo3%3DqDN8D%3DtccTqE4zbQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA262Aq812pPSDwgWJZcWZbGmpAo3%3DqDN8D%3DtccTqE4zbQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
>
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/5611999A.3040002%40gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/5611999A.3040002%40gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0dHd-RCUQ3NPCUmeEyTCBO8XDht1azCWev8iZC2N26Xg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to