How to construct a PolygonMorph?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

How to construct a PolygonMorph?

Tim Rowe-2
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
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: How to construct a PolygonMorph?

Stan Shepherd

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@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@0. 100@0. 0@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
Reply | Threaded
Open this post in threaded view
|

Re: How to construct a PolygonMorph?

Herbert König
In reply to this post by Tim Rowe-2
Hi Tim,


TR> But I can't work out what it expects for vertices. Could somebody give
though Stan gave a reply, PolygonMorph expects an Array of instances
of Point as vertices.

TR> me an example of how to create a PolygonMorph? (Or, better, tell me
TR> how to find things like this in the documentation, so I don't have to
TR> keep bothering you folks!)

It'll get quite lonely here if nobody asks questions :-)) Anyway,
Yahoo or the Squeak Swiki dig up a some examples. In a Browser point
to the class and press Alt Shift N or use class refs from the right
click menu. This finds you all messages in the image which send a
message to PolygonMorph.

BTW, you may want to try try addHandles for editing or display purposes.

--
Cheers,

Herbert  

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: How to construct a PolygonMorph?

Edgar J. De Cleene
Hi Tim:

Here you have two old versions of my Rompecabezas

http://wiki.squeak.org/squeak/3938
http://wiki.squeak.org/squeak/5861

The code inside show how create a PolygonMorph, using the nice code of
Jerome you could not only made a Polygon , but use curved segments.
Also shows how to use any pict to fill the closed surface, like a Puzzle
piece.

Edgar





_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: How to construct a PolygonMorph?

Jerome Peace
In reply to this post by Stan Shepherd
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@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 <[hidden email]> wrote:

> From: Stan Shepherd <[hidden email]>
> Subject: Re: [Newbies] How to construct a PolygonMorph?
> To: [hidden email]
> 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
> > [hidden email]
> > 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@0.
> 100@0. 0@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




_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: How to construct a PolygonMorph?

Tim Rowe-2
In reply to this post by Stan Shepherd
2009/12/22 Stan Shepherd <[hidden email]>: wrote:

> And generally, the answers will point you back to the image, rather than
> documentation.

Something I'm finding quite frustrating, actually. It feels as if I
can only do something if I can find somebody else who has done the
same thing!

My next step will be to make it respond to a mouse click. I /suspect/
that's something to do with Morph>>on:send:to: but there's no useful
documentation in the message definitions and I can't work out what's
happening in any of the senders (not helped by the fact that browsing
senders of on:send:to: actually yields senders of all messages whose
first part ends in "on:", whatever comes before or after, so the first
result I get is for AlignmentMorph>>addUpDownArrowsFor, because it
sends a message "position:" to an object).

Surely there comes a point when one needs actual documentation of this
stuff, instead of tring to work everything out by reverse engineering
the source?

--
Tim Rowe
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: How to construct a PolygonMorph?

Bert Freudenberg
On 22.12.2009, at 18:55, Tim Rowe wrote:
>
> 2009/12/22 Stan Shepherd <[hidden email]>: wrote:
>
>> And generally, the answers will point you back to the image, rather than
>> documentation.
>
> Something I'm finding quite frustrating, actually. It feels as if I
> can only do something if I can find somebody else who has done the
> same thing!

Isn't it rather unlikely nobody else ever had to do something similar? And isn't it nice to find that previous code so easily once you know the tools?

> My next step will be to make it respond to a mouse click. I /suspect/
> that's something to do with Morph>>on:send:to: but there's no useful
> documentation in the message definitions and I can't work out what's
> happening in any of the senders (not helped by the fact that browsing
> senders of on:send:to: actually yields senders of all messages whose
> first part ends in "on:", whatever comes before or after, so the first
> result I get is for AlignmentMorph>>addUpDownArrowsFor, because it
> sends a message "position:" to an object).

Hit cmd-g to search for the next occurrence of "on:". This method does employ it, the highlighting is just not smart enough to find the right spot. And it seems to be pretty useful to me:

        upArrow on: #mouseDown send: #upArrowHit to: aMorph

> Surely there comes a point when one needs actual documentation of this
> stuff, instead of tring to work everything out by reverse engineering
> the source?

Not really. We don't feel it is "reverse engineering". We embrace the "open-source-ness" much more than other communities because the relevant source is always at your finger tips. We just browse a big hyper-linked repository of source code (where links are followed by pressing cmd-n or cmd-m). We give methods intention-revealing selectors so there is less needs for comments. When I read the line pasted above I don't think it's worth commenting.

That's not to say there is no need for documentation. But attempts to create comprehensive documentation for Squeak have so far turned out to be unsustainable.

- Bert -

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners