1*19971Sdist /* 2*19971Sdist * Copyright (c) 1980 Regents of the University of California. 3*19971Sdist * All rights reserved. The Berkeley software License Agreement 4*19971Sdist * specifies the terms and conditions for redistribution. 5*19971Sdist */ 6*19971Sdist 715442Sralph #ifndef lint 8*19971Sdist static char sccsid[] = "@(#)subr.c 5.1 (Berkeley) 05/07/85"; 9*19971Sdist #endif not lint 1015442Sralph 1115442Sralph #include "dumb.h" 1215442Sralph 1315442Sralph /* Does not plot first point -- assumed that it is already plotted */ 1415442Sralph dda_line(ch, x0, y0, x1, y1) 1515442Sralph char ch; 1615442Sralph int x0, y0; /* already transformed to screen coords */ 1715442Sralph int x1, y1; /* untransformed */ 1815442Sralph { 1915442Sralph int length, i; 2015442Sralph double deltaX, deltaY; 2115442Sralph double x, y; 2215442Sralph double floor(); 2315442Sralph int abs(); 2415442Sralph 2515442Sralph scale(x1, y1); 2615442Sralph 2715442Sralph length = abs(x1 - x0); 2815442Sralph if (abs(y1 -y0) > length) 2915442Sralph length = abs(y1 - y0); 3015442Sralph 3115442Sralph if (length == 0) 3215442Sralph return; 3315442Sralph 3415442Sralph deltaX = (double) (x1 - x0)/(double) length; 3515442Sralph deltaY = (double) (y1 - y0)/(double) length; 3615442Sralph 3715442Sralph x = (double) x0 + 0.5; 3815442Sralph y = (double) y0 + 0.5; 3915442Sralph 4015442Sralph for (i=0; i < length; ++i) { 4115442Sralph x += deltaX; 4215442Sralph y += deltaY; 4315442Sralph x0 = floor(x); 4415442Sralph y0 = floor(y); 4515442Sralph currentx = x0; 4615442Sralph currenty = y0; 4715442Sralph screenmat[currentx][currenty] = ch; 4815442Sralph } 4915442Sralph } 50