Bitmap/Midpoint circle algorithm: Difference between revisions
Content added Content deleted
m (added whitespace.) |
(Replaced "initImage" by "newImage" (change in "bitmap.nim" interface).) |
||
Line 1,455: | Line 1,455: | ||
<lang Nim>import bitmap |
<lang Nim>import bitmap |
||
proc setPixel(img: |
proc setPixel(img: Image; x, y: int; color: Color) {.inline.} = |
||
# Set a pixel at a given color. |
# Set a pixel at a given color. |
||
# Ignore if the point is outside of the image. |
# Ignore if the point is outside of the image. |
||
Line 1,462: | Line 1,462: | ||
proc drawCircle(img: |
proc drawCircle(img: Image; center: Point; radius: Natural; color: Color) = |
||
## Draw a circle using midpoint circle algorithm. |
## Draw a circle using midpoint circle algorithm. |
||
Line 1,498: | Line 1,498: | ||
when isMainModule: |
when isMainModule: |
||
var img = |
var img = newImage(16, 16) |
||
img.fill(White) |
img.fill(White) |
||
img.drawCircle((7, 7), 5, Black) |
img.drawCircle((7, 7), 5, Black) |