148505Sbostic /*-
261365Sbostic * Copyright (c) 1980, 1993
361365Sbostic * The Regents of the University of California. All rights reserved.
448505Sbostic *
548505Sbostic * %sccs.include.proprietary.c%
619971Sdist */
719971Sdist
815442Sralph #ifndef lint
9*65570Sbostic static char sccsid[] = "@(#)subr.c 8.2 (Berkeley) 01/07/94";
1048505Sbostic #endif /* not lint */
1115442Sralph
1215442Sralph #include "dumb.h"
1315442Sralph
1415442Sralph /* Does not plot first point -- assumed that it is already plotted */
dda_line(ch,x0,y0,x1,y1)1515442Sralph dda_line(ch, x0, y0, x1, y1)
1615442Sralph char ch;
1715442Sralph int x0, y0; /* already transformed to screen coords */
1815442Sralph int x1, y1; /* untransformed */
1915442Sralph {
2015442Sralph int length, i;
2115442Sralph double deltaX, deltaY;
2215442Sralph double x, y;
2315442Sralph
2415442Sralph scale(x1, y1);
2515442Sralph
2615442Sralph length = abs(x1 - x0);
2715442Sralph if (abs(y1 -y0) > length)
2815442Sralph length = abs(y1 - y0);
2915442Sralph
3015442Sralph if (length == 0)
3115442Sralph return;
3215442Sralph
3315442Sralph deltaX = (double) (x1 - x0)/(double) length;
3415442Sralph deltaY = (double) (y1 - y0)/(double) length;
3515442Sralph
3615442Sralph x = (double) x0 + 0.5;
3715442Sralph y = (double) y0 + 0.5;
3815442Sralph
3915442Sralph for (i=0; i < length; ++i) {
4015442Sralph x += deltaX;
4115442Sralph y += deltaY;
4215442Sralph x0 = floor(x);
4315442Sralph y0 = floor(y);
4415442Sralph currentx = x0;
4515442Sralph currenty = y0;
4615442Sralph screenmat[currentx][currenty] = ch;
4715442Sralph }
4815442Sralph }
49