Roundedbox or ?

Hello,

I saw this video and i was wondering… How did they do the roundedbox part?
When the health takes down it’s not a rounding but just a straight line. Is this a roundedbox or something else?
And as soon as the health takes down the color changed from black to white? How did they do that?

Here is the video:
http://www.youtube.com/watch?v=Nub43EF2spc&t=1m5s

Kind regards,

Most posted man in the forum.

It’s not

draw.RoundedBox specifically, but

draw.RoundedBoxEx. That one allows some corners to be straight and some to be rounded.

Did i do something wrong?


 	draw.RoundedBoxEx( 30, 770, ScrH() - 110, 380, 60, Color( 255, 255, 255, 160, boolean roundBottomRight=false ) 


 
[ERROR] lua/autorun/client/rebornhud_loader.lua:65: ')' expected near 'roundBottomRight'
  1. unknown - lua/autorun/client/rebornhud_loader.lua:0

 

If it errors then obviously you did something wrong??

Color does not take a fifth argument, you forgot a parenthesis, i have no idea what you’re trying to accomplish by doing “boolean roundBottomRight=false”, it literally just takes a boolean. Please read this again

draw.RoundedBoxEx

How then?


 draw.RoundedBoxEx( 30, 770, ScrH(()- 110, 380, 60, Color(255, 255, 255), boolean roundTopLeft=true, boolean roundTopRight=true, boolean roundBottomLeft=true, boolean roundBottomRight=true ) 

Remove the boolean roundTopLeft= and etc, and just put bools there (aka either true or false)


 	draw.RoundedBoxEx( 30, 770, ScrH() - 110, 380, 60, Color(255, 255, 255), roundTopLeft=true, roundTopRight=true, roundBottomLeft=true, roundBottomRight=true) 

Now i get this error:


 
[ERROR] lua/autorun/client/rebornhud_loader.lua:65: ')' expected near '='
  1. unknown - lua/autorun/client/rebornhud_loader.lua:0
 

Solved it!

[editline]3rd September 2017[/editline]

Hey, i got it but as shown in the video in the beginning the RoundedBoxEx is rounded and when its gaining damage it’s getting straight? How did they do that?

How round a box this function produces is determined by its first argument, an integer in pixels. Instead of using a constant value, but instead used a value representative of say how much damage is gained, then you can animate the roundedness if you will of the box.

Wow, what? So what should i do then? Don’t really understand you.

He’s talking about partially-filled circles:

You could use materials if you don’t want to scale by resolution, but it looks like the original HUD used stencils anyway:

Could you give me a example? Im still learning at this part of huds.

Thank you!

Someone??

Stencils are going to be way too advanced for you. Anything we say would just go over your head.

Well sh*t… i need it so bad :disgust:

Hmm. I forgot render.SetScissorRect() was a thing.

[lua]
hook.Add(“HUDPaint”, “HealthBar”, function()
local hp = LocalPlayer():Health()
local width = hp/100*380

render.SetScissorRect(50, 50, 50 + width, 50 + 32, true)
draw.RoundedBox(16, 50, 50, 380, 32, Color(255, 255, 255))
draw.SimpleText(hp, "CloseCaption_Bold", 50 + 380 - 20, 50 + 32/2, Color(0, 0, 0), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)

render.SetScissorRect(50 + width, 50, 50 + 380, 50 + 32, true)
draw.RoundedBox(16, 50, 50, 380, 32, Color(0, 0, 0, 150))
draw.SimpleText(hp, "CloseCaption_Bold", 50 + 380 - 20, 50 + 32/2, Color(255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)

render.SetScissorRect(0, 0, 0, 0, false)

end)
[/lua]
You’ll probably need to make your own quarter- or half-circle textures, though, since the ones used by draw.RoundedBox() are only 16x16 and look awful at 32x32. Shouldn’t take long to throw some transparent PNGs together in GIMP or Paint.net.

Yes, perfect! One more thing tho. Im new to these render stuff… How would i put this in the middel bottom? Tryed it but didn’t work.

The x and y of your health bar need to be based on the screen size. In this case,

[Lua]
x = ScrW()/2 - width/2
y = ScrH() - 32 - 10 --10 is the gap from the bottom, 32 is the height of the bar.
[/Lua]

Thank you!

Where should i place that in the code? Im still frustrated. Can’t get it to work…
Help me please!


     local hp = LocalPlayer():Health()
	local width = hp/100*380

	render.SetScissorRect(50, 50, 50 + width, 50 + 32, true)
	draw.RoundedBox(16, 50, 50, 380, 32, Color(255, 255, 255))
	draw.SimpleText(hp, "Health", 50 + 380 - 20, 50 + 32/2, Color(0, 0, 0), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)

	render.SetScissorRect(50 + width, 50, 50 + 380, 50 + 32, true)
	draw.RoundedBox(16, 50, 50, 380, 32, Color(0, 0, 0, 150))
	draw.SimpleText(hp, "Health", 50 + 380 - 20, 50 + 32/2, Color(255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)

	render.SetScissorRect(0, 0, 0, 0, false) 

You’d put it in the coordinate arguments.