Bert Freudenberg uploaded a new version of Morphic to project Etoys:
http://source.squeak.org/etoys/Morphic-bf.92.mcz ==================== Summary ==================== Name: Morphic-bf.92 Author: bf Time: 23 June 2012, 11:58:55 pm UUID: 7b3a67f9-80a5-45ab-82a7-652a9c1bd99e Ancestors: Morphic-bf.91 Make sure changing a Sketch's rotationStyle does not change its on-screen appearance. Previously, changing the rotation style while the Sketch's heading was in certain quadrants could result in flipping. Now, we pre-flip its form so that the object still looks the same. =============== Diff against Morphic-bf.91 =============== Item was changed: ----- Method: SketchMorph>>rotationStyle: (in category 'e-toy support') ----- rotationStyle: aSymbol "Set my rotation style to #normal, #leftRight, #upDown, or #none. Styles mean: #normal -- continuous 360 degree rotation #leftRight -- quantize angle to left or right facing #upDown -- quantize angle to up or down facing + #none -- do not rotate + Because my rendering code flips the form (see generateRotatedForm) we 'pre-flip' it here to preserve the same visual appearance. + " - #none -- do not rotate" + | wasFlippedX wasFlippedY isFlippedX isFlippedY | + wasFlippedX := rotationStyle == #leftRight + and: [ self heading asSmallAngleDegrees < 0.0 ]. + wasFlippedY := rotationStyle == #upDown + and: [ self heading asSmallAngleDegrees abs > 90.0 ]. + rotationStyle _ aSymbol. + + isFlippedX := rotationStyle == #leftRight + and: [ self heading asSmallAngleDegrees < 0.0 ]. + isFlippedY := rotationStyle == #upDown + and: [ self heading asSmallAngleDegrees abs > 90.0 ]. + + wasFlippedX == isFlippedX + ifFalse: [self form: (self form flipBy: #horizontal centerAt: self form center)]. + wasFlippedY == isFlippedY + ifFalse: [self form: (self form flipBy: #vertical centerAt: self form center)]. + self layoutChanged. ! Item was changed: ----- Method: SketchMorph>>setDirectionFrom: (in category 'geometry eToy') ----- setDirectionFrom: aPoint + "This is called when changing the forward direction by the halo arrow. If rotationStyle is set to flipping, the rendering code flips the form (see generateRotatedForm). We 'pre-flip' it here because otherwise there would be no way to actually set the forward direction without having the object visually flip while doing so." - "This is called when changing the forward direction by the halo arrow. If rotationStyle is set to flipping, the rendering code flips the form. We 'pre-flip' it here because otherwise there would be no way to actually set the forward direction without having the object visually flip while doing so." | wasFlipped isFlipped | rotationStyle == #leftRight + ifTrue: [wasFlipped := self heading asSmallAngleDegrees < 0.0 ]. - ifTrue: [wasFlipped := self heading \\ 360 - self forwardDirection asSmallAngleDegrees > 180]. rotationStyle == #upDown + ifTrue: [wasFlipped := self heading asSmallAngleDegrees abs > 90.0 ]. - ifTrue: [wasFlipped := self heading - 90 \\ 360 - (self forwardDirection - 90) asSmallAngleDegrees > 180]. super setDirectionFrom: aPoint. rotationStyle == #leftRight + ifTrue: [isFlipped := self heading asSmallAngleDegrees < 0.0. - ifTrue: [isFlipped := self heading \\ 360 - self forwardDirection asSmallAngleDegrees > 180. wasFlipped == isFlipped ifFalse: [self form: (self form flipBy: #horizontal centerAt: self form center)]]. rotationStyle == #upDown + ifTrue: [isFlipped := self heading asSmallAngleDegrees abs > 90.0. - ifTrue: [isFlipped := self heading - 90 \\ 360 - (self forwardDirection - 90) asSmallAngleDegrees > 180. wasFlipped == isFlipped + ifFalse: [self form: (self form flipBy: #vertical centerAt: self form center)]] + ! - ifFalse: [self form: (self form flipBy: #vertical centerAt: self form center)]]! _______________________________________________ etoys-dev mailing list [hidden email] http://lists.squeakland.org/mailman/listinfo/etoys-dev |
Free forum by Nabble | Edit this page |