Bitmap/Midpoint circle algorithm: Difference between revisions

Content added Content deleted
(→‎{{header|REXX}}: added/changed whitespace and comments, simplified the subroutines.)
m (→‎{{header|REXX}}: changed a program comment, added/changed comments in the REXX section header.)
Line 1,474: Line 1,474:
<br>vertical direction because characters are "taller" than they're "wide", so this REXX version attempts to maintain
<br>vertical direction because characters are "taller" than they're "wide", so this REXX version attempts to maintain
<br>a good aspect ratio.
<br>a good aspect ratio.

The program automatically shows all of the plot's points by finding the minimum and maximum X,Y coördinates.
<lang rexx>/*REXX program plots three circles using midpoint/Bresenham's circle algorithm*/
<lang rexx>/*REXX program plots three circles using midpoint/Bresenham's circle algorithm*/
@. = '·' /*fill the array with middle─dots char.*/
@. = '·' /*fill the array with middle─dots char.*/
Line 1,497: Line 1,499:
/*────────────────────────────────────────────────────────────────────────────*/
/*────────────────────────────────────────────────────────────────────────────*/
drawCircle: procedure expose @. minX maxX minY maxY /* [↓] Y is defined as R*/
drawCircle: procedure expose @. minX maxX minY maxY /* [↓] Y is defined as R*/
parse arg xx,yy,r 1 y,plotChar; f=1-r; fx=1; fy=-2*r /*get the X,Y coordinates*/
parse arg xx,yy,r 1 y,plotChar; f=1-r; fx=1; fy=-2*r /*get the X,Y coördinates*/


do x=0 while x<y /*▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒*/
do x=0 while x<y /*▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒*/
Line 1,518: Line 1,520:
return</lang>
return</lang>
{{out}}
{{out}}
<pre>
<pre style="height:70ex">
·······················│·······················
·······················│·······················
·······················│·······················
·······················│·······················