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.


  • 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

    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.

Howdy, Stranger!

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