Avoid jagged edges of stencil?

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
Gatada
Prole
Posts: 2
Joined: Sat Mar 09, 2013 11:02 am

Avoid jagged edges of stencil?

Post 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()
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Avoid jagged edges of stencil?

Post 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.
Shallow indentations.
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Avoid jagged edges of stencil?

Post 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
Gatada
Prole
Posts: 2
Joined: Sat Mar 09, 2013 11:02 am

Re: Avoid jagged edges of stencil?

Post 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
Germanunkol
Party member
Posts: 712
Joined: Fri Jun 22, 2012 4:54 pm
Contact:

Re: Avoid jagged edges of stencil?

Post 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.
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
User avatar
mickeyjm
Party member
Posts: 237
Joined: Thu Dec 29, 2011 11:41 am

Re: Avoid jagged edges of stencil?

Post 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
Your screen is very zoomed in...
Post Reply

Who is online

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