Right, unpacking to 8 bit, sounds reasonable... :)

Now for the bonus question:
Does anybody know how to get a node's real note_font_colour?
If at default, it switches from dark to light depending on the tile_color but always returns 0 regardless. At least with the tile_color you can look up the default value via nuke.defaultNodeColor but I don't see any such method for the note_font_color. Alternatively, does anybody know what the logic behind the font colour switch is?

Cheers,
frank

On 28/12/15 8:44 pm, Ivan Busquets wrote:
Glad to hear!

And... come on! (0xFF & V >> 24) is pretty self explanatory, isn't it? :p

I can't even claim to fully understand it now, though it made sense at the time. The overall idea is that you're "unpacking" that 32 bit int, 8 bits at a time.

So, for RED, you're shifting those 32 bits 24 bits to the right (essentially leaving you with the first 8 bits only) , and then multiplying (bitwise AND) with an 8-bit white mask (0xFF). I think for the red channel you probably wouldn't even need this, as you are already left with only 8 bits, so probably don't need to mask anything (can't verify right now, though)

For GREEN, you're shifting 16 bits, meaning you have discarded the last 16 (blue and alpha), and you are left with green (first 8 bits) and red. Then you multiply this with an 8 bit mask (0xFF), which leaves you with just the 8 bits of the green channel (256 possible values), and divide by 255 to get it in a 0-1 range.

(same for blue, shifting only 8 bits to the right)

I *think* that's the gist of it, but it's been a while...

Cheers,
Ivan

On Sun, Dec 27, 2015 at 11:27 PM, Frank Rueter|OHUfx <[email protected] <mailto:[email protected]>> wrote:

    Sweet, thanks Ivan!
    I won't even try to understand this but it works.

    frank



    On 28/12/15 8:25 pm, Ivan Busquets wrote:
    Hey Frank,

    Found this buried inside some old backdrop-utilities module. I
    think it should work for what you're after.

    def TILEtoRGB(V):

        '''

        TILEtoRGB(V) -> tuple

        Returns a tuple representing Red, Green, and Blue values

        in a 0-1 range, from a 32 bit int as returned by the
    "tile_color" knob.

        Keyword arguments:

        V -- a 32 bit int as returned by the "tile_color" knob

        '''

        R = (0xFF & V >> 24) / 255.0

        G = (0xFF & V >> 16) / 255.0

        B = (0xFF & V >> 8) / 255.0

        return R,G,B

    Hope it helps!


    On Sun, Dec 27, 2015 at 11:11 PM, Frank Rueter|OHUfx
    <[email protected] <mailto:[email protected]>> wrote:

        Hi guys,

        after years of begrudgingly having to convert rgb to tile
        colour friendly values, I now need to do the opposite, i.e.
        take a tile color value and get rgb values from it.

        How do I do that?

        Cheers,
        frank


-- ohufxLogo 50x50 <http://www.ohufx.com> *vfx compositing
        <http://ohufx.com/index.php/vfx-compositing> | *workflow
        customisation and consulting
        <http://ohufx.com/index.php/vfx-customising>* *


        _______________________________________________
        Nuke-python mailing list
        [email protected]
        <mailto:[email protected]>,
        http://forums.thefoundry.co.uk/
        http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python




    _______________________________________________
    Nuke-python mailing list
    [email protected]
    
<mailto:[email protected]>,http://forums.thefoundry.co.uk/
    http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

-- ohufxLogo 50x50 <http://www.ohufx.com> *vfx compositing
    <http://ohufx.com/index.php/vfx-compositing> | *workflow
    customisation and consulting
    <http://ohufx.com/index.php/vfx-customising>* *


    _______________________________________________
    Nuke-python mailing list
    [email protected]
    <mailto:[email protected]>,
    http://forums.thefoundry.co.uk/
    http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python




_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

--
ohufxLogo 50x50 <http://www.ohufx.com> *vfx compositing <http://ohufx.com/index.php/vfx-compositing> | *workflow customisation and consulting <http://ohufx.com/index.php/vfx-customising>* *

_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to