/*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. */ EoE= 3000 /*EOE = End Of Earth, er, ··· graph. */ do j=-EoE to +EoE /*define the graph: lowest ──► highest.*/ image.j.0= '─' /*define the graph's horizontal axis. */ image.0.j= '│' /* " " " verical " */ end /*j*/ image.0.0= '┼' /*define the graph's axis origin (char)*/ parse arg xi yi xf yf . /*allow specifying the line-end points.*/ if xi=='' | xi=="," then xi= 1 /*Not specified? Then use the default.*/ if yi=='' | yi=="," then yi= 2 /* " " " " " " */ if xf=='' | xf=="," then xf=11 /* " " " " " " */ if yf=='' | yf=="," then yf=12 /* " " " " " " */ minX=0; minY=0 /*use these as the limits for plotting.*/ 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. */ end /*y*/ /*graph is cropped by the MINs and MAXs*/ exit /*stick a fork in it, we're all done. */ /*──────────────────────────────────────────────────────────────────────────────────────*/ drawLine: parse arg x1,y1,x2,y2; switchXY=0; dx=x2-x1 dy=y2-y1 if abs(dx)