[squeak-dev] morph selector x: x and y: y

Bert Freudenberg bert at freudenbergs.de
Wed Mar 6 12:54:56 UTC 2013


On 2013-03-06, at 09:00, Nicolai Hess <nicolaihess at gmail.com> wrote:

> 2013/3/5 Bert Freudenberg <bert at freudenbergs.de>
>> On 2013-03-05, at 08:46, Nicolai Hess <nicolaihess at gmail.com> wrote:
>> 
>> > Hi,
>> >
>> > someone knows why Morphs selector x x: and y y: are implemented differently?
>> 
>> Yes.
>> 
>> > Morph y and y: testing wether self world is nil whereas x and x: doesn't.
>> 
>> That's because the y coordinate does not need to be flipped.
>> 
>> As Marcel wrote, these should be moved to the Etoys package.
>> 
>> > Btw. what is the preferred way to position morphs relative
>> > to the bounds of its owner. It seems morph positions are always
>> > absolute coordinates.
>> 
>> The preferred way would be to use a layout.
>> 
>> A common way for absolute positioning is to add the children while the parent is still at 0 at 0.
>> 
>> Or, just embrace global coords:
>> 
>>         child center: parent center.
>> 
>> (similar for other setters like #topLeft etc)
>> 
>> - Bert -
> 
> Ah ok,
> that means etoys uses x/y coordinates with origin at lower left screen corner
> and morphs top/left are coordinates with origin at upper left screen corner.
> Thank you.
> 
> Nicolai

Yes, Etoys uses a cartesian coordinate system like kids learn it in school, with the origin in the lower left by default (but can be set to the center, too). Also, x and y refer to an object's center, by default. Who except programmers finds the upper-left corner of an object more natural than its center?

And I did mean to write "x does not need to be flipped" above of course. Reminds me of something I just saw on twitter:

"There are two hard problems in computer science: naming things, cache coherence, and off-by-one errors." -- anon

- Bert -




More information about the Squeak-dev mailing list