[SOLVED] Problem with graphics.setColor

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.
Post Reply
User avatar
Ragerin
Prole
Posts: 9
Joined: Fri Feb 22, 2013 8:24 am
Location: Denmark

[SOLVED] Problem with graphics.setColor

Post by Ragerin »

First of all, hello to you all!

I am having issues with using love.graphics.setColor.
In my love.draw()-function, I am drawing some images. Afterwards I want to draw a, let's say, green rectangle. But when I test my application, the entire Love-window goes green (and note, it's green transparent, even though I write 255 in alpha).

Here's my draw-function:

Code: Select all

function love.draw()
    love.graphics.draw(bgimg, 0, 0)
    love.graphics.draw(eng_bar, btn_eng.x, btn_eng.y)
    love.graphics.draw(rot_bar, btn_rot.x, btn_rot.y)
    love.graphics.draw(krot_btn_off, btn_krot.x, btn_krot.y)
    love.graphics.draw(pship, shipmarker.x, shipmarker.y, deg_to_rad(orient_deg), 1, 1, shipmarker.w/2, shipmarker.h/2)
    
    --love.graphics.setColor(0, 0, 0, 255)
    love.graphics.print("     Set Engine: "..engine_set, 10, 10)
    love.graphics.print("  Current Speed: "..engine_cur, 10, 20)
    love.graphics.print("Orientation/deg: "..orient_deg, 10, 30)
    love.graphics.print(" i : "..i, 10, 40)

    love.graphics.setColor(0, 255, 0, 255)              -- < That makes entire window green transparent?
    love.graphics.rectangle("fill", btn.x, btn.y, btn.w, btn.h)
end

Why has my code gone ill? :brows:
Last edited by Ragerin on Fri Feb 22, 2013 9:12 am, edited 1 time in total.
User avatar
OmarShehata
Party member
Posts: 259
Joined: Tue May 29, 2012 6:46 pm
Location: Egypt
Contact:

Re: Problem with graphics.setColor

Post by OmarShehata »

Imagine Love being an artist, a human artist. Love draws everything using one paint brush. It starts with a bucket of white paint, and it's drawing everything. Then you replace the white paint with green, so it draws your rectangle green, but it's also going to draw everything after that in green because..the bucket has green paint in it.

You need put white paint back in after you're done drawing the green rectangle.
User avatar
Ragerin
Prole
Posts: 9
Joined: Fri Feb 22, 2013 8:24 am
Location: Denmark

Re: Problem with graphics.setColor

Post by Ragerin »

Thank you very much. :-) That was the problem. This clarifies a lot.
Post Reply

Who is online

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