![]() |
|
Drawing Rounded Rects |
DanielH
Member #934
January 2001
![]() |
I looking for a way to draw a rounded rect given the radius and the thickness of the lines. Here is my code. I could have just done a circlefill instead of putpixels, but I want the rectangle to be contained in x1y1-x2y2. So the thicker I increase the thickness, the rectangle stays the same size. Just the thickness of the lines changes. Here is a screenshot with radius=16, thickness=12,color=black
I wanted to give more than just the color to do_line and do_arc. I wanted to add a thickness. So I created a struct and sent the struct instead. Does anyone have a better way to do this? |
Johan Halmén
Member #1,550
September 2001
|
Your inner radius is same as outer radius. The arches have different middle points. So the thickness is not constant. It doesn't look bad, but I'd draw them with same center point. Guess my approach would to draw four rectangles forming the straight edges. Then I'd use quadratic bitmaps for the corners. I'd start with magic pink for the quadrates, then I'd draw a black larger circle and a magenta smaller circle, both with centre in the corner of the quadrate. Then I'd transparent blit the quadrate to the right place. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest. |
DanielH
Member #934
January 2001
![]() |
I thought about using one bitmap for the corners, but wouldn't creating it, drawing to it, and blitting it be more time consuming? |
Fladimir da Gorf
Member #1,565
October 2001
![]() |
Quote: Does anyone have a better way to do this?
ol::Rect( x, y, w, h, thickness, roundness ).Draw( color );
Seriously though... Quote: I thought about using one bitmap for the corners, but wouldn't creating it, drawing to it, and blitting it be more time consuming? You mean, more time-consuming than to call rectfill per each pixel through a function pointer? The best way would be to rip Allegro's circle code and modify that to draw your thick edges - all 4 at the same time as they're mirror images of each other. OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori) |
|