canvas black & white only?

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
zorg
Party member
Posts: 3444
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: canvas black & white only?

Post by zorg »

dusoft wrote: Tue Apr 04, 2017 10:13 am
zorg wrote: Tue Apr 04, 2017 6:00 am Tinting (coloring) the canvas if you forget to clear the drawing color back to white is not a bug. :3
(the red line drawn premultiplied and tinted red coming out as a grey line may be, though i haven't done the math on that)
Well, if this is correct behaviour, then I apparently don't seem to get the whole canvas coloring concept. You have written that it behaves like standard drawing on screen, but based on this example, it just clearly does not. I would also expect the same behaviour as otherwise the whole UX (in this case programmer's usage experience) is just mess.

Anyway, problem is the Love2D documentation on canvas is hardly user friendly and is rather confusing. E.g. the modes alpha, add, multiply etc. should be demonstrated also visually, not just in text.
Yes, it behaves exactly as if you're drawing something colored to the screen... but if you forget to reset the drawing color to white (255,255,255,255) when drawing the canvas itself onto the screen, it will be tinted, as i said before.

And as s-ol said above, blendmodes put another layer of complexity on top of that. (for example, drawing your canvas with (alpha, alphamultiply) blendmode with the drawing color set to {anything, anything, anything, 0} will draw nothing, since the alpha value was zero, and the source pixels' colors were multiplied by that value)

I can't really explain it more clearer, instead of you drawing to the main window's "canvas", you are drawing onto a different one, then drawing that canvas onto the main window's canvas; both of those times (graphics -> your canvas; your canvas -> window canvas), the drawing operations are the same, both have the drawing color set by love.graphics.setColor applied to them. I'd want to think that the why part is straightforward, and that it's an easy mistake to fix.

Also, the online documentation is a wiki, if something's not clear to someone, then they can edit it using their forum account's username/password.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
dusoft
Party member
Posts: 509
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: canvas black & white only?

Post by dusoft »

s-ol wrote: Tue Apr 04, 2017 10:25 am I guess you mean the BlendModes documentation, since BlendModes have almost nothing to do with canvas'!

The problem is that it's quite hard to demonstrate the different blend modes, since each of them has 8 input parameters per pixel.
Just overlapping a red and a blue triangle for example won't demonstrate half of the blendmodes properly, and if you have a different scene in each I think it will lose the clarity. But if you can think of a way to demonstrate it, go ahead and put that up!
Yes, I meant BlendModes. However, if drawing to canvas needs to be finished by love.graphics.setColor(255, 255, 255) to get correct results, this should be mentioned in the docs. It can save hours of head banging for others.
User avatar
zorg
Party member
Posts: 3444
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: canvas black & white only?

Post by zorg »

dusoft wrote: Tue Apr 04, 2017 3:44 pm
s-ol wrote: Tue Apr 04, 2017 10:25 am I guess you mean the BlendModes documentation, since BlendModes have almost nothing to do with canvas'!

The problem is that it's quite hard to demonstrate the different blend modes, since each of them has 8 input parameters per pixel.
Just overlapping a red and a blue triangle for example won't demonstrate half of the blendmodes properly, and if you have a different scene in each I think it will lose the clarity. But if you can think of a way to demonstrate it, go ahead and put that up!
Yes, I meant BlendModes. However, if drawing to canvas needs to be finished by love.graphics.setColor(255, 255, 255) to get correct results, this should be mentioned in the docs. It can save hours of head banging for others.
No, resetting the color is needed before drawing the canvas itself to the screen.
Also, the example on Canvas resets the color to white before drawing the canvas itself to the screen.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
dusoft
Party member
Posts: 509
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: canvas black & white only?

Post by dusoft »

zorg wrote: Tue Apr 04, 2017 4:00 pm
dusoft wrote: Tue Apr 04, 2017 3:44 pm
s-ol wrote: Tue Apr 04, 2017 10:25 am I guess you mean the BlendModes documentation, since BlendModes have almost nothing to do with canvas'!

The problem is that it's quite hard to demonstrate the different blend modes, since each of them has 8 input parameters per pixel.
Just overlapping a red and a blue triangle for example won't demonstrate half of the blendmodes properly, and if you have a different scene in each I think it will lose the clarity. But if you can think of a way to demonstrate it, go ahead and put that up!
Yes, I meant BlendModes. However, if drawing to canvas needs to be finished by love.graphics.setColor(255, 255, 255) to get correct results, this should be mentioned in the docs. It can save hours of head banging for others.
No, resetting the color is needed before drawing the canvas itself to the screen.
Also, the example on Canvas resets the color to white before drawing the canvas itself to the screen.
It is just a regular line of color setting without any comment on it as opposed to other lines that are commented and that you actually pay attention to, since the comments are important here. The color reset line does not have any comment that would say how it is important to do so.
MrFariator
Party member
Posts: 512
Joined: Wed Oct 05, 2016 11:53 am

Re: canvas black & white only?

Post by MrFariator »

It's probably assumed that user can check love.graphics.setColor if they are curious as to how it works. You should link there on the wiki as opposed to linking to this thread, or just reduce the comment to saying that the drawing color is changed to white.
Post Reply

Who is online

Users browsing this forum: No registered users and 82 guests