'=========================================================================== ' Subject: LINE & CIRCLE REPLACEMENTS Date: 04-14-96 (21:45) ' Author: Justin Pasher Code: QB, QBasic, PDS ' Origin: FidoNet QUIK_BAS Echo Packet: DEMOS.ABC '=========================================================================== '> 'I need an algorythm (sp) that will allow me to draw a line without '> 'using the LINE command. The code below gives you an idea of what '... ' Here's some code. I converted it from Pascal, so I hope it's all 'correct! Enjoy! SUB Line (X1, Y1, X2, Y2, Col) ' This draws a line from X1,Y1 to X2,Y2 XLength = ABS(X1-X2) DX = SGN(X1-X2) YLength = ABS(Y1-Y2) DY = SGN(Y1-Y2) IF DY = 0 THEN IF DX = -1 THEN FOR X = X1 TO X2 PSET(X,Y1),Col NEXT ELSEIF DX = 1 THEN FOR X = X2 TO X1 PSET(X,Y1),Col NEXT END IF EXIT SUB END IF IF DX = 0 THEN IF DY = -1 THEN FOR Y = Y1 TO Y2 PSET(X1,Y),Col NEXT ELSEIF DY = 1 THEN FOR Y = Y2 TO Y1 PSET(X1,Y),Col NEXT END IF EXIT SUB END IF XSlope = XLength/YLength YSlope = YLength/XLength IF YSlope/XSlope < 1 AND YSlope/XSlope > -1 THEN IF DX = -1 THEN FOR X = X1 TO X2 Y = CINT(YSlope*X) PSET(X,Y),Col NEXT ELSEIF DX > 0 THEN FOR X = X2 TO X1 Y = CINT(YSlope*X) PSET(X,Y),Col NEXT ELSE IF DY < 0 THEN FOR Y = Y1 TO Y2 X = CINT(XSlope*Y) PSET(X,Y),Col NEXT ELSEIF DY > 0 THEN FOR Y = Y2 TO Y1 X = CINT(XSlope*Y) PSET(X,Y),Col NEXT END IF END SUB '> If that algorithm for drawing lines is in ASM could you convert '> it to QB and send it to me? Anything for a circle? ' Well what do ya know! I do have a circle algorithm! Here 'tis! '(converted from Pascal again, so you might need a few END IFs.. :) 'NOTE: This algorithm seems to draw the circle where it looks more like 'an ellipse, but it's sorta close to a circle. You can try messing around 'with a few aspects to tweak it out. Laterz... SUB Circles(X, Y, Rad, Col) ' This draws a circle with center X,Y, with Rad as it's radius Deg = 0 DO X = CINT(Rad*COS(Deg)) Y = CINT(Rad*SIN(Deg)) PSET(X+160,Y+100,Col) Deg = Deg + 0.005 LOOP UNTIL Deg > 6.4 END SUB