Line Drawing withough BGI Help 
Author Message
 Line Drawing withough BGI Help

  Hi all! I just had a question about drawing lines directly to video.
I have succesfully written a horiz, and vert line procedures in
assembly and am now trying to make line drawing procedure that can
handle sloped lines. This is what I came up with and was wondering if
anyone had suggestions on ways of optimising it..

procedure Line( x1,y1,x2,y2 : integer;col : byte);
  var Xdist,Ydist,
      x,y,inc          : integer;
  begin
      Xdist := abs(x2-x1);
      Ydist := abs(y2-y1);

      if xdist = 0 then
         HorizLine(x1,y1,y2,col)
      else if ydist = 0 then
         VertLine(x1,y1,x2,col)
      else
        begin
          if x1 > x2 then
            begin
              x  := x1;
              x1 := x2;
              x2 := x;
            end;
          if y1 > y2 then
            begin
              y  := y1;
              y1 := y2;
              y2 := y;
            end;

         if xdist >= ydist then
            begin
              inc := round(xdist / ydist);
              x := x1;
                for y := y1 to y2 do
                  begin
                    for x := x to x+inc do
                      putpixel(x,y,col);

                  end;
           end
        else
           begin
             inc := round(ydist / xdist);
             y := y1;
               for x := x1 to x2 do
                 begin
                   for y := y to y+inc do
                      putpixel(x,y,col);
                 end;
           end;
       end;

 end;


=Brent Hostetler ============================
================== www.kaiwan.com/~brenth ===
+===========================================+



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. BGI Arc Drawing

2. Draw a line in array

3. Efficient way to draw lines

4. Fast way to draw a line?

5. line drawing under modes x

6. Blank line between lines: HELP!

7. HELP --> How do you draw boxes or lines to make boxes in TPW 1.5

8. Graphics - need help on how to draw...

9. Help with overriding TRadioButtons.Draw

10. Help with overriding TRadioButtons.Draw

11. Grid custom draw - urgent help needed

12. Help! ComboBox do not draw DropDownList

 

 
Powered by phpBB® Forum Software