Snowflakes
- Type
- Graphics
- Category
- Random snowflake generator
- Author
- Jerry O'Neill
- Published in
- Antic, December 1983 (Vol. 2, No. 9), "Starting Line"
- Year
- 1983
- Language
- Atari BASIC
- Requirements
- Any Atari 8-bit, Atari BASIC
About the program
According to a REM in its first version, it was 3:20 on Christmas morning when Jerry O'Neill's snowflake program first ran successfully. He tidied it up for Antic's "Starting Line" beginners' column in December 1983, so readers wouldn't have to stay up into the small hours themselves. (The disk version's REM is dated 26 September 1983.) O'Neill was a writer and photographic consultant who had written about computer graphics for about ten years, and who bought an Atari so he could stop "watching over someone else's shoulder". He also wrote the 3-D Fuji tutorial. The program draws lacy, detailed snowflakes in high resolution. Thanks to RND, like nature's own, no two are the same.
What you need
Any Atari with Atari BASIC.
Typing it in
Plain ASCII, apart from inverse video around START in the prompts ({inv}…{/inv}, Atari key) and one {CLEAR} (ESC then SHIFT-CLEAR) in line 1110. The REMs explain each section and can be left out. Line 1150 is DATA for the spike directions. Keep it exactly as printed.
How to use it
RUN, and press START at each prompt. A snowflake is drawn on a full screen in a random colour. When it is finished, the console speaker buzzes. Press START for the next one, which will be the next of 12 types.
How it works
- Arms by trigonometry. O'Neill treated each arm as a radius of a circle. A point at distance
RDSalong armARMis atX=RDS*SIN(angle)+160,Y=RDS*COS(angle)+96, where 160,96 is the centre of the GRAPHICS 24 screen. The six angles are 60° apart, so line 1120 usesDEGand line 1130 works out each sine and cosine once into the tableTRIG(6,2). - Spikes. Arms are 84 units long, a number chosen because it looks good and divides evenly by 3 and by 6. Every 3 or 6 units along each arm, a pair of spikes is drawn.
TILT(6,3)gives the arm directions the spikes follow. They can sweep outward, sweep inward, or alternate. - Twelve types, endless variety.
TYPE(lines 1200–1240) sets the spike spacing, whether the spikes taper toward the tip, and their slant. Within each type the spike lengths come fromRND. O'Neill's first version chose everything at random while drawing, which was very slow. Picking the random lengths once per snowflake intoSPIKE()made it much faster without losing much variety. - The buzzer is the console speaker:
POKE CONSOLE,0fifty times in a loop (line 240), whereCONSOLEis 53279.
Listing
1 REM ANTIC MAGAZINE
2 REM JERRY O'NEILL -- 26 SEPT 1983
4 REM RANDOM COLOR BACKGROUNDS
9 REM JUMP TO SETUP ROUTINE
10 GOTO 1000
99 REM PLACE DRAWING ROUTINE NEAR START OF PROGRAM FOR SPEED
100 GRAPHICS 24:COLOR 1:IF TYPE=1 THEN 120
110 C=INT(RND(0)*15)+1:B=INT(RND(0)*7):SETCOLOR 2,C,B:SETCOLOR 1,C,B+8
119 REM DRAW MAIN ARMS
120 FOR ARM=1 TO 6:PLOT 160,96:DRAWTO 90*TRIG(ARM,1)+160,90*TRIG(ARM,2)+96:NEXT ARM
129 REM DRAW SPIKES ON ARMS
130 FOR RDS=ST TO 84 STEP ST
140 SPIKELN=SPIKE(RDS/ST)
150 IF SLANTFLAG=3 THEN SLANT=1-SLANT
160 FOR ARM=1 TO 6
170 D1=TILT(ARM,0+SLANT):D2=TILT(ARM,2+SLANT)
180 X=RDS*TRIG(ARM,1)+160:Y=RDS*TRIG(ARM,2)+96
190 X1=SPIKELN*TRIG(D1,1)+X:Y1=SPIKELN*TRIG(D1,2)+Y
200 X2=SPIKELN*TRIG(D2,1)+X:Y2=SPIKELN*TRIG(D2,2)+Y
210 PLOT X1,Y1:DRAWTO X,Y:DRAWTO X2,Y2
220 NEXT ARM
230 NEXT RDS
240 FOR I=1 TO 50:POKE CONSOLE,0:NEXT I:POKE CONSOLE,7
250 IF PEEK(CONSOLE)<>6 THEN 250
260 FOR I=1 TO 50:POKE CONSOLE,0:NEXT I:POKE CONSOLE,7
269 REM CHANGE SNOWFLAKE TYPE
270 GOTO 1200
999 REM SETUP SECTION
1000 GRAPHICS 1:POKE 752,1:SETCOLOR 0,9,6:CONSOLE=53279
1010 POSITION 5,5:? #6;"SNOWFLAKES"
1020 POSITION 9,7:? #6;"by":POSITION 3,9:? #6;"jerry o'neill"
1030 COLOR 42
1040 FOR X=0 TO 19:SOUND 0,121-(X*5),10,6:SOUND 1,120-(X*5),10,6:SOUND 2,60,10,6:PLOT X,0:NEXT X
1050 FOR Y=0 TO 19:SOUND 0,121-(X*5),10,6:SOUND 1,60+Y*3,10,6:SOUND 2,59+Y*3,10,6:PLOT 19,Y:NEXT Y
1060 FOR X=19 TO 0 STEP -1:SOUND 0,121-(X*5),10,6:SOUND 1,120-(X*5),10,6:SOUND 2,60,10,6:PLOT X,19:NEXT X
1070 FOR Y=19 TO 0 STEP -1:SOUND 0,121-(X*5),10,6:SOUND 1,60+Y*3,10,6:SOUND 2,59+Y*3,10,6:PLOT 0,Y:NEXT Y
1080 SOUND 0,0,0,0:SOUND 1,0,0,0:SOUND 2,0,0,0
1090 ? "EACH SNOWFLAKE IS DIFFERENT.":? :? "PRESS {inv} START {/inv}"
1100 IF PEEK(CONSOLE)<>6 THEN 1100
1110 ? "{CLEAR}";:? "AFTER EACH IS DONE,THE BUZZER SOUNDS":? "PRESS {inv} START {/inv} FOR ANOTHER SNOWFLAKE"
1120 DIM TRIG(6,2),TILT(6,3),SPIKE(28):DEG
1130 FOR I=1 TO 6:TRIG(I,1)=SIN(I*60):TRIG(I,2)=COS(I*60):NEXT I
1140 FOR J=0 TO 3:FOR I=1 TO 6:READ T:TILT(I,J)=T:NEXT I:NEXT J
1150 DATA 2,3,4,5,6,1,3,4,5,6,1,2,6,1,2,3,4,5,5,6,1,2,3,4
1160 FOR DEL=1 TO 500:NEXT DEL:? "PRESS {inv} START {/inv} NOW"
1170 FOR I=1 TO 50:POKE CONSOLE,0:NEXT I:POKE CONSOLE,7
1180 IF PEEK(CONSOLE)<>6 THEN 1180
1190 TYPE=0
1199 REM 12 DIFFERENT SNOWFLAKE TYPES--USE A DIFFERENT ONE EACH TIME
1200 TYPE=TYPE+1:IF TYPE=13 THEN TYPE=1
1209 REM ST=STEP LENGTH;TAPER=1 IS TAPERED,=2 IS NOT;SLANTFLAG=1 IS UPSWEPT,=2 IS DOWNSWEPT,=3 ALTERNATES
1210 ST=6:IF TYPE/2=INT(TYPE/2) THEN ST=3
1220 TAPER=1:IF TYPE=3 OR TYPE=4 OR TYPE=7 OR TYPE=8 OR TYPE=11 OR TYPE=12 THEN TAPER=2
1230 SLANTFLAG=1:IF TYPE>4 THEN SLANTFLAG=2:IF TYPE>8 THEN SLANTFLAG=3
1240 SLANT=0:IF SLANTFLAG=2 THEN SLANT=1
1249 REM LOAD RANDOM LENGTHS OF SPIKES INTO ARRAY
1250 ON TAPER GOTO 1260,1270
1260 FOR I=1 TO 84/ST:SPIKE(I)=((84-(ST*I))/3)*RND(0):NEXT I:GOTO 1280
1270 FOR I=1 TO 84/ST:SPIKE(I)=20*RND(0):NEXT I
1280 POKE 77,0
1290 GOTO 100
1300 END
Download
The original program from the Antic disk, to LOAD or ENTER instead of typing it: SNOWFLAK.BAS.
Credits
- Program listing: Snowflakes — program listing (Antic, December 1983 (Vol. 2, No. 9), "Starting Line") — Jerry O'Neill
- Picture: One of the twelve snowflake types. Random spike lengths make each one different. — Jerry O'Neill (program); screenshot by the site
- Antic Software Archive — disk files (December 1983 - Vol. 2 No. 9): SNOWFLAK.BAS — Nina R. Franco, 1983
- Antic magazine scan (OCR text layer): Antic_Vol_2-09_1983-12_Buyers_Guide_text.pdf — Internet Archive
