Weak text when printing to Canvas [RESOLVED}

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
simtrip
Prole
Posts: 2
Joined: Tue Nov 13, 2012 9:28 pm

Weak text when printing to Canvas [RESOLVED}

Post 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 207 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!
Last edited by simtrip on Tue Nov 13, 2012 11:15 pm, edited 1 time in total.
User avatar
Xgoff
Party member
Posts: 211
Joined: Fri Nov 19, 2010 4:20 am

Re: Weak text when printing to Canvas

Post by Xgoff »

you should set the blend mode to "premultiplied" before drawing a canvas that contains transparency (and set it back to "alpha" afterward)
Last edited by Xgoff on Tue Nov 13, 2012 10:44 pm, edited 1 time in total.
User avatar
slime
Solid Snayke
Posts: 3162
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Weak text when printing to Canvas

Post by slime »

Use the "premultiplied" blend mode in place of the "alpha" blend mode when drawing the Canvas to the screen.

EDIT: ninja'd. :(
simtrip
Prole
Posts: 2
Joined: Tue Nov 13, 2012 9:28 pm

Re: Weak text when printing to Canvas

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

Who is online

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