Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
LINE
#1
does any one know how to draw a line into an array?

Instead of drawing it onto the screen i.e. LINE (0, 0) - (5, 5), 4

I want to define a line in an array.
I assume it's some kind of algorithm.
if anyone can help, I'd appreciate it

Jony_Basic
Reply
#2
I don't think that's possible. The easiest way to store a line into an array would probably be to store the x,y coordinates and the color in an array and call it from there, but I'm not sure.

Just trying to help with ideas.
url=http://www.freewebs.com/boxtopstuff/]Planet Boxtop[/url] (Look out for the redesign!)
The only member of QBNF with severe "tomorrow syndrome."
Reply
#3
im sure searching this forum will turn up a few line algorithms, the only one i can remember is bresenham/bresnham

i posted it here
http://forum.qbasicnews.com/viewtopic.ph...t=bresnham
EVEN MEN OF STEEL RUST.
[Image: chav.gif]
Reply
#4
If you're in a hurry, you could just use LINE itself. As of FB .15, there is an extra parameter before line, like so:

Code:
LINE buffer, (...)-(...)

Not sure if it was in any other releases, but that's what the manual has to say on the subject.
.14159265358979323846264338327950288419716939937510582709445
Glarplesnarkleflibbertygibbertygarbethparkentalelelangathaffendoinkadonkeydingdonkaspamahedron.
Reply
#5
Here is one way, if I understood you correctly:

Code:
'Store lines of type LINE(x1,y1)-(x2,y2),color  in the array L:

'for storing up to 5 ines
n=5
DIM) L(n, n, n, n, n)

'for two lines:

'line 1:
L(1, 0, 0, 0, 0) = 0 'x11
L(0, 1, 0, 0, 0) = 0 'y11
L(0, 0, 1, 0, 0) = 8 'x21
L(0, 0, 0, 1, 0) = 8 'y21
L(0, 0, 0, 0, 1) = 7 'color1

'line 2:
L(2, 0, 0, 0, 0) = 8 'x12
L(0, 2, 0, 0, 0) = 0 'y12
L(0, 0, 2, 0, 0) = 0 'x22
L(0, 0, 0, 2, 0) = 8 'y22
L(0, 0, 0, 0, 2) = 7 'color2

'draw the first two lines stored in the array L:
SCREEN 13
FOR I = 1 TO 2
  LINE(L(I,  0, 0, 0, 0),L(0,  I, 0, 0, 0))-(L(0,  0, I, 0, 0), _
  L(0, 0, 0, I, 0)), L(0,  0, 0, 0, I)
NEXT I

'done!
Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Reply
#6
the bresenham line algorithm works well enough, except the line is some what broken, what I am doing is getting the mouse coordinates and then drawing a line between
oldMousex, oldMousey and mousex, mousey
the line comes out all broken looking, is there a way to remedy this?
Reply
#7
never mind :oops:
I found the bug
it was a mouse handling problem, thanks for your help Smile
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)