HUD Drawing doesn't work

Hey!

I have problem with lua.
I’ve spent 2 hours trying to find solution for this problem.



//START

function surface.PrecacheArc(cx,cy,radius,thickness,startang,endang,roughness,bClockwise)
	local triarc = {}
	local deg2rad = math.pi / 180
	
	-- Correct start/end ang
	local startang,endang = startang or 0, endang or 0
	if bClockwise and (startang < endang) then
		local temp = startang
		startang = endang
		endang = temp
		temp = nil
	elseif (startang > endang) then 
		local temp = startang
		startang = endang
		endang = temp
		temp = nil
	end
	
	
	-- Define step
	local roughness = math.max(roughness or 1, 1)
	local step = roughness
	if bClockwise then
		step = math.abs(roughness) * -1
	end
	
	
	-- Create the inner circle's points.
	local inner = {}
	local r = radius - thickness
	for deg=startang, endang, step do
		local rad = deg2rad * deg
		table.insert(inner, {
			x=cx+(math.cos(rad)*r),
			y=cy+(math.sin(rad)*r)
		})
	end
	
	
	-- Create the outer circle's points.
	local outer = {}
	for deg=startang, endang, step do
		local rad = deg2rad * deg
		table.insert(outer, {
			x=cx+(math.cos(rad)*radius),
			y=cy+(math.sin(rad)*radius)
		})
	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)
	for k,v in ipairs(arc) do
		surface.DrawPoly(v)
	end
end

function draw.Arc(cx,cy,radius,thickness,startang,endang,roughness,color,bClockwise)
	surface.SetDrawColor(color)
	surface.DrawArc(surface.PrecacheArc(cx,cy,radius,thickness,startang,endang,roughness,bClockwise))
end

//END



function drawHud()
	local h = ScrH()
	
	local centerX = 75
	local centerY = h - 75
	
	--BG FOR INFO
	draw.RoundedBoxEx( 7, centerX + 45, centerY - 35, 150, 70, Color( 255, 255, 255 ), false, true, false, true )
	--BG FOR INFO
	
	--BG CIRCLE
    local radius = 60
    local thickness = 15
    local startang = 0
    local endang = 360
    local roughness = 1
    draw.Arc(centerX, centerY, radius, thickness, startang, endang, roughness, Color( 120, 120, 120 ), false)
	--BG CIRCLE

end 
hook.Add("HUDPaint", "DarkRPHud", drawHud)


So this code draws Circle and RoundedBox.

You see here:



--BG FOR INFO
	draw.RoundedBoxEx( 7, centerX + 45, centerY - 35, 150, 70, Color( 255, 255, 255 ), false, true, false, true )
	--BG FOR INFO
	
	--BG CIRCLE
    local radius = 60
    local thickness = 15
    local startang = 0
    local endang = 360
    local roughness = 1
    draw.Arc(centerX, centerY, radius, thickness, startang, endang, roughness, Color( 120, 120, 120 ), false)
	--BG CIRCLE


It draws first the RoundedBox, then Circle BUT it doesnt draw the circle. If i swap their places then it draws both.
I need it to be first box then OVERLAY with the circle, but i don’t know how.

Thanks!

Anyone?

Change the draw.RoundedBoxEx to a surface drawing function, the arc code you are using for some reason does not like draw. functions.

With what i will have to replace it? I need rounded one…

[editline]20th April 2015[/editline]

Even better if that function can get fixed, if can, how?

Bump

Help?

You’re making a minor, frequently missed and somewhat unknown, mistake from quick glance… With poly, if you don’t reset the texture then you’re going to run into some issues such as the circle being transparent instead of solid, not visible, etc…

One example:
https://dl.dropboxusercontent.com/u/26074909/tutoring/poly/simplified_circles_with_poly.lua.html

Try adding this prior to drawing the poly and see how it turns out:


draw.NoTexture( );	

then set your color, etc…