Created
January 9, 2014 23:44
-
-
Save rbreslow/8344292 to your computer and use it in GitHub Desktop.
This file contains 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
local cx = 200; // Center X | |
local cy = 200; // Center Y | |
local size = 100; // The radius | |
local spacing = 15; // The angle between each triangle | |
local count = 360 / spacing; | |
local points = {} | |
function rotate(px, py, ax, ay, angle) | |
angle = angle * 0.0174532925; | |
local s = math.sin(angle); | |
local c = math.cos(angle); | |
px = px-ax; | |
py = py-ay; | |
// rotate point | |
local xnew = px * c - py * s; | |
local ynew = px * s + py * c; | |
return {xnew + ax, ynew + ay}; | |
end | |
local other = true; | |
for i = 1, count do | |
local angle = rotate(cx, cy - size, cx, cy, i * spacing); | |
local nangle = rotate(cx, cy - size, cx, cy, (i + 1) * spacing); | |
table.insert(points, { x = cx, y = cy } ) | |
if (other) then | |
table.insert(points, { angle[1], angle[2] } ); | |
table.insert(points, { nangle[1], nangle[2] } ); | |
end | |
other = !other; | |
end | |
hook.Add( "HUDPaint", "HUD Elements", function()) | |
surface.SetDrawColor( 255, 0, 0, 255 ) | |
draw.NoTexture() | |
surface.DrawPoly( points ) | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment