Newbie Color Question

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
chris-kun
Prole
Posts: 17
Joined: Mon Feb 07, 2011 4:57 am
Location: SF Bay Area
Contact:

Newbie Color Question

Post 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?
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Newbie Color Question

Post by BlackBulletIV »

Could you show the code you're using. We can't help much with so little information.
User avatar
chris-kun
Prole
Posts: 17
Joined: Mon Feb 07, 2011 4:57 am
Location: SF Bay Area
Contact:

Re: Newbie Color Question

Post 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
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Newbie Color Question

Post by Jasoco »

That code doesn't have any images in it... Just lines and colors.
User avatar
chris-kun
Prole
Posts: 17
Joined: Mon Feb 07, 2011 4:57 am
Location: SF Bay Area
Contact:

Re: Newbie Color Question

Post 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.
EMB
Citizen
Posts: 70
Joined: Sat Jan 08, 2011 8:49 pm

Re: Newbie Color Question

Post by EMB »

Try changing this line:

Code: Select all

pc={122, 150, 191}
to:

Code: Select all

pc={122, 150, 191, 255}
Request Programs
If Linux were a beer, it would be shipped in open barrels so that anybody could piss in it before delivery
User avatar
chris-kun
Prole
Posts: 17
Joined: Mon Feb 07, 2011 4:57 am
Location: SF Bay Area
Contact:

Re: Newbie Color Question

Post 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? :/
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Newbie Color Question

Post 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.
Shallow indentations.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Newbie Color Question

Post 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).
When I write def I mean function.
User avatar
chris-kun
Prole
Posts: 17
Joined: Mon Feb 07, 2011 4:57 am
Location: SF Bay Area
Contact:

Re: Newbie Color Question

Post 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
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 4 guests