Hi,
just came across Amber and find it truely amazing! I try to write a compound morph in Smalltalk: When it comes to adding a StringMorph to a BoxMorph, the string is inside the box at 0@0, so I use... myStringMorph moveBy: 4@4. ...but it doesn't work. Instead the StringMorph gets lost from the display. What's the clue here? Manythanx in advance... |
Are you using the JS implementation of morphic?
If so, maybe someone else could help here :) Nico On Tue, 2011-10-25 at 10:04 -0700, Tom wrote: > Hi, > just came across Amber and find it truely amazing! > > I try to write a compound morph in Smalltalk: When it comes to adding > a StringMorph to a BoxMorph, the string is inside the box at 0@0, so I > use... > > myStringMorph moveBy: 4@4. > > ...but it doesn't work. Instead the StringMorph gets lost from the > display. > > What's the clue here? > > Manythanx in advance... |
On 25 Okt., 23:25, Nicolas Petton <[hidden email]> wrote:
> Are you using the JS implementation of morphic? > If so, maybe someone else could help here :) > Yes, I use the fantastic morphic.js :) Also I just noticed, cascading of messages over the same object doesn't work with them JS objects of morphic. i.e. myStringMorph setText: 'Nothing special...'; toggleWeight; toggleItalic; setSerif. doesn't work, which is a little inconvenient. Greetz... |
Hi Tom,
I experimented a bit with morphic.js and Amber, however linking them together is not as straightforward as it may seem at first sight... Here's pretty much everything I tried, maybe you can find something useful to you: https://github.com/bromagosa/amber/blob/7e7e2ce8c6264b179435d4df6bfa5016ed5d941c/st/Morphic.st
I think Jens Mönig, the author of morph.js (who I think is also subscribed to this list), will be able to help you much better than I. Cheers!
2011/10/26 Tom <[hidden email]>
Bernat Romagosa. |
In reply to this post by Ankh'nAton
Hi Tom, and all.
I'm also profoundly impressed by Amber, but I have to confess that I have no idea how it casts its magic. ;-) What I can tell you is that in Morphic.js all positioning coordinates are absolute WRT the World and not relative to whichever parent Morph it is embedded in. But I'm afraid you already knew this... and "moveBy" certainly should work. Can you assert that the argument is indeed a (morphic) Point? --Jens On Oct 25, 7:04 pm, Tom <[hidden email]> wrote: > Hi, > just came across Amber and find it truely amazing! > > I try to write a compound morph in Smalltalk: When it comes to adding > a StringMorph to a BoxMorph, the string is inside the box at 0@0, so I > use... > > myStringMorph moveBy: 4@4. > > ...but it doesn't work. Instead the StringMorph gets lost from the > display. > > What's the clue here? > > Manythanx in advance... |
Aaaah indeed! That's something I stumbled upon too, when you want to express points for a Morph, you must make sure they're morph.js points, like:
myMorphPoint := <Point new(30,20);>.
Cheers,
2011/10/26 Jens Mönig <[hidden email]> Hi Tom, and all. Bernat Romagosa. |
Sorry, I meant:
myMorphPoint := <new Point(30,20);>. 2011/10/26 Bernat Romagosa <[hidden email]> Aaaah indeed! That's something I stumbled upon too, when you want to express points for a Morph, you must make sure they're morph.js points, like: Bernat Romagosa. |
Hmmm, so how can you make sure that when working with Morphic.js all
Points are morphic ones? Would you need some glue code to file into Amber that overrides the #@ method? On Oct 26, 1:36 pm, Bernat Romagosa <[hidden email]> wrote: > Sorry, I meant: > > myMorphPoint := <new Point(30,20);>. > > 2011/10/26 Bernat Romagosa <[hidden email]> > > > > > > > > > > > Aaaah indeed! That's something I stumbled upon too, when you want to > > express points for a Morph, you must make sure they're morph.js points, > > like: > > > myMorphPoint := <Point new(30,20);>. > > > Cheers, > > > 2011/10/26 Jens Mönig <[hidden email]> > > >> Hi Tom, and all. > > >> I'm also profoundly impressed by Amber, but I have to confess that I > >> have no idea how it casts its magic. ;-) > > >> What I can tell you is that in Morphic.js all positioning coordinates > >> are absolute WRT the World and not relative to whichever parent Morph > >> it is embedded in. But I'm afraid you already knew this... and > >> "moveBy" certainly should work. Can you assert that the argument is > >> indeed a (morphic) Point? > > >> --Jens > > >> On Oct 25, 7:04 pm, Tom <[hidden email]> wrote: > >> > Hi, > >> > just came across Amber and find it truely amazing! > > >> > I try to write a compound morph in Smalltalk: When it comes to adding > >> > a StringMorph to a BoxMorph, the string is inside the box at 0@0, so I > >> > use... > > >> > myStringMorph moveBy: 4@4. > > >> > ...but it doesn't work. Instead the StringMorph gets lost from the > >> > display. > > >> > What's the clue here? > > >> > Manythanx in advance... > > > -- > > Bernat Romagosa. > > -- > Bernat Romagosa. |
In reply to this post by Bernat Romagosa
How about a subclass of Point, maybe JsPoint?
Not sure if you can do something like this in Amber, though. Point >> asJsPoint ^<new Point(x,y)>
On Wed, Oct 26, 2011 at 12:36 PM, Bernat Romagosa <[hidden email]> wrote: Sorry, I meant: |
Yep, that'd be a solution :)
2011/10/26 Francisco Garau <[hidden email]> How about a subclass of Point, maybe JsPoint? Bernat Romagosa. |
In reply to this post by Francisco Garau
What's special in Smalltalk is that Points are constructed by sending
the #@ to a (any) Number, which results in an almost literal notation for Points, since #@ is a binary message, right? This wonderful feature of Smalltalk gets lost when you subclass Point with, say, MorphicPoint, unless you either override Number's #@ method or add a similar one for MorphicPoints. Since binary messages aren't restricted to single character symbols I guess you also add another binary method named #@@ to Number which instead of returning a Point object would instead return a MorhicPoint one... On Oct 26, 2:01 pm, Francisco Garau <[hidden email]> wrote: > How about a subclass of Point, maybe JsPoint? > > Not sure if you can do something like this in Amber, though. > > Point >> asJsPoint > ^<new Point(x,y)> > > On Wed, Oct 26, 2011 at 12:36 PM, Bernat Romagosa < > > > > > > > > [hidden email]> wrote: > > Sorry, I meant: > > > myMorphPoint := <new Point(30,20);>. > > > 2011/10/26 Bernat Romagosa <[hidden email]> > > >> Aaaah indeed! That's something I stumbled upon too, when you want to > >> express points for a Morph, you must make sure they're morph.js points, > >> like: > > >> myMorphPoint := <Point new(30,20);>. > > >> Cheers, > > >> 2011/10/26 Jens Mönig <[hidden email]> > > >>> Hi Tom, and all. > > >>> I'm also profoundly impressed by Amber, but I have to confess that I > >>> have no idea how it casts its magic. ;-) > > >>> What I can tell you is that in Morphic.js all positioning coordinates > >>> are absolute WRT the World and not relative to whichever parent Morph > >>> it is embedded in. But I'm afraid you already knew this... and > >>> "moveBy" certainly should work. Can you assert that the argument is > >>> indeed a (morphic) Point? > > >>> --Jens > > >>> On Oct 25, 7:04 pm, Tom <[hidden email]> wrote: > >>> > Hi, > >>> > just came across Amber and find it truely amazing! > > >>> > I try to write a compound morph in Smalltalk: When it comes to adding > >>> > a StringMorph to a BoxMorph, the string is inside the box at 0@0, so I > >>> > use... > > >>> > myStringMorph moveBy: 4@4. > > >>> > ...but it doesn't work. Instead the StringMorph gets lost from the > >>> > display. > > >>> > What's the clue here? > > >>> > Manythanx in advance... > > >> -- > >> Bernat Romagosa. > > > -- > > Bernat Romagosa. |
In reply to this post by Bernat Romagosa
On 26 Okt., 13:36, Bernat Romagosa <[hidden email]>
wrote: > Sorry, I meant: > > myMorphPoint := <new Point(30,20);>. > Yes and thanks, this is working. Here's a new instance method for Amber's Point class. asMorphicPoint | js | js := '< new Point(', x asString, ',', y asString, '); >.'. ^(SourceArea new eval: js) Now selecting #moveBy: goes like... myStringMorph moveBy: (6@6) asMorphcPoint. ...which is a workaround, not to forget ;) Cheers and thank You all! |
In reply to this post by Ankh'nAton
I believe you could implement it as:
<return new Point(this['@x'],this['@y']);> -- Sent from my Palm Pre 2, wohoo! On Oct 26, 2011 18:04, Tom <[hidden email]> wrote: On 26 Okt., 13:36, Bernat Romagosa <[hidden email]> wrote: > Sorry, I meant: > > myMorphPoint := <new Point(30,20);>. > Yes and thanks, this is working. Here's a new instance method for Amber's Point class. asMorphicPoint | js | js := '< new Point(', x asString, ',', y asString, '); >.'. ^(SourceArea new eval: js) Now selecting #moveBy: goes like... myStringMorph moveBy: (6@6) asMorphcPoint. ...which is a workaround, not to forget ;) Cheers and thank You all! |
@Göran Krampe: Yes, your far more elegant solution works. I didn't
know, that ivars can be referenced like @ivar in a JS context. I've just commited my new Kernel-Package containing the Point class ;) Tom |
Free forum by Nabble | Edit this page |