[Squeakland] Some more eToy questions

Ned Konz ned at squeakland.org
Wed Jan 21 08:34:54 PST 2004


My apologies in advance if this is too technical; I don't know what Darius' 
comfort level with these things is.

On Tuesday 20 January 2004 11:38 pm, Inglang wrote:

>   How can one make a mirror image of a polygon (or other graphical morph:
> ellipse, star, etc.)?

Right now, only SketchMorph knows how to be flipped  (in its 'graphics' 
vocabulary). So you can make a sketch (grab the image from the screen, erase 
its border) and then you can flip it.

>   Can one use tiles to position polygon-handles, curve-handles  (yellow
> circles when handles turned on)?

Not directly. If you rotate or otherwise change the geometry of a PolygonMorph 
that has its handles displayed, the handles will be moved appropriately.

The handles currently aren't smart enough to have their own scripts (if you 
move one from a script, it doesn't do the appropriate editing). If they were, 
it might be possible to add:

(Polygon) numberOfVertices -- return the number of vertices
(Polygon) numberOfVertices: -- set the number of vertices (adding or removing 
as necessary)
(Polygon) handleForVertex: <aNumber> -- return a PolygonHandle
(Polygon) handlesShown: <aBoolean> -- hide or show the handles

and then you could use the usual setX, setY, etc. commands to the 
PolygonHandle

You can use a hand-edited textual script to change the vertices of a 
PolygonMorph, but then you have the problem of having a maximum of only one 
argument to the script.

I did this to make a PolygonHandle that can be used to edit one vertex of a 
PolygonMorph:

* get an Ellipse
* add an instance variable named 'polygon' of type Player
* add an instance variable named 'vertex' of type Number
* add a new script, called 'adjust'
* edit the script textually to look like this:

adjust
	| poly verts |
	poly _ self getPolygon costume.
	(poly isKindOf: PolygonMorph) ifFalse: [ ^self ].
	verts _ poly vertices.
	verts atWrap: (self getVertex asInteger)
		put: self costume bounds center.
	poly setVertices: verts.

Now if the 'adjust' script is ticking, I can move the Ellipse (either by hand 
or by tile scripts) and it will move the corresponding vertex of the 
PolygonMorph. You could hide the Ellipse if you wanted.

>   Can one automatically create an script that matches the
> dimensions/position/color of the ellipse (star, polygon, etc.) morph as one
> created it with the halo handles?

You can duplicate a Morph. Is this what you mean?

>   Can one create a new instance of an ellipse (star, polygon, etc.) morph
> with a tile script?

It's easiest to duplicate an existing one (perhaps from a flap). The 'copy' 
command in the 'miscellaneous' vocabulary will create a new sibling (that is, 
it will share the same scripts as the original) in the same location and 
holder as the original.

>   Can one separate embedded morphs (un-embed) by halo menus or tiles?

Yes. If you have a tile for an embedded morph (which you will have to get by 
hand), you can then put that into a script and tell the World (or wherever 
you want the un-embedded morph to end up) to 'include at end:' or 'include at 
beginning:' (or in a Holder, you can also say 'include:').

>   Can one control the layer depth of how morphs are layered one over the
> other by numeric tile script?

Yes. Again, get a viewer on the World or Playfield; 'include at end:' will put 
the Morph under all the other morphs; 'include at beginning:' will put it 
above all the other morphs.



More information about the Squeakland mailing list