Skip to content

Instantly share code, notes, and snippets.

@creativenucleus
Last active January 22, 2023 13:33
Show Gist options
  • Save creativenucleus/fc2059808dc4874b98b90b5bc9b1d949 to your computer and use it in GitHub Desktop.
Save creativenucleus/fc2059808dc4874b98b90b5bc9b1d949 to your computer and use it in GitHub Desktop.
TIC-80/Lua rotated filled ellipse
// d1,d2: ellipse width/height
// r: rotation
function ellipf(x,y,d1,d2,r)
-- i is the angle step. We increment this until we've passed 2*PI
i=0.2
for a=0,6.29+i,i do
x1,y1=rotate(x,y,d1,d2,r,a)
x2,y2=rotate(x,y,d1,d2,r,a+i)
tri(x,y,x1,y1,x2,y2,2)
end
end
function rotate(x,y,dx,dy,r,a)
dx=math.cos(a)*dx
dy=math.sin(a)*dy
return
x+dx*math.cos(r)-dy*math.sin(r),
y+dx*math.sin(r)+dy*math.cos(r)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment