Found some code in the archives
http://www.blitzbasic.com/codearcs/codearcs.php?code=402
Modified it to work as you described.
Andy
http://www.blitzbasic.com/codearcs/codearcs.php?code=402
Modified it to work as you described.
Andy
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Rounded Rectangles ; ; Stephen C. Demuth -- sdemuth@... ; August 22, 2002 ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Modified for smooth shading by Andy Amaya ; February 12, 2004 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sw = 800 sh = 600 Graphics sw, sh SetBuffer BackBuffer() SeedRnd(MilliSecs()) While KeyHit(1) = 0 Cls() Color 255,255,255 Text 0,0,"Press a key for random rectangle" Text 0,20,"Press ESC to exit" r = 255 g = 255 b = 255 wide = Rand(100,350)*2 high = Rand(100,150)*2 x = (sw - wide)/2 y = (sh - high)/2 For rad = 50 To 10 Step -1 Color r,g,b RRect (x, y, wide, high, rad) r = r - 6 g = g - 6 b = b - 6 x = x + 1 y = y + 1 wide = wide - 2 high = high - 2 Next Flip() WaitKey Wend End ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; RRect(x,y,width,height,radius=5) ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Function RRect(x,y,width,height,radius=5) If radius > width/2 Then radius = width/2 If radius > height/2 Then radius = height/2 ;---DRAW BORDERS Line x+radius,y,x+width-radius,y ;Top Line x+radius,y+height,x+width-radius,y+height ;Bottom Line x,y+radius,x,y+height-radius ;Left Line x+width,y+radius,x+width,y+height-radius ;Right ;---DRAW CORNERS ;Upper Left For deg = 90 To 180 yp = Sin(deg) * radius * -1 + y + radius xp = Cos(deg) * radius + x + radius Oval xp-1,yp-1,2,2,1 ; Plot xp,yp Next ;Lower Left For deg = 180 To 270 yp = Sin(deg) * radius * -1 + y + height - radius xp = Cos(deg) * radius + x + radius Oval xp-1,yp-1,2,2,1 ; Plot xp,yp Next ;Upper Right For deg = 0 To 90 yp = Sin(deg) * radius * -1 + y + radius xp = Cos(deg) * radius + x + width - radius Oval xp-1,yp-1,2,2,1 ; Plot xp,yp Next ;Lower Right For deg = 270 To 359 yp = Sin(deg) * radius * -1 + y + height - radius xp = Cos(deg) * radius + x + width - radius Oval xp-1,yp-1,2,2,1 ; Plot xp,yp Next ;Adjustment Line x+radius,y-1,x+width-radius,y-1 ;Top Line x+radius,y+height+1,x+width-radius,y+height+1 ;Bottom Line x-1,y+radius,x-1,y+height-radius ;Left Line x+width+1,y+radius,x+width+1,y+height-radius ;Right End Function