[Etoys] [Fix] Horizontal and Vertical Flips

subbukk subbukk at gmail.com
Wed Nov 14 14:46:41 EST 2007


On Tuesday 13 November 2007 6:06 am, Scott Wallace wrote:
> Hi, Subbu,
>
> If the sketch has been rotated, this patch seems to produce incorrect
> results.
Here is my second attempt at getting Etoys to flip and tumble. The flip 
command will do a left-right swap around the rotationCenter while the tumble 
command will do a top-bottom swap.

flip/tumble operations are not propagated to submorphs and I find that a bit 
disconcerting with embedded morphs.

Turn left/right, grow/shrink/flip/tumble, shear left/right/forward/backward, 
move left/right/forward/backward transforms can be defined directly on Morphs 
(+extensions). I am confused about the role and necessity of non-visual 
morphs like TransformationMorphs and FlexMorphs. What specific problem do 
these solve?

Regards .. Subbu
-------------- next part --------------
'From etoys2.2 of 3 October 2007 [latest update: #1775] on 15 November 2007 at 12:37:31 am'!
"Change Set:		flipfixes
Date:			14 November 2007
Author:			kks

Added flip/tumble methods to Player and Viewer. Fixed flip methods in SketchMorph to take rotationCenter into account"!


!Player methodsFor: 'costume' stamp: 'kks 11/14/2007 23:39'!
flip
	| cos |
	((cos _ self costume renderedMorph) isSketchMorph)
		ifTrue:
			[cos flipHorizontal]! !

!Player methodsFor: 'costume' stamp: 'kks 11/5/2007 23:54'!
flipHorizontal
	| cos |
	((cos _ self costume renderedMorph) isSketchMorph)
		ifTrue:
			[cos flipHorizontal]! !

!Player methodsFor: 'costume' stamp: 'kks 11/5/2007 23:54'!
flipVertical
	| cos |
	((cos _ self costume renderedMorph) isSketchMorph)
		ifTrue:
			[cos flipVertical]! !

!Player methodsFor: 'costume' stamp: 'kks 11/14/2007 23:39'!
tumble
	| cos |
	((cos _ self costume renderedMorph) isSketchMorph)
		ifTrue:
			[cos flipVertical]! !


!SketchMorph methodsFor: 'e-toy support' stamp: 'kks 11/15/2007 00:28'!
flipHorizontal

	|  r |
	r _ self rotationCenter.
	self left:  self left - (1.0 - (2 * r x) * self width).
	self form: (self form flipBy: #horizontal centerAt: self form center).
	self rotationCenter: (1 - r x) @ (r y).! !

!SketchMorph methodsFor: 'e-toy support' stamp: 'kks 11/15/2007 00:32'!
flipVertical

	|  r |
	r _ self rotationCenter.
	self top:  self top - (1.0 - (2 * r y) * self height).
	self form: (self form flipBy: #vertical centerAt: self form center).
	self rotationCenter:  r x @ (1 - r y).! !


!SketchMorph class methodsFor: 'scripting' stamp: 'kks 11/14/2007 23:39'!
additionsToViewerCategories
	"Answer a list of (<categoryName> <list of category specs>) pairs that characterize the phrases this kind of morph wishes to add to various Viewer categories."

	^ #((graphics (
(slot graphic 	'The picture currently being worn' Graphic	 readWrite Player getGraphic Player setGraphic:)
(command wearCostumeOf: 'wear the costume of...' Player)
(slot baseGraphic 	'The picture originally painted for this object, but can subsequently be changed via menu or script' Graphic	 readWrite Player getBaseGraphic Player setBaseGraphic:)
(command restoreBaseGraphic 'Make my picture be the one I remember in my baseGraphic')

(slot rotationStyle 'How the picture should change when the heading is modified' RotationStyle readWrite Player getRotationStyle Player setRotationStyle:)
(command flip 'Flip left right' Player)
(command tumble 'Flip up down' Player)
)))


! !



More information about the Etoys mailing list