I am trying to challenge myself to make a circle/ellipse be a series of arcs so it doesn't draw anything outside of an area. (like the screen for example) I'm noticing that the love.graphics.arc doesn't have an x/y radius option.
I could probably use a stencil, but that probably wouldn't help it be faster, possibly slower.
I could also make my own. But I'm curious if there is something that I'm missing that could make this easier.
Any sneaky way to draw an elliptical arc?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Any sneaky way to draw an elliptical arc?
The obvious answer is to use trigonometry, but note that angles get deformed and don't work as one expects.
Code: Select all
function ellipticArc(x, y, rx, ry, angle1, angle2, segments)
local points = {}
local range = angle2 - angle1
for i = 0, segments do
local angle = angle1 + range * (i / segments)
points[i + i + 1] = cos(angle) * rx + x
points[i + i + 2] = sin(angle) * ry + y
end
love.graphics.line(points)
end
Who is online
Users browsing this forum: Google [Bot] and 7 guests