Radial Menu lines are acting odd.

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
JJSax
Prole
Posts: 8
Joined: Fri Apr 04, 2014 3:59 am

Radial Menu lines are acting odd.

Post by JJSax » Fri Jun 21, 2019 3:04 am

I'm in the early stages of making a radial menu and I'm having some weird lines out of my circle and can't figure out why. What is going on with this code to cause the lines. Also 6 segments and above has a missing section. I'm sure I could figure that one out but if you fix it in the process I wouldn't complain. I'll post my segment functions below.

segments: 2, 4, 6*, 10 and more after that have the weird line.
segment 6 also is having a wierd issue with the background segment not matching perfectly too.

Thank you in advance.

Code: Select all

function drawFillSegment(segments, x, y, radius)
	love.graphics.setLineStyle("smooth")
	local p2 = math.pi*2
	local slice = p2 / segments
	for i = 1, segments do
		love.graphics.arc("fill", x, y, radius, p2 * slice, slice * i)
	end
end

function drawLineSegments(segments, x, y, radius)
	love.graphics.setLineStyle("smooth")
	local p2 = math.pi*2
	local slice = p2 / segments
	for i = 1, segments do
		love.graphics.arc("line", x, y, radius, p2 + slice, slice * i)
	end
end
Attachments
temp.love
(7.44 KiB) Downloaded 62 times

User avatar
pgimeno
Party member
Posts: 1686
Joined: Sun Oct 18, 2015 2:58 pm

Re: Radial Menu lines are acting odd.

Post by pgimeno » Sun Jun 23, 2019 10:45 pm

There's an issue with the miter line mode. Try love.graphics.setLineJoin to correct it. Basically, in miter line join mode, the outer edges of the lines are extended until they join, but in your case they are nearly parallel, that's why they extend out of the screen.

The other issue is a typo in your code. In the filling formula you're using p2 * slice where it should be p2 + slice.

JJSax
Prole
Posts: 8
Joined: Fri Apr 04, 2014 3:59 am

Re: Radial Menu lines are acting odd.

Post by JJSax » Mon Jun 24, 2019 8:58 pm

pgimeno wrote:
Sun Jun 23, 2019 10:45 pm
There's an issue with the miter line mode. Try love.graphics.setLineJoin to correct it. Basically, in miter line join mode, the outer edges of the lines are extended until they join, but in your case they are nearly parallel, that's why they extend out of the screen.

The other issue is a typo in your code. In the filling formula you're using p2 * slice where it should be p2 + slice.
That works perfectly actually. Thank you for your help! It makes a lot of sense.

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests