1*15442Sralph #ifndef lint 2*15442Sralph static char sccsid[] = "@(#)subr.c 4.1 (Berkeley) 11/10/83"; 3*15442Sralph #endif 4*15442Sralph 5*15442Sralph #include "dumb.h" 6*15442Sralph 7*15442Sralph /* Does not plot first point -- assumed that it is already plotted */ 8*15442Sralph dda_line(ch, x0, y0, x1, y1) 9*15442Sralph char ch; 10*15442Sralph int x0, y0; /* already transformed to screen coords */ 11*15442Sralph int x1, y1; /* untransformed */ 12*15442Sralph { 13*15442Sralph int length, i; 14*15442Sralph double deltaX, deltaY; 15*15442Sralph double x, y; 16*15442Sralph double floor(); 17*15442Sralph int abs(); 18*15442Sralph 19*15442Sralph scale(x1, y1); 20*15442Sralph 21*15442Sralph length = abs(x1 - x0); 22*15442Sralph if (abs(y1 -y0) > length) 23*15442Sralph length = abs(y1 - y0); 24*15442Sralph 25*15442Sralph if (length == 0) 26*15442Sralph return; 27*15442Sralph 28*15442Sralph deltaX = (double) (x1 - x0)/(double) length; 29*15442Sralph deltaY = (double) (y1 - y0)/(double) length; 30*15442Sralph 31*15442Sralph x = (double) x0 + 0.5; 32*15442Sralph y = (double) y0 + 0.5; 33*15442Sralph 34*15442Sralph for (i=0; i < length; ++i) { 35*15442Sralph x += deltaX; 36*15442Sralph y += deltaY; 37*15442Sralph x0 = floor(x); 38*15442Sralph y0 = floor(y); 39*15442Sralph currentx = x0; 40*15442Sralph currenty = y0; 41*15442Sralph screenmat[currentx][currenty] = ch; 42*15442Sralph } 43*15442Sralph } 44