Issues

Issue #504 wontfix

Consistent color setting

hahawoo
created an issue

It might be neat if ParticleSystem:setColors and ImageData:setPixel could...

  • Accept tables of RGBA values, with alpha defaulting to 255 if not in the table (perhaps one table per color for ParticleSystem:setColors).
  • Use 255 as the default alpha value when called with numbers (probably wouldn't work with more than one color for ParticleSystem:setColors).

Comments (5)

  1. vrld

    You can use http://www.lua.org/manual/5.1/manual.html#pdf-unpack">unpack():

    navy_blue = {0, 0, 128} -- notice the missing alpha value
    spritebatch:setColor(unpack(navy_blue))
    imagedata:setPixel(x,y, unpack(navy_blue))
    
    rainbow = {
        255, 0, 0, 255, -- red
        255, 127, 0, 255, -- orange
        255, 255, 0, 255, -- yellow
        0, 255, 0, 255, -- green
        0, 0, 255, 255, -- blue
        75, 0, 130, 255, -- indigo
        143, 0, 255, 255, -- violet
    }
    particlesys:setColors(unpack(rainbow))
    
  2. hahawoo reporter

    love.graphics.setBackgroundColor and SpriteBatch:setColor (#459) accept arrays too.

    Also, ImageData:setPixel doesn't have a default alpha value.

    And, just to note, there would be a subtle difference in behavior with ParticleSystem:setColors with what I would suggest, which wouldn't be equivalent to unpacking everything:

    ps:setColors(c1, c2)
    

    would be equivalent to...

    ps:setColors(c1[1], c1[2], c1[3], c1[4] or 255, c2[1], c2[2], c2[3], c2[4] or 255)
    
  3. Log in to comment