1 /* Loglan82 Compiler&Interpreter
\r
2 Copyright (C) 1981-1993 Institute of Informatics, University of Warsaw
\r
3 Copyright (C) 1993, 1994 LITA, Pau
\r
5 This program is free software; you can redistribute it and/or modify
\r
6 it under the terms of the GNU General Public License as published by
\r
7 the Free Software Foundation; either version 2 of the License, or
\r
8 (at your option) any later version.
\r
10 This program is distributed in the hope that it will be useful,
\r
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 GNU General Public License for more details.
\r
15 =======================================================================
\r
21 void pascal draw( _col, _row )
24 int X1 = inxpos(NULL);
25 int Y1 = inypos(NULL);
30 int dX, dY, /* vector components */
32 final, /* final row or col number */
33 G, /* used to test for new row or column */
34 inc1, /* G increment when row or column doesn't change */
35 inc2; /* G increment when row or column does change */
45 dX = X2 - X1; dY = Y2 - Y1; /* find vector component */
46 pos_slope = (dX > 0); /* is slope positive? */
47 if (dY < 0) pos_slope = !pos_slope;
48 if (abs(dX) > abs(dY)) { /* shallow line case */
49 if (dX > 0) { /* determine start point and last column */
50 col = X1; row = Y1; final = X2;
52 col = X1; row = Y2; final = X1;
54 inc1 = 2*abs(dY); /* determine increments and initial G */
56 inc2 = 2 * (abs(dY) - abs(dX));
58 while (col<=final) { /* step thru cols. checking for new row */
61 if (G >= 0) { /* it's time to change rows */
62 row++; G+= inc2; /* positive slope, so inc thru rows */
63 } else /* stay at the same row */
67 while (col<=final) { /* step thru cols, check for new row */
70 if (G > 0) { /* time to change the rows */
71 row--; G+= inc2; /* negative slope, dec thru rows */
73 G += inc1; /* stay at the same row */
75 } /* if |dX| > |dY| */ else {
76 if (dY > 0) { /* steep line case, angle > 45 degree */
77 col = X1; row = Y1; final = Y2; /* find start point and last row */
79 col = X2; row = Y2; final = Y1;
81 inc1 = 2 * abs(dX); /* determine increments and initial G */
83 inc2 = 2 * (abs(dX) - abs(dY));
85 while (row <= final) { /* step thru rows - check for new column */
88 if (G >= 0) { /* it's time to change columns */
89 col++; G+= inc2; /* pos. slope, increment thru cols. */
91 G += inc1; /* stay at the same column */
94 while (row <= final) {/* step thru rows, checking for new column */
97 if (G > 0) { /* it's time to change columns */
98 col--; G+= inc2; /* neg slope, so decrement thru columns */
100 G += inc1; /* stay at the same column */
102 } /* if |dY| > |dX| */