[Newbies] How to construct a PolygonMorph?

Jerome Peace peace_the_dreamer at yahoo.com
Tue Dec 22 10:40:05 UTC 2009


Hi Stan, Hi Edgar,

Here's an example from a recent project. Should work in Squeak 3.10.2 or anything close. Paste into a workspace then evaluate.

[ "begin"
ourCrossHair :=
fullCircle := 360 .
startAngle := 9 .
nSlices := 40.
nSpiral := 10 .


spiralPoints :=
"{ (Point r: ( phi raisedTo: -9/180) degrees: 0-startAngle) 
. 1 at 0
. 0 asPoint } ."
( 0 - startAngle to: 360 * nSpiral - startAngle  by: fullCircle / nSlices ) collect: [ : each |
	Point r: ( phi raisedTo: each * 2/ fullCircle) degrees: each  ] .

ourScale := 720 .
ourCenter := Display center .

ourSpiral :=
PolygonMorph initializedInstance openInHand setVertices: spiralPoints * ourScale + World activeHand position  . 

"end" ] value .


Copy and paste in a workspace. You may wish to modify ourScale if your screen is small. 

I also like to use the pokegrapple way. Get one of the orange thingies with the blue borders from the Objects tab. They are different variants of PolygonMorph. Shift-click on what you have picked and you have yellow handles to move the vertices and green handles to create new ones. When done shift click again to remove the handles. 

Have fun.

Yours in curiosity and service, --Jerome Peace

--- On Mon, 12/21/09, Stan Shepherd <stan.shepherd414 at gmail.com> wrote:

> From: Stan Shepherd <stan.shepherd414 at gmail.com>
> Subject: Re: [Newbies] How to construct a PolygonMorph?
> To: beginners at lists.squeakfoundation.org
> Date: Monday, December 21, 2009, 8:21 PM
> 
> 
> 
> Tim Rowe-2 wrote:
> > 
> > I can see PolygonMorph
> Class>>vertices:color:borderWidth:borderColor:
> > 
> > But I can't work out what it expects for vertices.
> Could somebody give
> > me an example of how to create a PolygonMorph? (Or,
> better, tell me
> > how to find things like this in the documentation, so
> I don't have to
> > keep bothering you folks!)
> > 
> > Thanks.
> > 
> > -- 
> > Tim Rowe
> > _______________________________________________
> > Beginners mailing list
> > Beginners at lists.squeakfoundation.org
> > http://lists.squeakfoundation.org/mailman/listinfo/beginners
> > 
> > 
> 
> Hi Tim,
> 
> By right clicking on the class PolygonMorph, you get the
> menu option 'browse
> senders'. If you go to PolygonMorphTest, theres an
> example.
> 
>  (PolygonMorph
>         vertices: {0 at 0.
> 100 at 0. 0 at 100}
>         color: Color red
> borderWidth: 0 borderColor: Color transparent)
> openInWorld
> 
> Hope that helps (depending on the images we're using, you
> may see different.
> 
> And generally, the answers will point you back to the
> image, rather than
> documentation.
> 
> Cheers,   ...stan



      


More information about the Beginners mailing list