Page 1 of 1
Image Colour Workaround?
Posted: Sun Apr 29, 2012 8:45 pm
by Neon
When I set the colour of text, it changes the colour like it should. However, I can set the colour for my image, because it uses multiple colours (as most images do). How do I make it so when I use a image, it stay the colour it is, and is not affected by the current colour?
I tried:
Code: Select all
love.graphics.setColourMode("replace")
but that screwed up all the other colours, and just didn't work.
Re: Image Colour Workaround?
Posted: Sun Apr 29, 2012 9:09 pm
by Larsii30
Could you post the code ?
Whould be easier.
You could do it like this:
Code: Select all
love.graphics.setColorMode("replace") -- images will not be affected by current color
function love.draw()
love.graphics.setColorMode("modulate") -- image WIILL be affected
love.graphics.setColor(0,255,0)
love.graphics.print("hello, i'm Green!", 10,10)
love.graphics.setColorMode("replace") --not sure if that is needed
love.graphics.print("not Green, yeaaah!", 30 , 30)
end
edit (or without push pop
code should work)
Re: Image Colour Workaround?
Posted: Sun Apr 29, 2012 9:11 pm
by Zeliarden
Code: Select all
love.graphics.setColor(255, 255, 255)
just call it whenever you need to change color. Set it to (255, 255, 255) before you images for orginal color
Re: Image Colour Workaround?
Posted: Sun Apr 29, 2012 9:22 pm
by Neon
Larsii, I somewhat understand what you mean. Is there a easier way? I assume I could use your system, but a easier way would work much better.
Here is the function to draw all the objects in my lib.
Code: Select all
function Lib.draw() -- Draws all the objects.
for k, obj in pairs(Objects) do
if obj.objtype == "Label" then
love.graphics.setColor(obj.red, obj.green, obj.blue)
love.graphics.setFont(love.graphics.newFont(obj.fontsize))
love.graphics.print(obj.words, obj.xpos, obj.ypos)
elseif obj.objtype == "Button" then
love.graphics.setColor(obj.red, obj.green, obj.blue)
love.graphics.rectangle(obj.status, obj.xpos, obj.ypos, obj.height, obj.width)
elseif obj.objtype == "Image" then
love.graphics.draw(obj.pic, obj.x, obj.y)
end
end
end
Say a button is drawn before a image. The colour is set to the colour of the button. Then when you draw a image, it uses that colour. That's what I'm trying to avoid.
Re: Image Colour Workaround?
Posted: Sun Apr 29, 2012 10:02 pm
by Neon
Nevermind, Zeliarden's worked. Thanks.
Re: Image Colour Workaround?
Posted: Sun Apr 29, 2012 10:19 pm
by Larsii30
actually you're right . Didn't know that.
Then I could use it like this too
Thanks