The Trunk: Morphic-cbc.1450.mcz

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

The Trunk: Morphic-cbc.1450.mcz

commits-2
Chris Cunningham uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-cbc.1450.mcz

==================== Summary ====================

Name: Morphic-cbc.1450
Author: cbc
Time: 12 June 2018, 9:49:08.273851 pm
UUID: 85dec3fe-462d-7242-bdb4-797746d320a0
Ancestors: Morphic-dtl.1449

Recategorized rotationCenter and referencePosition (and setter versions) to more a more appropriate category.
rotationCenter is the relative position of the referencePosition point within the morph.  They are related - and should live together.
Also, moved base Morph versions of these out of EToys to be with the others.

=============== Diff against Morphic-dtl.1449 ===============

Item was changed:
+ ----- Method: CircleMorph>>referencePosition (in category 'rotate scale and flex') -----
- ----- Method: CircleMorph>>referencePosition (in category 'geometry eToy') -----
  referencePosition
  "Return the current reference position of the receiver"
  ^ self valueOfProperty: #referencePosition ifAbsent: [ self center ]
  !

Item was changed:
+ ----- Method: CircleMorph>>rotationCenter (in category 'rotate scale and flex') -----
- ----- Method: CircleMorph>>rotationCenter (in category 'geometry eToy') -----
  rotationCenter
  "Return the rotation center of the receiver. The rotation center defines the relative offset inside the receiver's bounds for locating the reference position."
  | refPos |
  refPos := self referencePosition.
  ^ (refPos - self bounds origin) / self bounds extent asFloatPoint!

Item was changed:
+ ----- Method: CircleMorph>>rotationCenter: (in category 'rotate scale and flex') -----
- ----- Method: CircleMorph>>rotationCenter: (in category 'geometry eToy') -----
  rotationCenter: aPointOrNil
  "Set the new rotation center of the receiver. The rotation center defines the relative offset inside the receiver's bounds for locating the reference position."
  | newRef box |
  aPointOrNil isNil
  ifTrue: [self removeProperty: #referencePosition.
  self removeProperty: #originalCenter.
  self removeProperty: #originalAngle. ]
  ifFalse: [ box := self bounds.
  newRef := box origin + (aPointOrNil * box extent).
  self setRotationCenterFrom: newRef ].
 
  !

Item was changed:
+ ----- Method: MatrixTransformMorph>>rotationCenter (in category 'rotate scale and flex') -----
- ----- Method: MatrixTransformMorph>>rotationCenter (in category 'geometry eToy') -----
  rotationCenter
  | pt |
  pt := self transform localPointToGlobal: super rotationCenter.
  ^pt - bounds origin / bounds extent asFloatPoint!

Item was changed:
+ ----- Method: MatrixTransformMorph>>rotationCenter: (in category 'rotate scale and flex') -----
- ----- Method: MatrixTransformMorph>>rotationCenter: (in category 'geometry eToy') -----
  rotationCenter: aPoint
  super rotationCenter: (self transform globalPointToLocal: bounds origin + (bounds extent * aPoint))!

Item was added:
+ ----- Method: Morph>>referencePosition (in category 'rotate scale and flex') -----
+ referencePosition
+ "Return the current reference position of the receiver"
+ | box |
+ box := self bounds.
+ ^box origin + (self rotationCenter * box extent).
+ !

Item was added:
+ ----- Method: Morph>>referencePosition: (in category 'rotate scale and flex') -----
+ referencePosition: aPosition
+ "Move the receiver to match its reference position with aPosition"
+ | newPos intPos |
+ newPos := self position + (aPosition - self referencePosition).
+ intPos := newPos asIntegerPoint.
+ newPos = intPos
+ ifTrue:[self position: intPos]
+ ifFalse:[self position: newPos].!

Item was changed:
+ ----- Method: Morph>>rotationCenter (in category 'rotate scale and flex') -----
- ----- Method: Morph>>rotationCenter (in category 'geometry eToy') -----
  rotationCenter
  "Return the rotation center of the receiver. The rotation center defines the relative offset inside the receiver's bounds for locating the reference position."
  ^self valueOfProperty: #rotationCenter ifAbsent:[0.5@0.5]
  !

Item was changed:
+ ----- Method: Morph>>rotationCenter: (in category 'rotate scale and flex') -----
- ----- Method: Morph>>rotationCenter: (in category 'geometry eToy') -----
  rotationCenter: aPointOrNil
  "Set the new rotation center of the receiver. The rotation center defines the relative offset inside the receiver's bounds for locating the reference position."
  aPointOrNil isNil
  ifTrue:[self removeProperty: #rotationCenter]
  ifFalse:[self setProperty: #rotationCenter toValue: aPointOrNil]
  !

Item was changed:
+ ----- Method: PolygonMorph>>referencePosition (in category 'rotate scale and flex') -----
- ----- Method: PolygonMorph>>referencePosition (in category 'geometry eToy') -----
  referencePosition
  "Return the current reference position of the receiver"
  ^ self valueOfProperty: #referencePosition ifAbsent: [super referencePosition]
  !

Item was changed:
+ ----- Method: PolygonMorph>>rotationCenter (in category 'rotate scale and flex') -----
- ----- Method: PolygonMorph>>rotationCenter (in category 'geometry eToy') -----
  rotationCenter
  "Return the rotation center of the receiver. The rotation center defines the relative offset inside the receiver's bounds for locating the reference position."
  | refPos |
  refPos := self valueOfProperty: #referencePosition
  ifAbsent: [^ 0.5@0.5].
  ^ (refPos - self bounds origin) / self bounds extent asFloatPoint!

Item was changed:
+ ----- Method: PolygonMorph>>rotationCenter: (in category 'rotate scale and flex') -----
- ----- Method: PolygonMorph>>rotationCenter: (in category 'geometry eToy') -----
  rotationCenter: aPointOrNil
  "Set the new rotation center of the receiver. The rotation center defines the relative offset inside the receiver's bounds for locating the reference position."
  | box |
  aPointOrNil isNil
  ifTrue: [self removeProperty: #referencePosition]
  ifFalse: [box := self bounds.
  self setProperty: #referencePosition
  toValue: box origin + (aPointOrNil * box extent)]
  !

Item was changed:
+ ----- Method: TransformationMorph>>referencePosition (in category 'rotate scale and flex') -----
- ----- Method: TransformationMorph>>referencePosition (in category 'geometry eToy') -----
  referencePosition
  "Answer the  receiver's reference position, bullet-proofed against infinite recursion in the unlikely but occasionally-seen case that I am my own renderee"
 
  | rendered |
  ^ (rendered := self renderedMorph) == self
  ifTrue:
  [super referencePosition]
  ifFalse:
  [transform localPointToGlobal: rendered referencePosition]!


cbc
Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Morphic-cbc.1450.mcz

cbc
On Tue, Jun 12, 2018 at 9:49 PM, <[hidden email]> wrote:
Chris Cunningham uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-cbc.1450.mcz

==================== Summary ====================

Name: Morphic-cbc.1450
Author: cbc
Time: 12 June 2018, 9:49:08.273851 pm
UUID: 85dec3fe-462d-7242-bdb4-797746d320a0
Ancestors: Morphic-dtl.1449

Recategorized rotationCenter and referencePosition (and setter versions) to more a more appropriate category.
rotationCenter is the relative position of the referencePosition point within the morph.  They are related - and should live together.
Also, moved base Morph versions of these out of EToys to be with the others
<snip>
Apparently there are other methods directly related to these (such as #referencePositionInWorld) that need to be moved out of EToys as well - and re-categorized.  Eventually I'll track those down - winding down for the night.

In a related effort, I tried to track down a way to validate what these methods DO (not yet being an EToys user).
If you open a new morph in Squeak
  Morph new openInWorld
and then bring up the halo, grab the bottom left blue swirly handle, you can see the morph rotates around it's center.
At this point, it should also show the #rotationCenter in the middle (little yellow circle with an arrow)

You can shift-drag it around to change the rotationCenter (and referencePosition), which you can verify changes by debugging>exploring the morph.
However, after changing the rotationCenter, the morph still rotates around the center of the morph, and not around the #rotationCenter.  That is kind of annoying.  (Although I haven't ever tried this before today - still, it would be nice if all the pieces worked together.)

-cbc


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Morphic-cbc.1450.mcz

Javier Diaz-Reinoso
That is because the TransformationMorph>>adjustAfter: ('ar 1/3/2010' ) have a guard:

self actorStateOrNil ifNotNil:[
self penUpWhile: [self position: self position + (oldRefPos - self referencePosition)].
].
actorStateOrNil is created if you open a Player with Etoys, then the rotation works OK, if you revert the method to the previous version of: 'di 9/30/1998' also works.

In a previous thread Bob Arning wrote:

The only comment I see associated with this change is

Make Etoys unloadable: Move lots of methods to Etoys package. Remove the old Fabrik remnants.


if now the methods are move out of Etoys, I think is better to revert TransformationMorph>>adjustAfter:.

On 13 Jun 2018, at 00:39, Chris Cunningham <[hidden email]> wrote:

On Tue, Jun 12, 2018 at 9:49 PM,  <[hidden email]> wrote:
Chris Cunningham uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-cbc.1450.mcz

==================== Summary ====================

Name: Morphic-cbc.1450
Author: cbc
Time: 12 June 2018, 9:49:08.273851 pm
UUID: 85dec3fe-462d-7242-bdb4-797746d320a0
Ancestors: Morphic-dtl.1449

Recategorized rotationCenter and referencePosition (and setter versions) to more a more appropriate category.
rotationCenter is the relative position of the referencePosition point within the morph.  They are related - and should live together.
Also, moved base Morph versions of these out of EToys to be with the others
<snip>
Apparently there are other methods directly related to these (such as #referencePositionInWorld) that need to be moved out of EToys as well - and re-categorized.  Eventually I'll track those down - winding down for the night.

In a related effort, I tried to track down a way to validate what these methods DO (not yet being an EToys user).
If you open a new morph in Squeak
  Morph new openInWorld
and then bring up the halo, grab the bottom left blue swirly handle, you can see the morph rotates around it's center.
At this point, it should also show the #rotationCenter in the middle (little yellow circle with an arrow)
<image.png>
You can shift-drag it around to change the rotationCenter (and referencePosition), which you can verify changes by debugging>exploring the morph.
However, after changing the rotationCenter, the morph still rotates around the center of the morph, and not around the #rotationCenter.  That is kind of annoying.  (Although I haven't ever tried this before today - still, it would be nice if all the pieces worked together.)

-cbc



Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Morphic-cbc.1450.mcz

timrowledge
In reply to this post by cbc

> However, after changing the rotationCenter, the morph still rotates around the center of the morph, and not around the #rotationCenter.  That is kind of annoying.  (Although I haven't ever tried this before today - still, it would be nice if all the pieces worked together.)

I noted a similar problem in '13 with rotating Scratch costumes and found the following in my notes -
>> ScratchSpriteMorph>turnRight: 15 is test case
>> Hm. Looks like old WarpBlt class>rotate:degrees:… returns a mixup point negative to nu version
>> Swapping the
>>                offsetWhenRotated := (costume rotationCenter + pair last) rounded].
>> for
>>                offsetWhenRotated := (costume rotationCenter - pair last) rounded].
>> Makes the level crossing barrier do the right thing.

Maybe that still has some relevance?

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
"How many Carlos Wus does it take to change a lightbulb?”
"With an unlimited breeding licence, who needs lightbulbs?"




cbc
Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Morphic-cbc.1450.mcz

cbc
In reply to this post by Javier Diaz-Reinoso
Hi Javier,

On Wed, Jun 13, 2018 at 8:53 AM, Javier Diaz-Reinoso <[hidden email]> wrote:
That is because the TransformationMorph>>adjustAfter: ('ar 1/3/2010' ) have a guard:

self actorStateOrNil ifNotNil:[
self penUpWhile: [self position: self position + (oldRefPos - self referencePosition)].
].
actorStateOrNil is created if you open a Player with Etoys, then the rotation works OK, if you revert the method to the previous version of: 'di 9/30/1998' also works.

In a previous thread Bob Arning wrote:

The only comment I see associated with this change is

Make Etoys unloadable: Move lots of methods to Etoys package. Remove the old Fabrik remnants.


if now the methods are move out of Etoys, I think is better to revert TransformationMorph>>adjustAfter:.

that fixed the issue, although I didn't do a revert (Andreas had also converted _ to :=, and I wanted to leave that in).  Basically, I just removed the guard.
Rotations of morphs now works.

I did look into tracking down how much of the EToys methods I'd have to move out to get rotation of Morphs to continue to work when EToys is unloaded - but stopped once it got to the point where I'd have to bring in player methods (and probably players) - that is (from my understanding) deep into EToys.

 Thanks,
cbc