Qbasicnews.com
April 09, 2020, 06:39:05 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: Line Drawing... Bresenham?  (Read 4664 times)
Jkl
New Member

Posts: 9


« on: March 04, 2003, 02:12:54 AM »

I originally had this post in the Programming Help section but thought it would probably be better here. Im trying to draw a line from x1,y1 to x2,y2 in text. I was told to use Bresenham's Algorithm but all of the examples i found were in c code.
Logged
relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #1 on: March 04, 2003, 03:12:41 AM »

here:

http://relsoft.wrq.cjb.net/files/relgfx.zip

Rel.Line
Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
Jkl
New Member

Posts: 9


« Reply #2 on: March 04, 2003, 12:03:16 PM »

Okay, that looks like it would have what im looking for but im not sure about what to do with it. I messed around with it but i couldnt get anything to show up on the .bas version.
Logged
relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #3 on: March 05, 2003, 03:57:15 AM »

Have you ever tried to read the DOC?
Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
toonski84
__/--\__
*****
Posts: 2567



« Reply #4 on: March 05, 2003, 08:56:02 AM »

blast! library comes with one as well.

or you could type in "bresenham line" into google and end up with many, many routines.
Logged

i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Neo
Na_th_an
*****
Posts: 2150



« Reply #5 on: March 05, 2003, 09:09:22 AM »

the old, but working Search Engines Smiley
Logged
Jkl
New Member

Posts: 9


« Reply #6 on: March 05, 2003, 11:59:35 AM »

That demo is for lines in screen 13 and i dont understand much of the code. Im just looking for something simpler (if there is anything) that would print in text. For example:

X
  .
  .
   .
   .
    .
    .
     X

with no gaps in the line
I have checked google a lot ,of course, and it either doesnt have what im looking for or i dont know what to look for.
Logged
Jkl
New Member

Posts: 9


« Reply #7 on: March 05, 2003, 12:21:34 PM »

I HAVE found exactly what im looking for, but it is in C code. Is this of any value to me? I know nothing about programming in c.
Logged
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #8 on: March 05, 2003, 03:42:33 PM »

nathan posted an answer to this.

Replace PSET (x, y) with:

LOCATE y, x: PRINT "X";
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Jkl
New Member

Posts: 9


« Reply #9 on: March 08, 2003, 02:00:45 AM »

I dont understand all that sub stuff. I run the program and nothing happens. and when i go to the rel.line i dont even see pset?
Logged
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #10 on: March 08, 2003, 11:47:42 AM »

Quote

DX=x2-x1
dy=y2-y1

L!=sqr(DX*dx+dy*dy)

NX!=DX/L!
NY!=dy/L!


For I=0 to L!

X1=x1+NX!
Y1=Y1+NY!
Pset(x1!,Y1!),15
Next I
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Jkl
New Member

Posts: 9


« Reply #11 on: March 08, 2003, 12:33:01 PM »

Thanks Agamemnus
Logged
pr0gger
I hold this place together
*****
Posts: 775


« Reply #12 on: March 12, 2003, 09:21:09 PM »

Shocked  that's it? It's that simple? you do realize, of course, that I once spent days trying to figure that out, and ended up with a hunk of code, 30 lines.... life before i used the forums...
Logged

size=9]"To announce that there must be no criticism of the president, or that we are to stand by the president, right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public." -- Theodore Roosevelt[/size]
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #13 on: March 12, 2003, 10:43:39 PM »

That is the slow, floating point algorithm. The bresenham approach only uses interger math and several optimizations, thus it is more complicated, but heaps faster.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #14 on: March 13, 2003, 03:21:42 AM »

Yeah, its what you call a vector line. I used that for some of my games.

YOu could also try to use DDA. The one with error Code.
Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
Pages: [1] 2
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!