+'...IFS-compressed image reconstructor
+ dummy=MsgBox("Select project type and color.","Continue")
+ msg$ = "Iterated Function System by David Benn "+chr$(169)
+ msg$ = msg$+" 1994 for Karen."
+ dummy=MsgBox(msg$,"Continue")
+ menu 1,0,1 '..enable project menu
+ menu 2,0,1 '..enable color menu
+ menu 3,2,0 '..disable "stop" item
+'...read probability levels, x & y factors and IFS data...
+dim n%(pats),xscale%(pats),yscale%(pats),xoffset%(pats),yoffset%(pats)
+ read n%(r),xscale%(r),yscale%(r),xoffset%(r),yoffset%(r)
+DATA 3,150,115,160,60 '..Sierpinski triangle
+DATA 4,150,75,225,70 '..Square
+DATA 4,25,12,285,60 '..Fern
+DATA 4,250,225,300,60 '..Tree #1
+DATA 4,150,75,160,40 '..Tree #2
+DATA 4,54,26,230,50 '..Sunflower
+pt=0 '...reset probability counter
+dim a(pats,4),b(pats,4),c(pats,4),d(pats,4),e(pats,4),f(pats,4),p(pats,4)
+ read a(1,I),b(1,I),c(1,I),d(1,I),e(1,I),f(1,I),pk
+pt=0 '...reset probability counter
+'...Sierpinski Triangle...
+DATA .5,0,0,.5,.5,.5,.34
+DATA .5,0,0,.5,.5,.5,.25
+DATA .2,-.26,.23,.22,0,1.6,.07
+DATA -.15,.28,.26,.24,0,.44,.07
+DATA .85,.04,-.04,.85,0,1.6,.85
+DATA .42,-.42,.42,.42,0,.2,.4
+DATA .42,.42,-.42,.42,0,.2,.4
+DATA 0.195,-0.488,0.344,0.443,0.722,0.536,0.25
+DATA 0.462,0.414,-0.252,0.361,0.538,1.167,0.25
+DATA -0.058,-0.070,0.453,-0.111,1.125,0.185,0.25
+DATA -0.045,0.091,-0.469,-0.022,0.863,0.871,0.25
+DATA -.3,-.6,1.1,.11,4,0,.02
+DATA -.3,-1,1,.01,4,0,.95
+DATA .02,.01,0,-.2,0,0,.01
+DATA 0,.02,0,0,.01,.02,.02
+window 1,"IFS",(0,0)-(640,225),0,1
+const black=0,white=1,green=2,red=3,blue=4,yellow=5
+menu 1,1,1,"Sierpinski Triangle"
+menu 1,7,0,"-------------------"
+menu 1,8,1,"Help...","H"
+menu 1,9,1,"About...","A"
+menu 3,1,0,"Clear Window","C"
+ if item=8 or item=9 then
+ until op% >= 1 and op% <= pats and fgnd% > 0
+ '..disable menus 1 and 2
+ '..enable special menu's CLS and STOP items
+ ON MENU gosub handle_menu
+ IF R <= p(op%,3) THEN k%=3 ELSE k%=n%(op%)
+ newx = a(op%,k%) * x + b(op%,k%) * y + e(op%,k%)
+ newy = c(op%,k%) * x + d(op%,k%) * y + f(op%,k%)
+ outX% = x * xscale%(op%) + xoffset%(op%)
+ outY% = 200 - (y * yscale%(op%) + yoffset%(op%))
+ until i& > 25000& or finished
+ if item=2 then finished = -1