Created
August 17, 2023 02:17
-
-
Save jblang/edc35045eb724d5df15379fa6a877c8f to your computer and use it in GitHub Desktop.
Advanced Graphics Techniques for Mac QuickBASIC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Advanced Graphics Techniques--Part II by Bob Boothe | |
' 80 Microcomputing Magazine, May 1981, Page 119-142 | |
' https://archive.org/details/80-microcomputing-magazine-1981-05/page/n121/mode/2up | |
' Converted to QuickBASIC for Mac by J.B. Langston, August 2023 | |
w=WINDOW(2): h=WINDOW(3) | |
pi=3.14: xc=w/2: yc=h/2: sc=yc | |
CALL Poly18 | |
CALL TheEye | |
CALL Moire | |
CALL TheTunnel | |
CALL SimpleDisc | |
CALL OverlappingSpiral | |
CALL Rose(76!, 3!, 2!) | |
CALL Rose(60!, 2!, 2!) | |
CALL Rose(60!, 4!, 4!) | |
CALL ScaledTriangle | |
SUB Poly18 STATIC | |
SHARED sc | |
CLS | |
CALL RegularPoly(sc, sc, 18!) | |
CALL WaitKey | |
END SUB | |
SUB TheEye STATIC | |
SHARED h, sc, xc, yc | |
CLS | |
x0=xc-sc: y0=yc-sc | |
FOR q = 0 TO h STEP 9 | |
LINE (x0,y0+q)-(x0+q,y0+h) | |
LINE (x0+q,y0)-(x0+h,y0+q) | |
NEXT | |
CALL RegularPoly(sc/2,sc/2,11!) | |
CALL WaitKey | |
END SUB | |
SUB Moire STATIC | |
SHARED sc, xc, yc, pi | |
CLS | |
r1=sc/2: r2=sc*2 | |
x0=xc-r2/2: y0=yc-r2/2 | |
FOR t = 0 TO pi/2 STEP pi/180 | |
x1=COS(t)*r1: y1=SIN(t)*r1 | |
x2=COS(t)*r2: y2=SIN(t)*r2 | |
LINE (x0+x1,y0+y1)-(x0+x2,y0+y2) | |
LINE (x0+r2-x1, y0+r2-y1)-(x0+r2-x2, y0+r2-y2) | |
NEXT | |
CALL WaitKey | |
END SUB | |
SUB TheTunnel STATIC | |
SHARED sc, xc, yc, h | |
CLS | |
x1=xc*1.08: y1=yc*1.15 | |
FOR q = 1 TO h/5.5 | |
x2=x1+5*q+2: y2=y1: LINE (x1,y1)-(x2,y2) | |
x1=x2: y1=y2+5*q+3: LINE (x1,y1)-(x2,y2) | |
x2=x1-5*q-5: y2=y1: LINE (x1,y1)-(x2,y2) | |
x1=x2: y1=y2-5*q-6: LINE (x1,y1)-(x2,y2) | |
NEXT | |
CALL WaitKey | |
END SUB | |
SUB SimpleDisc STATIC | |
SHARED sc, pi | |
CLS | |
FOR t1 = 0 TO 2*pi STEP pi/50 | |
t2=t1+3*pi/4 | |
CALL PlotPolar(t1, sc, t2, sc) | |
NEXT | |
CALL WaitKey | |
END SUB | |
SUB OverlappingSpiral STATIC | |
SHARED pi | |
CLS | |
FOR t1=0 TO 10*pi STEP pi/20 | |
t2=t1+2*pi/3 | |
r1=4*t1: r2=4*t2 | |
CALL PlotPolar(t1, r1, t2, r2) | |
NEXT | |
CALL WaitKey | |
END SUB | |
SUB Rose(sd, td, tm) STATIC | |
SHARED pi,sc | |
CLS | |
FOR t1 = 0 TO 2*pi STEP pi/sd | |
t2=t1+pi/td | |
r1=COS(tm*t1)*sc: r2=COS(tm*t2)*sc | |
CALL PlotPolar(t1, r1, t2, r2) | |
NEXT | |
CALL WaitKey | |
END SUB | |
SUB ScaledTriangle STATIC | |
SHARED pi | |
CLS | |
r = 1 | |
FOR t = 0 TO 3.24 STEP pi/30 | |
r=r*1.18 | |
t1=t: t2=t+2*pi/3 | |
CALL PlotPolar(t1, r, t2, r) | |
t1=t1+4*pi/3 | |
CALL PlotPolar(t1, r, t2, r) | |
t2=t | |
CALL PlotPolar(t1, r, t2, r) | |
NEXT | |
CALL WaitKey | |
END SUB | |
SUB RegularPoly(r1, r2, v) STATIC | |
SHARED pi | |
FOR t1 = 0 TO 2*pi - .001 STEP 2*pi / v | |
FOR t2 = t1 + 2*pi / v TO 2*pi - .001 STEP 2*pi / v | |
CALL PlotPolar(t1, r1, t2, r2) | |
NEXT | |
NEXT | |
END SUB | |
SUB PlotPolar(t1, r1, t2, r2) STATIC | |
SHARED xc, yc | |
x1=INT(COS(t1)*r1 + xc): y1=INT(SIN(t1)*r1 + yc) | |
x2=INT(COS(t2)*r2 + xc): y2=INT(SIN(t2)*r2 + yc) | |
LINE (x1,y1)-(x2,y2) | |
END SUB | |
SUB WaitKey STATIC | |
WHILE INKEY$="" : WEND | |
END SUB |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment