draw.OutlinedRoundedBox

I know this isn’t much of a release, but i personally think this is very useful for people who don’t know how to do this.

function:
[lua]
function draw.OutlinedRoundedBox(Bordersize, x, y, Width, Height, color, outlinew, outlinec)
for _x=-1, 1 do
for _y=-1, 1 do
draw.RoundedBox(Bordersize, x + (_xoutlinew), y + (_youtlinew), Width, Height, outlinec)
end
end
draw.RoundedBox(Bordersize, x, y, Width, Height, color)
end
[/lua]

and to use it. something like this :slight_smile:

[lua]
draw.OutlinedRoundedBox(4, 0, 0, 300, 100, Color( 200,200,255,255), 2, Color(50,50,50,255))
[/lua]

This will produce something like this background:

I also made a similar function to make health bars:

[lua]
function draw.PlayerBar(Bordersize, x, y, Width, Height, color, outlinew, outlinec, BGW, BGH)
for _x=-1, 1 do
for _y=-1, 1 do
draw.RoundedBox(Bordersize, x + (_xoutlinew), y + (_youtlinew), BGW, BGH, outlinec)
end
end
draw.RoundedBox(Bordersize, x, y, Width +4, Height + 3, color)
end
[/lua]
[lua]
local health = LocalPlayer():Health()
draw.PlayerBar(4, x +4,y + 4, health * 2.88, 21, Color( 170,0,0,255), 2, Color(50,50,50,255), 292,25)
[/lua]

Will make the health bar in the screenshot.

PS:I didn’t intend for my name to be dave brown :), that is my family members name, just for a test
Thanks for reading :slight_smile:

Dosn’t work with transparency.

Transparency works perfectly fine.

Try and make a rounded box with a opaque black outline and a transparent fill.

You can’t.

well, that’s because there is another rounded box behind the first…ill make something else, so it just draws edges, going to take a while though, trying to figure out how to Draw a verticle (health) bar sort of? and i did it the way someone told me to, and it disappears totally…so i’ll have to work on it.

does anyone know the base code for DrawOutlinedRect?

Modified Rounded box:
[lua]
local Tex_Corner8 = surface.GetTextureID( “gui/corner8” )
local Tex_Corner16 = surface.GetTextureID( “gui/corner16” )
function draw.RoundedOutlinedBox( bordersize, x, y, w, h, color )

x = math.Round( x )
y = math.Round( y )
w = math.Round( w )
h = math.Round( h )

surface.SetDrawColor( color.r, color.g, color.b, color.a )

// Draw as much of the rect as we can without textures
surface.DrawRect( x+bordersize, y, w-bordersize*2, 2 )
surface.DrawRect( x+bordersize, h+18, w-bordersize*2, 2 )
surface.DrawRect( x, y+bordersize, bordersize, h-bordersize*2 )
surface.DrawRect( x+w-bordersize, y+bordersize, bordersize, h-bordersize*2 )

local tex = Tex_Corner8
if ( bordersize > 8 ) then tex = Tex_Corner16 end

surface.SetTexture( tex )
surface.DrawTexturedRectRotated( x + bordersize/2 , y + bordersize/2, bordersize, bordersize, 0 ) 
surface.DrawTexturedRectRotated( x + w - bordersize/2 , y + bordersize/2, bordersize, bordersize, 270 ) 
surface.DrawTexturedRectRotated( x + w - bordersize/2 , y + h - bordersize/2, bordersize, bordersize, 180 ) 
surface.DrawTexturedRectRotated( x + bordersize/2 , y + h -bordersize/2, bordersize, bordersize, 90 ) 

end
[/lua]

then the function to draw out outlined rounded box:
[lua]
function draw.RoundedBoxO(Bordersize, x, y, Width, Height, color, outlinew, outlinec)

for _x=-1, 1 do 
	for _y=-1, 1 do 
		draw.RoundedBox(Bordersize, x + (_x*outlinew), y + (_y*outlinew), Width, Height, outlinec)
	end 
end 

draw.RoundedOutlinedBox(Bordersize, x, y, Width, Height, color) 

end
[/lua]

Important!
make sure you set the outlinew to 0, so a test box would be
[lua]
draw.RoundedBoxO(4, 20, 20, 200, 200, Color(255,255,255,255), 0, Color(255,0,0,20))
[/lua]

which produces:

http://img705.imageshack.us/img705/1597/otlined.png

I know this is simple, but very useful to me. I’m going to attempt a textured/gradient one really quickly before sleep

Very useful function for quickly drawing boxes with edges.
Useful’d

I like mine better

Why don’t you share your code? :slight_smile:

It looks like a WIP to me, besides, if he’s coding a windows based derma skin I doubt hes going to publicly release it.

I will, when it’s done. (soon)