[squeak-dev] Rotating Morphs; how to rotate about a point other than the centre of bounds?

Bob Arning arning315 at comcast.net
Thu Apr 6 22:52:33 UTC 2017


how about

| secondHand |
secondHand _ Morph new extent: 3 at 50; color: Color yellow.
holder _ Morph new extent: 1 at 1; position: 100 at 100.
secondHand bottomRight: 0 at 0.
holder openInWorld.
flex _ holder addFlexShell.
holder addMorph: secondHand.
1 to: 30 do: [ :i |
     flex angle: Float pi * (i/30.0) negated.
     World displayWorldSafely.
     (Delay forSeconds: 1) wait
].
flex explore


On 4/6/17 6:07 PM, tim Rowledge wrote:
> As part of the never ending Weather station project I’m making a rotary dial morph that can be used to display things such as barometers, speedometers, vu meters, clocks, compasses etc - pretty much anything where a needle thing rotates about a pivot in order to point to a value on a scale.
>
> Clearly one can be ultra simplistic and use a LineMorph over a CircleMorph but that isn't terribly pretty. Right now I have things set up to simply add submorphs to build whatever background and borders and tick marks are wanted, plus the needle. With an ImageMorph (or should it be a SketchMorph?) providing a picture of the dial/scale/frame it can look quite nice.
>
> However, the needle is a problem. A simple Line or PolygonMorph can be used and then it is possible to set the rotationCenter such that subsequent #rotationDegrees: make it turn about that centre. So far, so good. I’d prefer to allow arbitrary morphs for the needle - again, an image would be good in a lot of cases - but I cannot for the life of me find how to make general morphs rotate about a set point. I can use #rotationCenter: and the value is stuck in the extension as expected. If I use the halo rotate after doing that the new center point is clearly shown in the right place BUT it still rotates about the center of the bounds. I can’t find any illuminating usages of #rotationCenter to show how the new center point is used and certainly nothing that makes it look like it is ever treated as the pivot.
>
> I’ve dug into using asFlexShell and friends with no improvement. I’ve searched through the swiki. I’ve compared a 5.0 image with the 6alpha image. To cause further concern pretty much all the rotate related code I can find seems to be in the EToys package, which may mean it would go away when we make a more typical release image. Isn’t rotating morphs a relatively basic part of using them?
>
> What have I missed, or looked at without actually seeing?
>
> tim
> --
> tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
> Strange OpCodes: LTT: Lose Timing Track
>
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20170406/0da03110/attachment.html>


More information about the Squeak-dev mailing list