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

Bob Arning arning315 at comcast.net
Fri Apr 7 00:42:41 UTC 2017


Well, here's a different approach that uses a Form for the moving hand.


     | f pt elapsed start morph deg f2 |

     pt _ 200 at 200.
     f _ Form extent: 100 at 100 depth: 32.
     f fillColor: (Color white alpha: 0.1).
     f getCanvas line: 50 at 0 to: 50 at 50 width: 2 color: Color orange.
     morph _ ImageMorph new image: f.
     morph openInWorld.
     start _ Time millisecondClockValue.
     [elapsed _ Time millisecondClockValue - start. elapsed < 60000] 
whileTrue: [
         deg _ 360.0 * (elapsed \\ 60000) / 60000.
         f2 _ f rotateBy: deg smoothing: 2.
         morph image: f2; position: pt - (f2 extent // 2).
         World displayWorldSafely.
     ]


On 4/6/17 7:23 PM, tim Rowledge wrote:
> Thanks Bob,
>
>> On 06-04-2017, at 3:52 PM, Bob Arning <arning315 at comcast.net> wrote:
>>
>> | 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
>
> That’s… interesting. So by putting the morph I care about into a ‘fake morph’ that doesn’t even enclose it and rotating that in a TransformationMorph it does pretty much what I need. Really clever and completely not what I’d ever expect.
>
> Has to be a more easily usable approach that we can come up with to do this, surely. What is the purpose of the entire rotationCenter thing if not to make it be the center of any following rotations?
>
> tim
> --
> tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
> May the bugs of many programs nest on your hard drive.
>
>
>

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


More information about the Squeak-dev mailing list