Computer Graphics

Moderators: Sephiroth
Number of threads: 1241
Number of posts: 2641

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Edit Report
linedrawing Posted by daniel on 31 Jan 2000 at 6:23 PM
hello!<br>
I'm writting my own vga library for FirstBasic(powerbasic), and I've done<br>
everything except I can't seem to get a line statement. I would like to get an<br>
example of how to draw a line using direct memory access in 320x200x256<br>
(screen 13 in basic) either in basic code or pascal.


Edit Report
Re: linedrawing Posted by EyesBare on 1 Feb 2000 at 6:06 AM
Lets suppose that the parameters are:<br>
x1, y1, x2, y2, color.<br>
<br>
dx= x1 - x2<br>
dy= y1 - y2<br>
<br>
if dx > dy then the x_step is 1 and y_step is dy/dx<br>
else x_step = dx/dy and y_step = 1<br>
<br>
then you have to make a loop in wich you add x_step to x1 and y_step to y1 and draw the pixel at x, y.<br>
<br>
If dx or dy is possitive, you have to put a '-' in front of the steps. Yust play with this a bit, it isn't difficult. <br>
<br>
<br>



Edit Report
Re: Re: linedrawing Posted by The Watcher^TUHB on 2 Feb 2000 at 2:25 AM
Or just look on the net for Bresenham linedrawing routines (basically the same thing), there should be plenty of code available. For some quick pascal examples it is always smart to look at<br>
<br>
http://www.prog.cz/prog/swag/swag/<br>
<br>
Hope that helped<br>
<br>
The Watcher^TUHB<br>
<br>
p.s. writing a fast _clipped_ line routine is not at all a trivial task.





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.