[comp.sys.apple] snowflake - program

Phil_Bowers.henr801E@XEROX.COM (08/16/89)

To all interested in the Kock 'snowflake curve' program;
    The original program was written for a Hitachi Peach. I have changed  a
few lines so that it will run on an Apple II+, and have
added/deleted/edited some REMs from the original. 
    As pointed out in the article this came from, this program only draws
1/3 of the snowflake curve because to show the whole curve would results in
considerable loss of detail . This is especially true for an Apple II with
280 by 192 graphics as compared to the Peach that has 639 by 199. 

000 REM  orignal written by Simon Wardrop
001 REM for MICRO (March 1984, vol 70)
010 HOME: HGR2: HCOLOR=3:REM HGR will not work for long.
020 DIM X(1000),Y(1000)
030 REM INIT VARIABLES
040 ML=10:S=0.5:P=3.1416:SW=279:SH=191:CZ=1/3:REM SH->Screen Heigth,
SW->Screen Width, ML->Min Length(amount of detail. Higher the value, less
the detail ), S->height factor(1.0 works nice)
050 X(1)=279:Y(1)=10
060 X(2)=0: Y(2)=10: REM X(2)->will move image to right on screen
070 P=2
080 REM MAIN LOOP
090 L=SQR((X(P)-X(P-1)) **2+(Y(P)-Y(P-1))**2)
100 IF L<ML THEN HPLOT X(P),SH-S*Y(P) TO X(P-1),SH-S*Y(P-1) :P=P-1
110 IF L>ML THEN GOSUB 500
120 IF P>1 THEN 90
130 END
140 REM END MAIN LOOP
500 REM SPLIT INTERVAL
510 XL=X(P):YL=Y(P):XR=X(P-1):YR=Y(P-1)
520 C=XR-XL:D=YR-YL:L=SQR(C*C+D*D) * CZ
530  GD=ATN(D/C)
540 IF  XR<XL THEN L=-L
550 X(P+3)=XL:Y(P+3)=YL
560 X(P+2)=C/3+XL:Y(P+2)=D/3+YL
570 X(P+1)=C/2-L*SIN(GD)+XL:Y(P+1)=D/2+L*COS(GD)+YL
580 X(P)=2*C/3+XL:Y(P)=2*D/3+YL
590 X(P-1)=XR:Y(P-1)=YR
600 P=P+3
610 RETURN