A newbie needs some help in squeak (maths, algorithm and drawing)

Gary Chambers gazzaguru2 at btinternet.com
Thu Apr 26 16:46:11 UTC 2007


Perhaps something more like this...


	| theta r pen p|
	pen _ Pen new.
	len _ 200.
	ppr _ 10.
	0 to: (len-1) do: [:i |
		theta _ 2 * Float pi * i / len * ppr.
		r _  i.
		p _ r * theta cos @ (r * theta sin).
		pen goto: p + Display boundingBox center]


I'm not sure what len and ppr mean to you though!

-----Original Message-----
From: squeak-dev-bounces at lists.squeakfoundation.org
[mailto:squeak-dev-bounces at lists.squeakfoundation.org] On Behalf Of
Christophe Bouchard
Sent: 26 April 2007 3:27 pm
To: squeak-dev at lists.squeakfoundation.org
Subject: A newbie needs some help in squeak (maths, algorithm and drawing)


Hello,
I have to realize an application in squeak which is an icon generator. My
questions are the following: I have an algorithm which describe a spiral and
i'd like to transcript it into squeak, but it doesn't work. The original
algorithm is: " for( i=0; i < len; i++ ) {
  theta = 2*pi*float(i) / ppr;
  r = 0.15 * sqrt(theta);
  x = r * cos(theta);
  y = r * sin(theta);
  }
"

And what i've done but that doesn't work:
"
spiral: len with: ppr

	| theta r x y |
	
	0 to: (len-1) do:
		[:i | theta = 2* Float pi * i / ppr.
			r = 0.15 * (self sqrt: theta).
			x = r * ( self cos: theta).
			y = r * ( self sin: theta).		
		]
"

But this code doesn't work and I don't know how to code my spiral algorithm
and how it will be displayed on screen when running. Thank you for your
help. Chris




More information about the Squeak-dev mailing list