Anonymous user
Bitmap/Midpoint circle algorithm: Difference between revisions
Bitmap/Midpoint circle algorithm (view source)
Revision as of 12:32, 31 December 2012
, 11 years agoUpdated D entry
(Updated D entry) |
|||
Line 305:
=={{header|D}}==
Uses the second Image implementation.
<lang d>import
void circle(Image img, in int x0, in int y0, in int radius,
in Color color) pure nothrow {
int f = 1 - radius;
int
int
int x = 0;
int y = radius;
Line 321 ⟶ 322:
if (f >= 0) {
y--;
f +=
}
x++;
f +=
img[y0 + y][x0 + x] = color;
img[y0 + y][x0 - x] = color;
Line 340 ⟶ 341:
void main() {
auto img = new Image(25, 25);
circle(img, 12, 12, 12, Color.
img.textualShow();
}</lang>
{{out}}
<pre>.........#######.........
.......##.......##.......
|