TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: MIKE PONTILLO
from: HERMAN SCHONFELD
date: 1997-03-16 12:29:00
subject: line()?

MP> * Original message posted in area Fidonet: C programming
MP> * Cross posted to area Fidonet: Pascal Support
MP>                        Fidonet: C++ programming
MP>hi all,
MP>       anyone have some pascal/c source for a nice line() graphics
MP>function
MP>that uses direct memory access, or a putpixel routine?  all i need it to
MP>do
MP>is draw a line in a VGA mode, no more.
MP>thanks,
Procedure Line(a,b,c,d:integer;col:byte;where:word);
  { This draws a solid line from a,b to c,d in colour col }
  function sgn(a:real):integer;
  begin
       if a>0 then sgn:=+1;
       if a<0 then sgn:=-1;
       if a=0 then sgn:=0;
  end;
var i,s,d1x,d1y,d2x,d2y,u,v,m,n:integer;
begin
     u:= c - a;
     v:= d - b;
     d1x:= SGN(u);
     d1y:= SGN(v);
     d2x:= SGN(u);
     d2y:= 0;
     m:= ABS(u);
     n := ABS(v);
     IF NOT (M>N) then
     BEGIN
          d2x := 0 ;
          d2y := SGN(v);
          m := ABS(v);
          n := ABS(u);
     END;
     s := m shr 1;
     FOR i := 0 TO m DO
     BEGIN
          putpixel(a,b,col,where);
          s := s + n;
          IF not (s * Origin: Fox's Lair BBS Bris Aus +61-7-38033908 V34+ Node 2 (3:640/238)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.