draw.circle

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
bitlord
Prole
Posts: 10
Joined: Thu Jun 02, 2011 7:06 pm

draw.circle

Post by bitlord »

I was wondering why it still uses lines when the line width is not 1
I use something like this

Code: Select all

function generate_circle(mode,x, y, r, w, n, r1, r2)
	local cp = {}
	if r1 == nil then r1 = 0 end
	if r2 == nil then r2 = 2*math.pi end
	local t = (r2-r1)/n
	if mode == "inner" then
		r = r-w/2
	elseif mode == "outer" then
		r= r+w/2
	end
	for i=0,n,1 do
		cp[4*i + 1] = x + (r-w/2)*math.cos(r1+i*t)
		cp[4*i + 2] = y + (r-w/2)*math.sin(r1+i*t)
		cp[4*i + 3] = x + (r+w/2)*math.cos(r1+i*t)
		cp[4*i + 4] = y + (r+w/2)*math.sin(r1+i*t)
	end
	return cp
end


function draw_quadstrip(mode, q)
	for i=1,#q-4,4 do
		love.graphics.quad( mode, q[i], q[i+1], q[i+2], q[i+3],
			q[i+6], q[i+7], q[i+4], q[i+5] )
	end
end
mode : one of "inner" "outer" "mid" , direction in which the circle gains thickness
x, y : center
r : radius
w : width
n : segments
r1 : start angle(radian)
r2 : end angle(radian)
circle = generate_circle(...)
draw_quadstrip("fill", circle)
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: draw.circle

Post by Robin »

bitlord wrote:I was wondering why it still uses lines when the line width is not 1
I'm sorry, what is your question?
Help us help you: attach a .love.
User avatar
bitlord
Prole
Posts: 10
Joined: Thu Jun 02, 2011 7:06 pm

Re: draw.circle

Post by bitlord »

It is obvious.

Code: Select all

function love.draw()
 love.graphics.setLineWidth(30)
 love.graphics.circle( "line", 200, 200, 100, 10)
end
result:
a4TRZ.png
a4TRZ.png (1.69 KiB) Viewed 761 times
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: draw.circle

Post by BlackBulletIV »

Ramp up that last parameters to love.graphics.circle. You might want something like 50 or so. The greater the number the more detailed the circle (and the more costly to performance, so be weary of drawing circles).
User avatar
bitlord
Prole
Posts: 10
Joined: Thu Jun 02, 2011 7:06 pm

Re: draw.circle

Post by bitlord »

but it doesn't matter since it is composed of separate lines
so you will always have artifacts
User avatar
bitlord
Prole
Posts: 10
Joined: Thu Jun 02, 2011 7:06 pm

Re: draw.circle

Post by bitlord »

example of what I mean
Attachments
circle.love
make it smile
(1.56 KiB) Downloaded 631 times
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: draw.circle

Post by vrld »

Lines and OpenGL dont play very well together. However, this will be gone in love 0.8.
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
Post Reply

Who is online

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