Help with Rotating a Box

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Help with Rotating a Box

Prof. Andrew P. Black
I've been playing with a Morphic implementation of "Joe the box" for  
an intro programming course.  It shouldn't be hard, right?

The problem is rotation.  It's easy to rotate a polygon morph, but I  
can't get a TextMorph (for the name) to rotate and stay centered.  My  
next attempt (attached), was to use a transformation morph.  This  
almost works, except that when rotating from a non-manhattan  
orientation, smurfs get left on the display.

The code is attached.






I try doing this in a workspace:

joe := NamedBoxMorph2 new.
joe name: 'Fred'.
joe openInWorld.
joe color: Color lightBlue.
joe turn: -45.
joe turn: 45.

Do the

        joe turn: +/- 45

a few times.  Bits of the rectangle are left on the display.  Is this  
a bug in morphic, or a bug in my code (more likely)?  Is tehre an easy  
fix/

The critical method from the filein is this one, I think:

BoxMorph2 >> initialize
        "initialize this BoxMorph so that it looks like a Box in BoxWorld"
        | rectangle b |
        super initialize.
        smoothing := 3.
        b := Rectangle origin: 85 @ 200 extent: 80 @ 80.
        rectangle := RectangleMorph new.
        rectangle bounds: b.
        rectangle color: Color transparent.
        rectangle borderWidth: 1.
        self addMorphCentered: rectangle.
        self bounds: b.

I tired making the bounds of the boxMorph a pixel or two bigger (in  
the last line): this didn't help.

Any ideas?

        Andrew


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

CS520-MorphicBoxes.st (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Help with Rotating a Box

Nicolas Cellier
http://bugs.squeak.org/view.php?id=6511

2009/9/25 Andrew P. Black <[hidden email]>:

> I've been playing with a Morphic implementation of "Joe the box" for an
> intro programming course.  It shouldn't be hard, right?
>
> The problem is rotation.  It's easy to rotate a polygon morph, but I can't
> get a TextMorph (for the name) to rotate and stay centered.  My next attempt
> (attached), was to use a transformation morph.  This almost works, except
> that when rotating from a non-manhattan orientation, smurfs get left on the
> display.
>
> The code is attached.
>
>
>
>
>
>
> I try doing this in a workspace:
>
> joe := NamedBoxMorph2 new.
> joe name: 'Fred'.
> joe openInWorld.
> joe color: Color lightBlue.
> joe turn: -45.
> joe turn: 45.
>
> Do the
>
>        joe turn: +/- 45
>
> a few times.  Bits of the rectangle are left on the display.  Is this a bug
> in morphic, or a bug in my code (more likely)?  Is tehre an easy fix/
>
> The critical method from the filein is this one, I think:
>
> BoxMorph2 >> initialize
>        "initialize this BoxMorph so that it looks like a Box in BoxWorld"
>        | rectangle b |
>        super initialize.
>        smoothing := 3.
>        b := Rectangle origin: 85 @ 200 extent: 80 @ 80.
>        rectangle := RectangleMorph new.
>        rectangle bounds: b.
>        rectangle color: Color transparent.
>        rectangle borderWidth: 1.
>        self addMorphCentered: rectangle.
>        self bounds: b.
>
> I tired making the bounds of the boxMorph a pixel or two bigger (in the last
> line): this didn't help.
>
> Any ideas?
>
>        Andrew
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project