Am 25.05.2005 um 21:09 schrieb Randy Heiland:
Hi Squeakers,
In Etoys, can I make some drawing that was the result of a script become an object? For example, consider the simple circle-drawing script (fwd by, turn by, pen down). Can I somehow treat that resulting circle as an object and thereby make copies of it, etc? I realize that I could use either the 'Grab Patch' or 'Lasso' in the Supplies to manually "select" the circle, however that approach of course gives me more pixels than I really want.
Hi Randy,
this is not quite possible out-of-the-box, as far as I know. However, nothing is impossible in Squeak ;-)
Here's what you can do:
1. Make a new playfield. 2. Place your drawing player in the playfield. 3. Let it draw. 4. Set the playfield's graphic to the drawn pen trails. 5. Make a new sketch. 6. assign the playfield's graphic to the sketch's graphic. 7. You're done :-)
Now that seems straight-forward, but unfortunately there is no "setGraphicFromTrails" tile that we need for step 4. We'll need a bit of magic. Here is how to make that tile: 4a. Get a viewer on the playfield. 4b. From the "playfield" category, drag out the arrow tile for "playfields graphic", making a script. 4c. Rename the script to "setGraphicFromTrails". 4d. Switch the script to textual mode (click the square checkbox in the upper left of the script) 4e. Replace the text shown there: ===================== setGraphicFromTrails self setGraphic: Form3 ===================== with the following (just copy and paste): ===================== setGraphicFromTrails self setGraphic: ((self costume instVarNamed: #turtleTrailsForm) ifNotNilDo: [:f | f trimBordersOfColor: Color transparent]) ===================== Accept using Cmd-s (Alt-s on PC). 4f. Hide the script with the "o" button. 4f. In the playfield's scripts category you'll find your shiny new "setGraphicFromTrails" tile.
For step 6, you could make a skript for the sketch like this:
Playfield setGraphicFromTrails Sketch's graphic <- Playfield's graphic
I think this might be a valuable feature to add generally - that is, making the pen trail's graphic available as a tile. Maybe for the next etoys version.
- Bert -