Draw Rounded Outlined Rect?

Title says it all. How? D=

It depends if you want the fill area opaque or not. If so, just draw a rounded rect for the outline color, then another one slightly smaller for the fill color.

If you want it it transparent, copy Garry’s code and use custom textures.

Thing is, I don’t want to use textures. Just color. ( I honestly know NOTHING about textures) Is there a just black texture? Also, will that lag it more than if I were to just use a DrawOutlinedBox? I don’t wanna make it slower just for some curvy edges.

If it wasn’t obvious, I want just a rounded border. Transparent inside.

TomFN made this, just a quick duplicate of DrawRoundedBox:

local texOutlinedCorner = surface.GetTextureID( “gui/td/rounded-corner” )

Name: RoundedBoxOutlined( bordersize, x, y, w, h, color, bordercol )
Desc: Draws a rounded box with a 1 pixel wide border - ideally bordersize will be 8 or 16
Usage: color is a table with r/g/b/a elements
function draw.RoundedBoxOutlined( bordersize, x, y, w, h, color, bordercol )

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

draw.RoundedBox( bordersize, x, y, w, h, color )

surface.SetDrawColor( bordercol )

surface.SetTexture( texOutlinedCorner )
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 ) 

surface.DrawLine( x+bordersize, y, x+w-bordersize, y )
surface.DrawLine( x+bordersize, y+h-1, x+w-bordersize, y+h-1 )

surface.DrawLine( x, y+bordersize, x, y+h-bordersize )
surface.DrawLine( x+w-1, y+bordersize, x+w-1, y+h-bordersize )


All the texture is is a copy of “surface.GetTextureID( “gui/corner16” )” but outlined.

Thank you :slight_smile: I really appreciate this.

Wouldn’t you need to offer up the texture for that to be useful to him?

You can do that, but there is also the command “draw.RoundedBox”

all you could need to do is this for the outline:
draw.RoundedBox( 2, 10, 10, 300, 300, Color( 0, 0, 0, 255 ) );
draw.RoundedBox( 2, 11, 11, 299, 299, Color( 255, 0, 0, 255 ) );

That’s already been brought up, it doesn’t solve his problem.

he never mentioned a specific problem, except that he didn’t want to use textures but he DID want to use alpha, your way is good, but the way i posted should work perfectly for what he wants, correct me if i am wrong.

We did correct you because you were wrong, he want’s to make it transparent, so drawing 2 boxes will not work.

Read the entire thread. You are wrong.


Ooops. What he said.


Also, any chance I can get that vtf? I tried making it myself, and it turns out I’m terrible =[

Something like this? :slight_smile:

That looks so epic may I ask for the X in top are you making it with a Derma skin or using a paint function on it

He’s editing my code. I personally like my streaks better shrug Mine is a good base derma though. It has a panel for the 0,0 position you’d want to place controls on. so it’s perfect without messing with positions. :slight_smile:

Fish: The X is a paint function. I hate using images for the most part, so I just drew that with 1px high boxes.