June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -1,4 +1,4 @@
|
|||
/*REXX program plots/draws (ASCII) a line using the Xiaolin Wu line algorithm. */
|
||||
/*REXX program plots/draws (ASCII) a line using the Xiaolin Wu line algorithm. */
|
||||
background= '·' /*background character: a middle-dot. */
|
||||
image.= background /*fill the array with middle-dots. */
|
||||
plotC= '░▒▓█' /*characters used for plotting points. */
|
||||
|
|
@ -17,11 +17,11 @@ minX=0; minY=0 /*use these as the limits for p
|
|||
maxX=0; maxY=0 /* " " " " " " " */
|
||||
call drawLine xi, yi, xf, yf /*invoke subroutine and graph the line.*/
|
||||
border=2 /*allow additional space (plot border).*/
|
||||
minX=minX - border * 2; maxX=maxX+border * 2 /*preserve screen's aspect ratio {*2}.*/
|
||||
minY=minY - border ; maxY=maxY+border
|
||||
do y=maxY to minY by -1; _= /*construct a row.*/
|
||||
do x=minX to maxX; _=_ || image.x.y; end /*x*/
|
||||
say _ /*display the constructed row to term. */
|
||||
minX=minX - border * 2; maxX=maxX + border * 2 /*preserve screen's aspect ratio {*2}.*/
|
||||
minY=minY - border ; maxY=maxY + border
|
||||
do y=maxY to minY by -1; $= /*construct a row.*/
|
||||
do x=minX to maxX; $=$ || image.x.y; end /*x*/
|
||||
say $ /*display the constructed row to term. */
|
||||
end /*y*/ /*graph is cropped by the MINs and MAXs*/
|
||||
exit /*stick a fork in it, we're all done. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
|
|
@ -42,19 +42,19 @@ drawLine: parse arg x1,y1,x2,y2; switchXY=0; dx=x2-x1
|
|||
call plotXY xpx12, ypx12 , brite(1 - fpart(yend*xgap)), switchXY
|
||||
call plotXY xpx12, ypx12+1, brite( fpart(yend*xgap)), switchXY
|
||||
|
||||
do x=xpx11+1 to xpx12-1 /*◄───draw the line.═════════════*/
|
||||
!intery=floor(intery)
|
||||
call plotXY x, !intery , brite(1 - fpart(intery)), switchXY
|
||||
call plotXY x, !intery+1, brite( fpart(intery)), switchXY
|
||||
intery=intery + gradient
|
||||
end /*x*/
|
||||
do x=xpx11+1 to xpx12-1 /*◄═════════════════draw the line.═════════════*/
|
||||
!intery=floor(intery)
|
||||
call plotXY x, !intery , brite(1 - fpart(intery)), switchXY
|
||||
call plotXY x, !intery+1, brite( fpart(intery)), switchXY
|
||||
intery=intery + gradient
|
||||
end /*x*/
|
||||
return
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
brite: return substr(background || plotC, 1 + round( abs( arg(1) ) * length(plotC)), 1)
|
||||
floor: parse arg ?; _=trunc(?); return _ - (?<0) * (?\=_)
|
||||
fpart: parse arg ?; return abs(? - trunc(?))
|
||||
floor: parse arg #; _=trunc(#); return _ - (#<0) * (#\=_)
|
||||
fpart: parse arg #; return abs(# - trunc(#) )
|
||||
round: return format(arg(1), , word(arg(2) 0, 1) )
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
plotXY: parse arg xx,yy,bc,switchYX; if switchYX then parse arg yy,xx
|
||||
image.xx.yy=bc; minX=min(minX, xx); maxX=max(maxX,xx)
|
||||
minY=min(minY, yy); maxY=max(maxY,yy); return
|
||||
image.xx.yy=bc; minX=min(minX, xx); maxX=max(maxX,xx)
|
||||
minY=min(minY, yy); maxY=max(maxY,yy); return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue