Maybe revising draw.RoundedBoxEx ?

So here is something strange.

After seeing the update I noticed the additions Garry has added to derma and draw events and etc. One of them really got my attention, the draw.RoundedBoxEx.
Basically, what you can do with it is drawing a rounded box and defining which sides and to round and what not. Like seen on the Wiki








Round Top Left,

Round Top Right,

Round Bottom Left,

Round Bottom Right )

Description: Draws a square with the bottom right and left rounded.

Used on:

Code: [lua]function GAMEMODE:HUDPaint()
draw.RoundedBoxEx( 20, 40, 40, 50, 50, Color(255,255,255,255), false, false, true, true )
But I ran into some troubles while using it. So I made a screenshot of the tests I made with it, and came up with some drawing errors. I don’t know if it is intended but this is what it gave;

Small legend to show what in the picture means what, and the settings I used on the boolean part.

[li]t for True[/li][li]f for False[/li][/ul]

So thats about it. If it was intended to do so, then maybe it should be upgraded or revised. If it isn’t supposed to do this then maybe fixing it could help cause I think this function has great potential when drawing stuff.

I never knew you could make shapes like that!
Still a beginner so yea…
But thanks for posting :smiley:

woah that is WAAAY broken, must be hell trying to get the right combination to get the rounded corners you want

The decent combinations that worked in my tests were:

( false, false, true, true )

But most of the others gave me what you see in the pic.

Looking at the code, I doubt it’s intentional.

Name: RoundedBox( bordersize, x, y, w, h, color )
Desc: Draws a rounded box - ideally bordersize will be 8 or 16
Usage: color is a table with r/g/b/a elements
function RoundedBoxEx( bordersize, x, y, w, h, color, a, b, c, d )

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, h )
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 )

if ( a ) then
	surface.DrawTexturedRectRotated( x + bordersize/2 , y + bordersize/2, bordersize, bordersize, 0 ) 
	surface.DrawRect( x, y, bordersize, bordersize )

if ( b ) then
	surface.DrawTexturedRectRotated( x + w - bordersize/2 , y + bordersize/2, bordersize, bordersize, 270 ) 
	surface.DrawRect( x + w - bordersize, y, bordersize, bordersize )

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 ) 


if you notice, only the top two corners are affected. If you look at the first two boolean values passed, they are correct. The problem is that the bottom two corners are always rounded.


It looks intentional, only a and b are ever checked in the code.

Last 2 arguments are ignored?


Thats kind of odd, hope garry can revise it soon.