Using this code
[lua]
-- Draws an arc on your screen.
-- startang and endang are in degrees,
-- radius is the total radius of the outside edge to the center.
-- cx, cy are the x,y coordinates of the center of the arc.
-- roughness determines how many triangles are drawn. Number between 1-360; 2 or 3 is a good number.
function draw.Arc(cx,cy,radius,thickness,startang,endang,roughness,color)
surface.SetDrawColor(color)
surface.DrawArc(surface.PrecacheArc(cx,cy,radius,thickness,startang,endang,roughness))
end
function surface.PrecacheArc(cx,cy,radius,thickness,startang,endang,roughness)
local triarc = {}
-- local deg2rad = math.pi / 180
-- Define step
local roughness = math.max(roughness or 1, 1)
local step = roughness
-- Correct start/end ang
local startang,endang = startang or 0, endang or 0
if startang > endang then
step = math.abs(step) * -1
end
-- Create the inner circle's points.
local inner = {}
local r = radius - thickness
for deg=startang, endang, step do
local rad = math.rad(deg)
-- local rad = deg2rad * deg
local ox, oy = cx+(math.cos(rad)*r), cy+(-math.sin(rad)*r)
table.insert(inner, {
x=ox,
y=oy,
u=(ox-cx)/radius + .5,
v=(oy-cy)/radius + .5,
})
end
-- Create the outer circle's points.
local outer = {}
for deg=startang, endang, step do
local rad = math.rad(deg)
-- local rad = deg2rad * deg
local ox, oy = cx+(math.cos(rad)*radius), cy+(-math.sin(rad)*radius)
table.insert(outer, {
x=ox,
y=oy,
u=(ox-cx)/radius + .5,
v=(oy-cy)/radius + .5,
})
end
-- Triangulize the points.
for tri=1,#inner*2 do -- twice as many triangles as there are degrees.
local p1,p2,p3
p1 = outer[math.floor(tri/2)+1]
p3 = inner[math.floor((tri+1)/2)+1]
if tri%2 == 0 then --if the number is even use outer.
p2 = outer[math.floor((tri+1)/2)]
else
p2 = inner[math.floor((tri+1)/2)]
end
table.insert(triarc, {p1,p2,p3})
end
-- Return a table of triangles to draw.
return triarc
end
function surface.DrawArc(arc) //Draw a premade arc.
for k,v in ipairs(arc) do
surface.DrawPoly(v)
end
end
hook.Add("HUDPaint", "somehookname", function()
draw.Arc( ScrW() / 2, ScrH() / 2, 200, 20, 0, 360, 1, Color( 255, 73, 98 ) );
draw.Arc( ScrW() / 2, ScrH() / 2, 200, 20, 0, 90, 1, Color( 26, 188, 156 ) );
end)
[/lua]
The draw.Arc works fine inside a HUDPaint but as soon as it's inside a DFrame.Paint function it fucks up.
[lua]
draw.Arc( w / 2, 440*hMod, math.Round(80*wMod), 10, 180, 360, 1, Color( 255, 73, 98, 255 ) );
[/lua]
Drawing with and without wMod/hMod makes no difference.
Here's a pic of exactly what happens
[t]http://images.akamai.steamusercontent.com/ugc/264966045858384494/31FD95368B3FA415647905F7B1807CE0FB12BE66/[/t]
Try setting the material before draw.Arc to vgui/white or use draw.NoTexture()
I Dont think this is about politics ;D
Easy way it draw a circle the same color as the background and have the changing circle behind it
[QUOTE=McDunkable;50579832]Try setting the material before draw.Arc to vgui/white or use draw.NoTexture()[/QUOTE]
<3
Sorry, you need to Log In to post a reply to this thread.