Bitmap/Midpoint circle algorithm: Difference between revisions

Content added Content deleted
(Updated D entry)
m ({{out}})
Line 1: Line 1:
{{task|Raster graphics operations}}Using the data storage type defined [[Basic_bitmap_storage|on this page]] for raster images, write an implementation of the '''midpoint circle algorithm''' (also known as '''Bresenham's circle algorithm'''). <BR>
{{task|Raster graphics operations}}Using the data storage type defined [[Basic_bitmap_storage|on this page]] for raster images,
write an implementation of the '''midpoint circle algorithm'''
(also known as '''Bresenham's circle algorithm'''). <BR>
([[wp:Midpoint_circle_algorithm|definition on Wikipedia]]).
([[wp:Midpoint_circle_algorithm|definition on Wikipedia]]).

=={{header|Ada}}==
=={{header|Ada}}==
<lang ada>procedure Circle
<lang ada>procedure Circle
Line 43: Line 46:
Circle (X, (8, 8), 5, Black);
Circle (X, (8, 8), 5, Black);
Print (X);</lang>
Print (X);</lang>
{{out}}
Sample output:
<pre>
<pre>


Line 118: Line 121:
(print OF class image)(x)
(print OF class image)(x)
)</lang>
)</lang>
{{out}}
'''Output:'''
<pre>
<pre>
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
Line 1,042: Line 1,045:
END CIRCLE;
END CIRCLE;
</lang>
</lang>
Output for three circles centered at the origin.
{{out}} for three circles centered at the origin.
<lang>
<pre>
....................|....................
....................|....................
................2222*1111................
................2222*1111................
Line 1,085: Line 1,088:
................5555*6666................
................5555*6666................
....................|....................
....................|....................
</lang>
</pre>


=={{header|PureBasic}}==
=={{header|PureBasic}}==
Line 1,200: Line 1,203:
+-------------------------+
+-------------------------+
'''
'''

</lang>
</lang>


Line 1,297: Line 1,299:
minY=min(minY,yy); maxY=max(maxY,yy)
minY=min(minY,yy); maxY=max(maxY,yy)
return</lang>
return</lang>
{{out}}
'''output'''
<pre style="height:70ex">
<pre style="height:70ex">
·······················│·······················
·······················│·······················