Note sure what you can do with it!!? I am not sure what I can't do with it!

Here is the IFS fractal script: It supports the "usual 5" IFS fractals: the ubiquitous fern, Sierpinskys triangle and a variation on that, one called the Dragon that I found in a book and one called the Maple leaf that I found in the same book, but looks nothing like a maple leaf.

[technical fractal talk]
The fern is not perfect as the script gives each transformation the same priority. When I get access to my original notes (at home somewhere) I will look up the transformaion prioritys and put them in the $AT[0] array. This is the "settings" for eact affine transform.
[/technical fractal talk]

here is the script:

if you have any problems I can email it to you.


code:

break on

? "KiXForms IFS Fractal Generator"
? "Version 1.1 by cj"
?


; the fern
dim $fern[4]
$fern[0]=200,300,1,1,10000
$fern[1]=85,4,0,-4,85,40
$fern[2]=20,-26,0,23,22,40
$fern[3]=-15,28,0,26,24,11
$fern[4]=0,0,0,0,16,0

; Sierpinsky's triangle
dim $sierp[3]
$sierp[0]=300,300,1,1,20000
$sierp[1]=50,0,0,0,50,0
$sierp[2]=50,0,301,0,50,0
$sierp[3]=50,0,0,0,50,301

; A slightly modified Sierpinsky triangle
dim $sierp2[4]
$sierp2[0]=400,400,1,1,10000
$sierp2[1]=50,0,0,0,50,0
$sierp2[2]=50,0,300,0,50,0
$sierp2[3]=50,0,150,0,50,300
$sierp2[4]=25,0,225,0,25,150

; the dragon
dim $dragon[2]
$dragon[0]=200,300,1,1,10000
$dragon[1]=45,-50,0,40,55,0
$dragon[2]=45,-50,400,40,55,0

; a maple leaf - this one doesn't look right...
dim $maple[4]
$maple[0]=250,200,1,-1,10000
$maple[1]=49,1,25,0,62,-2
$maple[2]=27,52,0,-40,36,56
$maple[3]=18,-73,88,50,26,8
$maple[4]=4,-1,52,50,0,32

; create KiXForm
$form = createobject("kixtart.form")
$form.caption = "IFS Fractal test"
$form.visible=1

$Form.BackColor = 0 ; black background
$form.forecolor = $Form.RGB(0, 200, 0) ; a beautiful green

$cmdFern = $Form.CommandButton(560,55,65,25,"Fern")
$cmdSierp = $Form.CommandButton(560,80,65,25,"Sierpinsky")
$cmdSierp2 = $Form.CommandButton(560,105,65,25,"Sierpinsky2")
$cmdDragon = $Form.CommandButton(560,130,65,25,"Dragon")
$cmdMaple = $Form.CommandButton(560,155,65,25,"Maple")
$cmdExit = $Form.CommandButton(560,205,65,25,"Exit")

:again

while not $form.getevent() loop ; scan for click

; process click
if $cmdFern.click() DrawIFS($fern) endif
if $cmdSierp.click() DrawIFS($sierp) endif
if $cmdSierp2.click() DrawIFS($sierp2) endif
if $cmdDragon.click() DrawIFS($dragon) endif
if $cmdMaple.click() DrawIFS($maple) endif
if not $cmdExit.click() goto again endif

quit quit


function DrawIFS($AT)

$Form.BackColor = 0 ; clear the screen again

$i=0

; get image offset
$xoff=$at[0][0]
$yoff=$at[0][1]
; get image rotation
$xflip=$at[0][2]
$yflip=$at[0][3]


do
$t=rnd(ubound($at)-1)+1

$x=(($x*$at[$t][0])/100)+(($y*$at[$t][1])/100)+$at[$t][2]
$y=(($x*$at[$t][3])/100)+(($y*$at[$t][4])/100)+$at[$t][5]

; $form.circle(300-$x, 300-$y, 1) ; draw dot
$form.circle(-$xflip*$x+$xoff, -$yflip*$y+$yoff, 1) ; draw dot

$i=$i+1
until $i=$at[0][4]
; while $Form.getevent() and not $cmdExit.click() loop

endfunction


cj