Page 1 of 1

Radial Menu lines are acting odd.

Posted: Fri Jun 21, 2019 3:04 am
by JJSax
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

Re: Radial Menu lines are acting odd.

Posted: Sun Jun 23, 2019 10:45 pm
by pgimeno
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.

Re: Radial Menu lines are acting odd.

Posted: Mon Jun 24, 2019 8:58 pm
by JJSax
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.