In my project i need to implement circle and ellipse rasterization (in C++ or in assembly + SIMD if possible). I know about midpoint circle algorithm and Bresenham's circle algorithm. But these algorithms work with integer values (center x, center y and radius). In my case radius and center must be expressed in floating-point format (or at least fixed point). And also radius can be less than 1px. So i need an algorithm that works with floating point values. Can somebody help me?
Asked
Active
Viewed 1,555 times
1
-
2Even if your coordinates are expressed in floating-point format, you can round any floating-point number to an integer. Also, rasterization implies that you are working with integers (you convert a vector image to pixels). You can round floating point numbers to integers. – berendeanicolae Dec 19 '16 at 17:44
-
Why floating point? Can you access 0.152 of a pixel? – Thomas Matthews Dec 19 '16 at 17:49
-
I suppose one might discus 0.152 of a pixel if one were talking something like font smoothing. But I doubt that's it. – infixed Dec 19 '16 at 18:00
-
I'm working on a drawing app for Android. I need to draw many circles along the Bezier curve with a very good quality. – Igor Yarmolyk Dec 19 '16 at 18:04
-
If you already have an algorithm to draw bezier curves, you can approximate circles and ellipses well with bezier curves: http://stackoverflow.com/questions/1734745/how-to-create-circle-with-b%C3%A9zier-curves – samgak Dec 19 '16 at 19:30
-
are you talking about empty circler/ellipses or filled ? are those ellipses axis aligned? Do you want sub-pixel precision of output? For filled circle/ellipses is also a raw 2D filling with inside condition a possibility (can even beat Bresenham even on floats if coded right due to modern architectures and is easily parallelisable). You mentioned Android are there any gfx access restrictions and performance hits on targeted devices? – Spektre Dec 20 '16 at 08:17
-
I'm talking about filled circles/ellipses with antialiased edges. Ellipses may be rotated around the center – Igor Yarmolyk Dec 20 '16 at 17:59
1 Answers
-1
According to Wikipedia's Bresenham's algorithm, it's thought to draw a circle in the pixels of the screen.
That's the reason why you can base the calculations of your circle in floating point numbers, putting the center in any not-integer place, with any not-integer radius, and your circle will be drawn exactly into integer pixel places.
fernando.reyes
- 597
- 2
- 15