# digarok/rc2014sc

Day 2 - Flowers (polar graphs in Applesoft BASIC)

Dagen Brock authored and Dagen Brock committed Jul 2, 2014
1 parent 7924fd3 commit 2d24d15fbda374bca6fee99978c0c369a53e0677
Showing with 159 additions and 0 deletions.
1. day2/DAY2.po
2. +50 −0 day2/src/day2bas1.txt
3. +40 −0 day2/src/day2bas2.txt
4. +69 −0 day2/src/flowers.txt
BIN +800 KB day2/DAY2.po
Binary file not shown.
 @@ -0,0 +1,50 @@ REM Reference: "Three Ways of Looking At A Function"" REM by James Fuller REM January 1983 (c) Creative Computing REM ****************** REM Define a function to plot in terms of Q 100 DEF FN R(Q) = COS(Q) + COS(2*Q) + COS (5*Q) REM ****************** REM Function Increment 200 I = 1 REM X Scale Factor 300 SX = .5 REM Y Scale Factor 350 SY = .5 REM X Origin Displacement (-130, 130) 400 OX = 0 REM Y Origin Displacement (-90, 90) 450 OY = 0 REM ****************** 500 HGR : POKE -16302,0 550 HCOLOR = 3 600 F = 139 + OX 610 E = 96 + OY 620 HPLOT F,0 TO F,191 630 HPLOT 0,E TO 278, E 640 FOR XR = F TO 278 STEP 19 * SX 650 HPLOT XR, E - 1 TO XR, E + 1 : NEXT XR 660 FOR XL = F TO 0 STEP -19 * SX 670 HPLOT XL, E - 1 TO XL, E + 1 : NEXT XL 680 FOR YD = E TO 191 STEP 15 * SY 690 HPLOT F - 1, YD TO F + 1, YD : NEXT YD 700 FOR YU = E TO 0 STEP -15 * SY 710 HPLOT F - 1, YU TO F + 1, YU : NEXT YU REM POLAR PLOT 800 FOR G = 0 TO 360 STEP I 810 T = G / 57.29576 820 X = FN R(T) * COS(T) 830 Y = FN R(T) * SIN(T) 840 XX = X * (19 * SX) + F 850 YY = -Y * (15 * SY) + E 860 IF XX < 0 OR XX > 279 THEN 900 870 IF YY < 0 OR YY > 191 THEN 900 880 HPLOT XX, YY 900 NEXT G
 @@ -0,0 +1,40 @@ REM Reference: "Three Ways of Looking At A Function"" REM by James Fuller REM January 1983 (c) Creative Computing REM ****************** REM Define a function to plot in terms of Q 100 DEF FN R(Q) = COS(7 * SIN(2*Q)) REM ****************** REM Function Increment 200 I = 1 REM X Scale Factor 300 SX = 2 REM Y Scale Factor 350 SY = 2 REM X Origin Displacement (-130, 130) 400 OX = 0 REM Y Origin Displacement (-90, 90) 450 OY = 0 REM ****************** 500 HGR : POKE -16302,0 550 HCOLOR = 3 600 F = 139 + OX 610 E = 96 + OY REM POLAR PLOT 800 FOR G = 0 TO 360 STEP I 810 T = G / 57.29576 820 X = FN R(T) * COS(T) 830 Y = FN R(T) * SIN(T) 840 XX = X * (19 * SX) + F 850 YY = -Y * (15 * SY) + E 860 IF XX < 0 OR XX > 279 THEN 900 870 IF YY < 0 OR YY > 191 THEN 900 880 HPLOT XX, YY 900 NEXT G
 @@ -0,0 +1,69 @@ REM Reference: "Three Ways of Looking At A Function"" REM by James Fuller REM January 1983 (c) Creative Computing REM ****************** REM Define a function to plot in terms of Q 100 DEF FN R(Q) = COS(7 * SIN(2*Q)) REM ****************** REM Function Increment 200 I = 1 REM X Scale Factor 300 SX = 2 REM Y Scale Factor 350 SY = 2 REM X Origin Displacement (-130, 130) 400 OX = 0 REM Y Origin Displacement (-90, 90) 450 OY = 0 REM ****************** 500 HGR : POKE -16302,0 510 GOSUB 5000 : REM DRAW FIELD 550 FOR N = 1 TO 5 560 GOSUB 5100 : REM Make Flower Parms 562 GOSUB 2000 : REM Grow Stem 563 GOSUB 5200 : REM Random "friendly" Hcolor 565 GOSUB 800 : REM Draw Flower 570 NEXT N 580 END REM POLAR PLOT 800 FOR G = 0 TO 360 STEP I 810 T = G / 57.29576 820 X = FN R(T) * COS(T) 830 Y = FN R(T) * SIN(T) 840 XX = X * (19 * SX) + F 850 YY = -Y * (15 * SY) + E 860 IF XX < 0 OR XX > 279 THEN 900 870 IF YY < 0 OR YY > 191 THEN 900 880 HPLOT F,E TO XX, YY 900 NEXT G 910 RETURN REM Grow Stem 2000 HCOLOR = 1 : FOR Y = 191 TO E STEP -1 : HPLOT F-1,191 TO F+1,Y : NEXT Y 2100 RETURN REM Make Field 5000 HCOLOR=1 5010 FOR X = 0 TO 279 5020 Y = 189 - INT(RND(1)*6) 5030 HPLOT X,Y TO X,191 5040 NEXT X 5050 RETURN REM Make Flower Parms 5100 F = 10 + INT(RND(1)*260) 5110 E = 40 + INT(RND(1)*80) 5120 SX = RND(1) * 5 5130 IF SX < .5 OR SX > 3 THEN SX = 1.2 5140 SY = SX 5150 RETURN REM Random "friendly" Hcolor 5200 FC = INT(rnd(1)*6) 5210 IF FC = 0 OR FC = 4 THEN FC=5 5230 HCOLOR = FC