• Improved Health Circle?
    2 replies, posted
I am currently using this as my code to do a circle to represent health. However, it is coming out clunky, and unappealing. Does anyone have a better function or idea I can use? [CODE] local clamp, cos, sin, deg2rad = math.Clamp, math.cos, math.sin, math.pi/180 function DrawPartialCircle( x, y, radius, linewidth, startangle, endangle, aa ) -- Thanks for getting me started on how to do this python1320 <3 aa = aa or 1; startangle = clamp( startangle or 0, 0, 360 ); endangle = clamp( endangle or 360, 0, 360 ); if endangle < startangle then local temp = endangle; endangle = startangle; startangle = temp; end for i=startangle, endangle, aa do local _i = i * deg2rad; surface.DrawTexturedRectRotated(cos( _i ) * (radius - linewidth) + x,sin( _i ) * (radius - linewidth) + y, linewidth, aa*2, -i ); end end[/CODE] I would draw it with this. [CODE]DrawPartialCircle( 80, ScrH() - 70, 65, 13, 0, math.max( 0, client:Health() ) * 3.6, 1 ) [/CODE] Any tips?
Draw a .png texture of a half circle, and set [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/render/SetScissorRect]render.SetScissorRect[/url] over it, and rotate that texture so that it leaves the scissor rectangle thus not drawing the part outside it (or vice versa). You can repeat this effect flipped for the second half of the circle, or make each half represent different things (like one half for health, the other in another color for armor or sprint remaining).
Alright, thanks.
Sorry, you need to Log In to post a reply to this thread.