[Newbies] Subclassing PasteUpMorph

Bert Freudenberg bert at freudenbergs.de
Fri May 6 14:33:44 UTC 2016

On 04.05.2016, at 19:48, Michael Rice <limitcase at gmail.com> wrote:
> I'm experimenting with subclassing PasteUpMorph to get some additional behavior. One thing I want to do is have my subclass open with a CircleMorph at 0 at 0. I already get that behavior, the CircleMorph in the upper left corner, but want my subclass' origin to be at its center, and the CircleMorph drawn there. My current initialize method,
> initialize
> 	""
> 	super initialize.
> 	self originAtCenter; addMorph: ((CircleMorph new) color: Color white) centeredNear: 0 at 0.
> still places it in the upper left corner.
> How do I get the origin, 0 at 0, at the center?

You could use

	circle x: 0 y: 0.

The originAtCenter flag only affects the PasteUpMorph’s cartesianOrigin which is used by Etoys (via the x/y methods) and puts the origin at either its lowerLeft corner or its center, just as in Math (and unlike Squeak).

That said, Morphic currently does not use a fully transform-based graphics engine. You cannot easily transform the coordinate system for submorphs. Etoys gets around this by applying the origin offset in its x/y accessors (which also flip the y direction from downwards to upwards).

- Bert -

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4207 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/beginners/attachments/20160506/8b44f84d/smime.bin

More information about the Beginners mailing list