Page 1 of 1

Weak text when printing to Canvas [RESOLVED}

Posted: Tue Nov 13, 2012 9:48 pm
by simtrip
I'm really not sure whether this is actually a bug or whether I'm overlooking something related to the love.graphics module, so I've posted here instead of the issue tracker. I've noticed that when printing text to a Canvas, text appears strangely weak or thin-looking compared to printing on the draw callback. Even stranger is that I've been able to fix the issue simply by drawing the same text to the Canvas again (literally copy-pasting the print line twice.)

Here it is exemplified in a GUI object I was working on - left is the image with 3 identical love.graphics.print() commands in a row drawn to a Canvas, and on the right is with just the one line.
2TgvZ.png
2TgvZ.png (12.24 KiB) Viewed 208 times

The following code also creates the effect on my machine and a friend who tested his. The text from the Canvas appears less smooth than the text printed above it - any ideas why?

Code: Select all

function love.load()
	text = "Hello World"
	canvas = love.graphics.newCanvas()
	canvas:renderTo(function() love.graphics.print(text,1,1)end)
end

function love.update(dt)
end

function love.draw()
	love.graphics.print(text,10,10)
	love.graphics.draw(canvas,10,30)
end
Thanks!

Re: Weak text when printing to Canvas

Posted: Tue Nov 13, 2012 10:43 pm
by Xgoff
you should set the blend mode to "premultiplied" before drawing a canvas that contains transparency (and set it back to "alpha" afterward)

Re: Weak text when printing to Canvas

Posted: Tue Nov 13, 2012 10:44 pm
by slime
Use the "premultiplied" blend mode in place of the "alpha" blend mode when drawing the Canvas to the screen.

EDIT: ninja'd. :(

Re: Weak text when printing to Canvas

Posted: Tue Nov 13, 2012 11:01 pm
by simtrip
Oh wow, excellent. So the effect is that love.graphics tries to perform its colour blending on image data that already has it present.
Thanks a bunch :)