Wavelenght color in lua

  • Ligan
    20th Feb 2017 Member 0 Permalink

    Is it possible to exactly replicate, in lua, the color spectrum of photons into an elemnt ?

    I tried before but the colors are not accurate :

    Below is FILT, above is my element with the same ctype. I don't understand why it only works with certain colors.

  • LBPHacker
    20th Feb 2017 Developer 0 Permalink

    I don't see why it wouldn't be possible. Maybe show us some code?

  • Ligan
    20th Feb 2017 Member 0 Permalink

    http://pastebin.com/1HpJuDNV

     

    It's basically a translation from BIZR's update transition, but here you go.

    Edited 2 times by Ligan. Last: 20th Feb 2017
  • LBPHacker
    20th Feb 2017 Developer 0 Permalink

    Well, it's not a *perfect* translation, and r/g/b aren't local to anything and are not reset to 0 either (derp). One of those will be the cause of the problem.

     

    Yep, once you translate the += part properly, the result looks the same as FILT.

    for x = 0, 11 do
        r = r + bit.band(bit.rshift(ctype, x + 18), 1)
        g = g + bit.band(bit.rshift(ctype, x +  9), 1)
        b = b + bit.band(bit.rshift(ctype, x     ), 1)
    end

    Edited 3 times by LBPHacker. Last: 20th Feb 2017
  • jacob1
    20th Feb 2017 Developer 0 Permalink
    @LBPHacker (View Post)
    r, g, and b are passed into the graphics function. That's because it used to be difficult to get the rgb out of the hex color before we had bit functions or gfx.getColors