[SOLVED] Using intersection of stencils

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
User avatar
msilvestro
Prole
Posts: 29
Joined: Tue Feb 25, 2014 11:15 pm
Location: Italy
Contact:

[SOLVED] Using intersection of stencils

Post by msilvestro »

Hi everybody!
I'm trying to draw a tiled ground, but I want it to be a circle of radius r. So, I first drew a square with sides of 2*r of length, and then I applied a stencil of a circle of radius r with the same center of the square, and everything worked very well.
My problem is this: what can I do if I want, let's say, a circular sector of the circle with inside the tiled ground, what can I do?
With stencils, if I add a triangle in the stencil function (with already the circle), I get the union of the shapes, but what if I want the intersection of them?
Is that possibile with stencils? Or maybe I have to study the canvases to achieve this?
Thanks for the help!
Attachments
stencil.love
(3.01 KiB) Downloaded 57 times
Last edited by msilvestro on Wed Mar 05, 2014 10:44 pm, edited 1 time in total.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Using intersection of stencils

Post by Nixola »

Did you try setting a stencil while drawing a stencil?
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
msilvestro
Prole
Posts: 29
Joined: Tue Feb 25, 2014 11:15 pm
Location: Italy
Contact:

Re: Using intersection of stencils

Post by msilvestro »

Nixola wrote:Did you try setting a stencil while drawing a stencil?
Do you mean something like this?

Code: Select all

triangle = function()
	love.graphics.polygon("fill", xc, yc, 0, 600, 300, 0)
end
groundCircle = function()
	love.graphics.setStencil(triangle)
	love.graphics.circle("fill", xc, yc, r, 100)
	love.graphics.setStencil()		
end
If yes, it didn't worked... I don't know what to do exactly!
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Using intersection of stencils

Post by micha »

You can draw a circular sector with love.graphics.arc. And if you need a more complicated shape you can always make a polygon of the shape and use this as a stencil.
User avatar
msilvestro
Prole
Posts: 29
Joined: Tue Feb 25, 2014 11:15 pm
Location: Italy
Contact:

Re: Using intersection of stencils

Post by msilvestro »

micha wrote:You can draw a circular sector with love.graphics.arc. And if you need a more complicated shape you can always make a polygon of the shape and use this as a stencil.
Oh thanks, I didn't remembered there was such a function! :awesome:
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests