Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,36 @@
|
|||
/* Draw a line from (x0, y0) to (x1, y1). 13 May 2010 */
|
||||
/* Based on Rosetta code proforma. */
|
||||
|
||||
/* Declarations for image and selected color, for 4-bit colors. */
|
||||
declare image(40,40) bit (4), color bit (4) static initial ('1000'b);
|
||||
|
||||
draw_line: procedure (xi, yi, xf, yf );
|
||||
declare (xi, yi, xf, yf) fixed binary (31) nonassignable;
|
||||
declare (x0, y0, x1, y1) fixed binary (31);
|
||||
declare (deltax, deltay, x, y, ystep) fixed binary;
|
||||
declare (error initial (0), delta_error) float;
|
||||
declare steep bit (1);
|
||||
|
||||
x0 = xi; y = YI; y0 = yi; x1 = xf; y1 = yf;
|
||||
steep = abs(y1 - y0) > abs (x1 - x0);
|
||||
if steep then
|
||||
do; call swap (x0, y0); call swap (x1, y1); end;
|
||||
if x0 > x1 then
|
||||
do; call swap (x0, x1); call swap (y0, y1); end;
|
||||
deltax = x1 - x0; deltay = abs(y1 - y0);
|
||||
delta_error = deltay/deltax;
|
||||
if y0 < y1 then ystep = 1; else ystep = -1;
|
||||
do x = x0 to x1;
|
||||
if steep then image(y, x) = color; else image(x, y) = color;
|
||||
if steep then put skip list (y, x); else put skip list (x, y);
|
||||
error = error + delta_error;
|
||||
if error >= 0.5 then do; y = y + ystep; error = error - 1; end;
|
||||
end;
|
||||
|
||||
swap: procedure (a, b);
|
||||
declare (a, b) fixed binary (31);
|
||||
declare t fixed binary (31);
|
||||
t = a; a = b; b = t;
|
||||
end swap;
|
||||
|
||||
end draw_line;
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
..........|..........
|
||||
..........|..........
|
||||
..........|..........
|
||||
..........|..........
|
||||
..........|..........
|
||||
..........|..........
|
||||
..........|.........*
|
||||
..........|.......**.
|
||||
..........|.....**...
|
||||
..........|...**.....
|
||||
----------+-**-------
|
||||
..........**.........
|
||||
........**|..........
|
||||
.......*..|..........
|
||||
..........|..........
|
||||
..........|..........
|
||||
..........|..........
|
||||
..........|..........
|
||||
..........|..........
|
||||
..........|..........
|
||||
..........|..........
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
*process source xref or(!);
|
||||
brbn:Proc Options(main);
|
||||
/*********************************************************************
|
||||
* 21.05.2014 Walter Pachl
|
||||
* Implementing the pseudo code of
|
||||
* http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm
|
||||
* under 'Simplification' (see also REXX version 2)
|
||||
*********************************************************************/
|
||||
grid.=
|
||||
dcl image(-2:7,-4:11) char(1);
|
||||
image='.';
|
||||
image(*,0)='-';
|
||||
image(0,*)='|';
|
||||
image(0,0)='+';
|
||||
call draw_line(-1,-3,6,10);
|
||||
Dcl (i,j) Bin Fixed(31);
|
||||
Do j=11 To -4 By -1;
|
||||
Put Edit(j,' ')(Skip,f(2),a);
|
||||
Do i=-2 To 7;
|
||||
Put Edit(image(i,j))(a);
|
||||
End;
|
||||
End;
|
||||
Put Edit(' 2101234567')(Skip,a);
|
||||
|
||||
draw_line: procedure (x0,y0,x1,y1);
|
||||
dcl (x0,y0,x1,y1) fixed binary(31);
|
||||
dcl (dx,dy,sx,sy,err,e2) fixed binary(31);
|
||||
|
||||
dx = abs(x1-x0);
|
||||
dy = abs(y1-y0);
|
||||
if x0 < x1 then sx = 1;
|
||||
else sx = -1;
|
||||
if y0 < y1 then sy = 1;
|
||||
else sy = -1;
|
||||
err = dx-dy;
|
||||
|
||||
Do Until(x0=x1&y0=y1);
|
||||
image(x0,y0)='X';
|
||||
e2=err*2;
|
||||
if e2>-dy then do;
|
||||
err=err-dy;
|
||||
x0=x0+sx;
|
||||
End;
|
||||
if e2<dx then do;
|
||||
err=err+dx;
|
||||
y0=y0+sy;
|
||||
End;
|
||||
End;
|
||||
image(x0,y0)='X';
|
||||
end;
|
||||
end;
|
||||
Loading…
Add table
Add a link
Reference in a new issue