[squeakland] How can I fill a polygon with a graphic

Bert Freudenberg bert at freudenbergs.de
Wed Jul 20 12:18:55 EDT 2011


On 20.07.2011, at 07:03, Steve Thomas wrote:

> So I have a fraction cutter that can split a polygon and separate the halves by moving them apart.
> 
> I want to be able to allow a teacher (or student) to select a graphic to place inside the polygon so they can cut cakes, cookies, pictures of themselves etc.
> 
> The polygon has an option from the menu to set "fill style" to "bitmap fill".  But "choosing a new graphic" is not straight forward (an option similar to a player variable where I can click on an costume would be nice). And "grab a new graphic" does not allow for the precision I need and requires some trial and error which makes difficult things I want to be easy.

One idea would be to use a ScreeningMorph. It allows to view one object to be viewed "screened" by another morph.

It looks like it's missing from the object catalog. But you can use a RoundGlass from the "Just for Fun" category instead. This is actually a rectangular Magnifier screened by an Ellipse.

Click twice to get the halo on the Ellipse, lift it out. Then click twice again to lift the Magnifier out. Drop an Image in, then a Polygon.

Even if that does not fit your purpose, Screening is cool ;)

> So is there a way to "choose a new graphic" in smalltalk code?

I was about to suggest you look at the "caleidoscope" project, but google found these instead. Still pretty neat:

http://www.luise-buechner-schule.eisfair.net/moodle/mod/resource/view.php?id=16784

http://community.ofset.org/index.php/Les_limites_du_monde_Kedama

For the Smalltalk code you could use a textual script like this:

adoptGraphic
	Sensor waitNoButton.
	self costume
		fillStyle: (BitmapFillStyle fromForm: self costume world chooseClickTarget imageForm)

- Bert -




More information about the squeakland mailing list