Page 1 of 1

Avoid jagged edges of stencil?

Posted: Sat Mar 09, 2013 2:35 pm
by Gatada
Hi,

I want to animate the filling of a circle outline. So I created a stencil based on a circle "line" with setLine(3, "smooth"), and then moved a rectangle("fill"..) upwards to fill the circle. However, the resulting circle line is jagged/pixellated, and not as smooth as a regular circle "line" would be.

Any ideas why the stencil line is jagged - and better yet, how to avoid it and get smooth edges?

Thanks for any input,

Code: Select all

love.graphics.setLine(3, "smooth")

local makeFillStencil = function()
	love.graphics.circle("line", xC, yC, radius)
end

local fillStencil = love.graphics.newStencil(makeFillStencil)

love.graphics.setStencil(fillStencil)
	love.graphics.rectangle("fill", xC - radius, yC, xC + radius, yC + radius)			
love.graphics.setStencil()

Re: Avoid jagged edges of stencil?

Posted: Sat Mar 09, 2013 3:34 pm
by Boolsheet
Stencil are exactly that; they either let something through, or they don't. If you want a mask, you probably need Canvases or another approach. I can't think of one right now, sorry.

Re: Avoid jagged edges of stencil?

Posted: Sat Mar 09, 2013 4:40 pm
by micha
Gatada wrote:Hi,

I want to animate the filling of a circle outline. So I created a stencil based on a circle "line" with setLine(3, "smooth"), and then moved a rectangle("fill"..) upwards to fill the circle. However, the resulting circle line is jagged/pixellated, and not as smooth as a regular circle "line" would be.

Any ideas why the stencil line is jagged - and better yet, how to avoid it and get smooth edges?
If you just want to fill it from bottom to top, you can change the roles of the rectangle and the circle. Use the rectangle as stencil and draw the circle through this stencil.
And then, since the stencil is rectangular, you can use scissors instead. They are probably faster.
https://love2d.org/wiki/love.graphics.setScissor

Re: Avoid jagged edges of stencil?

Posted: Sun Mar 10, 2013 12:42 pm
by Gatada
micha wrote:If you just want to fill it from bottom to top, you can change the roles of the rectangle and the circle. Use the rectangle as stencil and draw the circle through this stencil.
Hah! Clever. Didn't think about that.
micha wrote:And then, since the stencil is rectangular, you can use scissors instead. They are probably faster.
https://love2d.org/wiki/love.graphics.setScissor
You are of course right. Great!

Thanks a lot!

-- Edit: Read about rewarding karma to answers, but can't find that? karma++ for you anyway

Re: Avoid jagged edges of stencil?

Posted: Sun Mar 10, 2013 2:16 pm
by Germanunkol
Gatada wrote:-- Edit: Read about rewarding karma to answers, but can't find that? karma++ for you anyway
I read that they removed it with a forum-software update a few years back.

Re: Avoid jagged edges of stencil?

Posted: Sun Mar 10, 2013 4:17 pm
by mickeyjm
Germanunkol wrote:
Gatada wrote:-- Edit: Read about rewarding karma to answers, but can't find that? karma++ for you anyway
I read that they removed it with a forum-software update a few years back.
I dont think it was a few years, months maybe