Page 1 of 4

Newbie Color Question

Posted: Mon Feb 07, 2011 11:47 pm
by chris-kun
When I load images, everything seems ok, but when I tell love to draw images, they all seem washed out, like the alpha has been lowered or something. any idea why this might be happening?

Re: Newbie Color Question

Posted: Mon Feb 07, 2011 11:51 pm
by BlackBulletIV
Could you show the code you're using. We can't help much with so little information.

Re: Newbie Color Question

Posted: Mon Feb 07, 2011 11:53 pm
by chris-kun

Code: Select all

function love.load()
  ......
  pc={122,150,191}
  love.graphics.setColorMode("replace")
  love.graphics.setBackgroundColor(51,51,51)
end

Code: Select all

function love.draw()
  love.graphics.setColor(pc)
  love.graphics.line(paddle[2].x, paddle[2].y, paddle[2].x, paddle[2].y+92)
end

Re: Newbie Color Question

Posted: Tue Feb 08, 2011 12:07 am
by Jasoco
That code doesn't have any images in it... Just lines and colors.

Re: Newbie Color Question

Posted: Tue Feb 08, 2011 12:10 am
by chris-kun
I was only posting the relevant parts. My point is if I use images instead of the code above, everything's cool, but the code above produces washed out colors even though it should be the same as their image equivalents.

Re: Newbie Color Question

Posted: Tue Feb 08, 2011 7:26 am
by EMB
Try changing this line:

Code: Select all

pc={122, 150, 191}
to:

Code: Select all

pc={122, 150, 191, 255}

Re: Newbie Color Question

Posted: Tue Feb 08, 2011 7:56 am
by chris-kun
that's what I had before, but it doesn't seem to change at all. I think 255 is the default so I just took it off. decreasing it definitely makes a difference, but putting 255 and putting nothing seem to be equivalent.

is it normal on everyone else's computer? :/

Re: Newbie Color Question

Posted: Tue Feb 08, 2011 11:01 am
by Boolsheet
Yes, the alpha defaults to 255 in that case.

I see that you use love.graphics.setColorMode, so I'm assuming you know that the color you set with love.graphics.setColor affects images.
The color in images never were a problem for me. Maybe you could expand your code example a bit more.

Re: Newbie Color Question

Posted: Tue Feb 08, 2011 12:55 pm
by kikito
You have to set the color back to white (255,255,255) before drawing your images, otherwise they will be "tinted" (it's more appropiate than "washed out") with the previous color you set.

This is useful in some cases - think about the different faction colors on strategy game. Instead of creating one image set per color (red soldier, blue soldier, pink soldier ...) this allows you to create just one "soldier", and then "tint" it (in some cases you will need two - "soldier" and "soldier_colors", only "soldier_colors" being tintable).

Re: Newbie Color Question

Posted: Tue Feb 08, 2011 5:39 pm
by chris-kun
where am I putting the reset to white? I put it in a bunch of places but still seeing color differences.

Code: Select all

function love.draw()
   love.graphics.setColor(255,255,255)                                       
   love.graphics.setColor(pc)
   love.graphics.line(paddle[2].x1, paddle[2].y1, paddle[2].x2, paddle[2].y2)
   love.graphics.setColor(255,255,255)
   love.graphics.draw(paddlei, paddle[1].x1, paddle[1].y1)
   love.graphics.draw(balli, bx-balli:getWidth()/2, by-balli:getHeight()/2)
   love.graphics.print(p1,5,5) love.graphics.print(p2,x-13,5)
   love.graphics.setColor(255,255,255)
end