Delphi32.com - Home!
| Home/News | Downloads | Forums | D32 Magazine | Resources | Info and Facts |  
 
 How do I plot a line?


How do I plot a line?   

    The easiest way to step along each point in a line segment is to call the Windows API function LineDDA(). LineDDA() takes the x and y start and end points of the line you wish to plot, and the address of a function in your program, and calls this function for each pixel that needs to be drawn. LineDDA() accepts an additional parameter "LParam" that gets passed back to your function each time it is called. The value of LParam can be anything you wish, and is useful for passing handles and pointers. Some typecasting of this parameter may be necessary to achieve the functionality you desire.

    The following example shows how to plot a line from 0, 0 to 00, 00, and draw a circle along the line if the x coordinate of the pixel position is an even multiple of 0.

    Example:

    procedure DDAProc(x : integer; y : integer; LParam : LongInt) {$IFDEF WIN32} stdcall; {$ELSE} ; export; {$ENDIF} begin if x mod 0 = 0 then TCanvas(LParam).Ellipse(x - 0, y - 0, x + 0, y + 0); end;

    procedure TForm .Button Click(Sender: TObject); begin LineDDA( 0, 0, 00, 00, @DDAProc, {$IFDEF WIN32} LongInt(Form .Canvas) {$ELSE} Form .Canvas {$ENDIF} ); end;

    7/ 6/98 4:3 :28 PM

     



  << Previous Faq     Complete List     Next Faq >>  



 
 Hits/month  2,500,000+ 
 Downloads
 (Since May 2000)
 7,393,709 
 Total Files  6,023 
 Forum msgs  7,670 
 Articles/FAQs  70+/900+ 
Kylix
Tips n Tricks
FAQs
Knowledge Base
Bug Listings
Articles
Books
Newsgroups
Links
Submissions
Testimonials
Advertising
Contact Us
About Us
Search Amazon:
Top Selling Software at Amazon

| Home/News | Downloads | Forums | Resources | Info and Facts | Testimonials |
  Site Search:
 


Comments/Problems: Webmaster@delphi32.com
Copyright © 1998-2006, Delphi32.com. All rights reserved.
Terms of Use