[Fun] Spiral animation

Markus Gaelli gaelli at emergent.de
Sun Jun 20 12:34:41 UTC 2004


Hi folks,

I thought some of you might like it...
I stole the formula at the bottom from Wolframs New Kind of Science:  
http://www.wolframscience.com/nksonline/page-411?firstview=1

For an online version of the spirals see:  
http://www.squeakland.org/project.jsp?http://www.emergent.de/pub/ 
smalltalk/squeak/projects/galaxies.001.pr

I find it amazing, that sunflowers (anAngle =  137.5 = 360*(1-phi)),  
yin-yang, and lots of other interesting :-/ symbols can be made out of  
this simple formula (which I made a bit more complex for aesthetic  
reasons).

| backgroundColor  leafSize anExtent aCanvas numbersOfLeafs someColors  
aPoint |
	backgroundColor _ Color blue muchDarker.
	leafSize _ 60 @ 60.
	anExtent _ Display extent y @ Display extent y.
	aCanvas _ BalloonCanvas extent: anExtent.
	numbersOfLeafs _ 200.
	someColors _ Color wheel: numbersOfLeafs.
	[Display fillColor: backgroundColor.
	0
		to: 360
		by: 0.1
		do: [:anAngle |
			(1 to: numbersOfLeafs)
				do: [:anInt |
					aPoint _ (anInt sqrt * ((anInt * anAngle degreesToRadians) cos @  
(anInt * anAngle degreesToRadians) sin) * (anExtent - leafSize /  
numbersOfLeafs sqrt) + (anExtent - leafSize) / 2) rounded.
					aCanvas
						fillOval: (aPoint extent: (leafSize * (numbersOfLeafs - anInt) /  
numbersOfLeafs) rounded)
						color: (someColors at: anInt)].
			aCanvas showAt: (Display center - (anExtent / 2)) rounded.
			aCanvas fillColor: backgroundColor].
	[Sensor anyButtonPressed] whileFalse.
	nil]
		ensure: [Display restore]

Enjoy,

Markus




More information about the Squeak-dev mailing list