how to draw a rounded filled rect
BlitzMax Forums/BlitzMax Programming/how to draw a rounded filled rect
| ||
I would like to draw a rounded filled rect, without making circles and boxes (becouse if I make circles and boxes, the result si not alpha-compatible. Any suggestion on how to do that? |
| ||
When BMAX draws a shape it's actually creating a surface from polygons, becuase the polygonal surface is not textured, and BMAX does not allow edge antialiasing, you will get pixelated edges. I suggest you try using textured polygons of just use a simple image. |
| ||
If you wanted it as a simple DrawRoundRect() function you could possibly make a series of images put together on each draw call. like a top left round corner, top right, middle, etc. that way you can scale the center image without having skewed corners. |
| ||
didn't you ask for this before <edit> Oopps just saw the bit about circles/rects. <edit> Can you still use them then grab them... Function DrawRoundRect:TImage(x:Int, y:Int, width:Int, height:Int, radius:Int) DrawOval(x, y, radius, radius) DrawOval(x + (width - (radius)), y, radius, radius) DrawOval(x, y + (height - (radius)), radius, radius) DrawOval(x + (width - (radius)), y + (height - (radius)), radius, radius) DrawRect(x + (radius / 2), y, width - radius, height) DrawRect(x, y + (radius / 2), width, height - radius) Return LoadImage(GrabPixmap(100,100,100,100),FILTEREDIMAGE|MIPMAPPEDIMAGE) End Function Graphics 640,480 'drawroundrect(100,100,100,100,10) 'image:TImage=LoadImage(GrabPixmap(100,100,100,100),FILTEREDIMAGE|MIPMAPPEDIMAGE) image:TIMAGE=drawroundrect(100,100,100,100,10) Cls DrawImage image,0,0 Flip WaitKey() |
| ||
@Tonyg: I'll try it this way, but just another question: How can I make anti-aliased borders? (I think in OpenGL there's a simple flag, but in DX...) |
| ||
const D3DRS_EDGEANTIALIAS=40 PrimaryDevice.device.SetRenderState D3DRS_EDGEANTIALIAS,True More here |
| ||
@tonig: It's not working, I can't preserve the alpha channel of the corners... Any other suggestion? |
| ||
Indie's render-to-texture would be able to do it. |
| ||
Indie's example in TonyG's link doesn't work for me either. I just get a jagged line:Const D3DRS_EDGEANTIALIAS=40 Graphics 640,480,0,60 SetBlend(ALPHABLEND) PrimaryDevice.device.SetRenderState D3DRS_EDGEANTIALIAS,True DrawLine 10,10,100,600 Flip WaitKey() |
| ||
Wasn't that believed to be a graphics card specific issue similar to the antialias issue on B3D? |
| ||
You could just do custom OpenGL and create a triangle strip which runs around the edge of a rectangle - when it gets to a corner it attaches the inside edge to the corner and curves around it. |