Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

linedrawing

hello!

I'm writting my own vga library for FirstBasic(powerbasic), and I've done

everything except I can't seem to get a line statement. I would like to get an

example of how to draw a line using direct memory access in 320x200x256

(screen 13 in basic) either in basic code or pascal.


Comments

  • Lets suppose that the parameters are:

    x1, y1, x2, y2, color.



    dx= x1 - x2

    dy= y1 - y2



    if dx > dy then the x_step is 1 and y_step is dy/dx

    else x_step = dx/dy and y_step = 1



    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.



    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.








  • 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



    http://www.prog.cz/prog/swag/swag/



    Hope that helped



    The Watcher^TUHB



    p.s. writing a fast _clipped_ line routine is not at all a trivial task.


Sign In or Register to comment.