Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Support for rgb/hsl colors? — Gideros Forum

Support for rgb/hsl colors?

piepie Member
edited March 2015 in General questions
Please someone correct me if I am wrong:

right now Gideros natively support only hex colors, and rgb only in Sprite:setColorTransform?

Thanks

Comments

  • hgy29hgy29 Maintainer
    Accepted Answer
    This is right as far as I can tell: gideros only handle RGB, either with separated components or with 0xrrggbb representation depending on the function.
  • piepie Member
    to whoever might be interested in colors ( @hgy29 maybe you might, since you're "the king of Shapes" to me :D)

    I just found something that seems wonderful:

    http://sputnik.freewisdom.org/lib/colors/


    just played with that a little, i'd say that there is only one requirement to let it work with gideros:
    --change
    module(..., package.seeall)
     
    --to 
     
    module("colorLib", package.seeall) --I wrote "colorLib", I suppose that a string is good as another. I am still trying to understand what should the ... operator do in that position.
    it doesn't export hex colors but should be just a temporary issue, until we find the right transformation function... rgb2hex()

    :)

    Likes: hgy29, MoKaLux

    +1 -1 (+2 / -0 )Share on Facebook
  • function rgbToHex(r,g,b)
    local hex=r*256*256+g*256+b
    return hex
    end

    Likes: pie, MoKaLux

    +1 -1 (+2 / -0 )Share on Facebook
  • and back:


    function hexToRgb(hex)
    local blue=hex%256
    local green=(hex-blue)/256 %256
    local red=(hex-blue-256*green)/256^2
    return red,green,blue
    end

    Likes: pie, MoKaLux

    +1 -1 (+2 / -0 )Share on Facebook
Sign In or Register to comment.