Qbasicnews.com
April 06, 2020, 10:40:41 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 4655 times)
Jkl
New Member

Posts: 9


« Reply #15 on: March 13, 2003, 11:31:28 AM »

Well then by all means tell me the faster way to do it!
Logged
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #16 on: March 13, 2003, 02:40:40 PM »

Code:

DIM SHARED x2b(8) AS INTEGER, y2b(8) AS INTEGER
x2b(1) = 0: y2b(1) = 1
x2b(2) = 0: y2b(2) = -1
x2b(3) = 1: y2b(3) = 0
x2b(4) = -1: y2b(4) = 0
x2b(5) = -1: y2b(5) = 1
x2b(6) = 1: y2b(6) = 1
x2b(7) = 1: y2b(7) = -1
x2b(8) = -1: y2b(8) = -1

FUNCTION try.straight% (x0 AS INTEGER, y0 AS INTEGER, x1 AS INTEGER, y1 AS INTEGER)
DIM diff AS INTEGER, cost.min AS INTEGER, x0b AS INTEGER, y0b AS INTEGER
DO
cost.min = 32767
FOR i = 1 TO 8
diff = (x1 - x0 - x2b(i)) ^ 2 + (y1 - y0 - y2b(i)) ^ 2
IF diff < cost.min THEN cost.min = diff: x0b = x0 + x2b(i): y0b = y0 + y2b(i)
NEXT i
x0 = x0b: y0 = y0b
IF x0 = x1 THEN IF y0 = y1 THEN try.straight% = 1: EXIT DO
LOOP
END FUNCTION
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.
relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #17 on: March 14, 2003, 03:28:13 AM »

Here:

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

Rel.Line

Just change the PutPixel to Psets...
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!