Created
October 16, 2013 20:02
-
-
Save Metapyziks/7013849 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function CreateHollowCircle(x, y, innerRadius, outerRadius, startAngle, rotation) | |
| rotation = math.min(rotation or (math.pi * 2), math.pi * 2) | |
| startAngle = startAngle or 0 | |
| local quality = math.min(256, 4 * math.sqrt(outerRadius) + 8) | |
| local verts = {} | |
| local angA, angB | |
| local mul = math.pi * 2 / quality | |
| local count = quality * rotation / (math.pi * 2) | |
| for i = 0, count do | |
| angA = startAngle + i * mul | |
| angB = angA + mul | |
| if angB - startAngle > rotation then angB = startAngle + rotation end | |
| sinA, cosA = sin(angA), cos(angA) | |
| sinB, cosB = sin(angB), cos(angB) | |
| verts[i + 1] = { | |
| { x = x + cosA * innerRadius, y = y + sinA * innerRadius }, | |
| { x = x + cosA * outerRadius, y = y + sinA * outerRadius }, | |
| { x = x + cosB * outerRadius, y = y + sinB * outerRadius }, | |
| { x = x + cosB * innerRadius, y = y + sinB * innerRadius } | |
| } | |
| end | |
| return verts | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment