[etoys-dev] Etoys Inbox: Morphic-kks.67.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Jul 30 07:50:32 EDT 2011


A new version of Morphic was added to project Etoys Inbox:
http://source.squeak.org/etoysinbox/Morphic-kks.67.mcz

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

Name: Morphic-kks.67
Author: kks
Time: 30 July 2011, 5:18:47 pm
UUID: 33db131b-2c4b-40e6-883a-77678befec97
Ancestors: Morphic-kfr.66

Create a silhouette from any morph or use one as a stencil to create a sketch. see in "extras.." sub-menu.

=============== Diff against Morphic-kfr.66 ===============

Item was added:
+ ----- Method: EllipseMorph class>>fromHand: (in category 'class initialization') -----
+ fromHand: aHand
+ 	"Create an EllipseMorph interactively"
+ 	| origin color ellipse w drawBlock savecursor |
+ 	w _ self currentWorld.
+ 	Cursor crossHair showWhile: [
+ 		[Sensor noButtonPressed] whileTrue: [w displayWorldSafely; runStepMethods].
+ 		origin _ Sensor cursorPoint].
+ 	color _ Color yellow alpha: 0.2.
+ 	ellipse _ EllipseMorph new extent: 10 at 10; center: origin;  color: color;  width: 2.
+ 	ellipse openInWorld: w.
+ 	drawBlock _ [:p |
+ 		ellipse extent: (p - origin) abs * 2; center: origin.
+ 		w displayWorldSafely; runStepMethods].
+ 	savecursor _ Sensor currentCursor.
+ 	Cursor corner show.
+ 	[true] whileTrue: [
+ 		[Sensor anyButtonPressed] whileTrue: [ drawBlock value: Sensor cursorPoint ].
+ 		(Sensor cursorPoint dist: origin) > 3 ifTrue: [
+ 				drawBlock value: Sensor cursorPoint.
+ 				 aHand position: Sensor cursorPoint.
+ 				savecursor show.
+ 				ellipse color: (ellipse color alpha: 1.0).
+ 				^ellipse delete].
+ 		[Sensor noButtonPressed] whileTrue: [ drawBlock value: Sensor cursorPoint ].
+ ].
+ "
+ EllipseMorph fromHand: ActiveHand
+ "!

Item was added:
+ ----- Method: EllipseMorph class>>newFrom: (in category 'class initialization') -----
+ newFrom: aHand
+ 	"Create a new ellipse interactively"
+ 	| e |
+ 	e _ self fromHand: aHand.
+ 	e openInWorld: aHand world.
+ "
+ 	EllipseMorph newFrom: ActiveHand.
+ "!

Item was changed:
  ----- Method: Morph>>addMiscExtrasTo: (in category 'menus') -----
  addMiscExtrasTo: aMenu
  	"Add a submenu of miscellaneous extra items to the menu."
  
  	| realOwner realMorph subMenu |
  	subMenu _ MenuMorph new defaultTarget: self.
  	(Preferences eToyFriendly not and: [self isWorldMorph not and: [self renderedMorph isSystemWindow not]])
  		ifTrue: [subMenu add: 'put in a window' translated action: #embedInWindow].
  
  	self isWorldMorph ifFalse:
  		[subMenu add: 'adhere to edge...' translated action: #adhereToEdge.
  		subMenu addLine].
  
  	realOwner _ (realMorph _ self topRendererOrSelf) owner.
  	(realOwner isKindOf: TextPlusPasteUpMorph) ifTrue:
  		[subMenu add: 'GeeMail stuff...' translated subMenu: (realOwner textPlusMenuFor: realMorph)].
  
  	Preferences eToyFriendly
   ifFalse: [
  		subMenu
  	
  		add: 'add mouse up action' translated action: #addMouseUpAction;
  	
  		add: 'remove mouse up action' translated action: #removeMouseUpAction;
  	
  		add: 'hand me tiles to fire this button' translated action: #handMeTilesToFire.
  	
  	subMenu addLine.
  	].
  
  	Preferences eToyFriendly
   ifFalse: [
  		subMenu add: 'arrowheads on pen trails...' translated action: #setArrowheads.
  	
  	subMenu addLine.
  	
  ].
  	subMenu defaultTarget: self topRendererOrSelf.
  	(self isWorldMorph not and: [(self renderedMorph isSystemWindow) not]) ifTrue: [
  		subMenu add: 'draw new path' translated action: #definePath.
  	
  	subMenu add: 'follow existing path' translated action: #followPath.
  	
  	subMenu add: 'delete existing path' translated action: #deletePath.
  	
  	subMenu addLine.
  	].
  	self addGestureMenuItems: subMenu hand: ActiveHand.
  
  	self isWorldMorph ifFalse:
  		[subMenu add: 'balloon help for this object' translated action: #editBalloonHelpText].
  
+ 	subMenu addLine.
+ 	subMenu add: 'sketch this' translated action: #sketchIt.
+ 	subMenu add: 'sketch a silhouette' translated action: #sketchASilhouette.
+ 	subMenu add: 'stencil a sketch' translated action: #stencilASketch.
+ 
  	subMenu submorphs isEmpty ifFalse: [
  		aMenu add: 'extras...' translated subMenu: subMenu
+ 	].
+ !
- 	].!

Item was added:
+ ----- Method: Morph>>silhouetteForm (in category 'drawing') -----
+ silhouetteForm
+ 	"Return a form representing the 'shadow' of the receiver including all its submorphs"
+ 	| bnds canvas form |
+ 	bnds _ self fullBounds.
+ 	canvas _ (Display defaultCanvasClass extent: bnds extent depth: 1)
+ 				asShadowDrawingCanvas: Color black. "Color black represents one for 1bpp"
+ 	canvas translateBy: bnds topLeft negated
+ 		during:[:tempCanvas|
+ 			self fullDrawOn: tempCanvas].
+ 	form _ ColorForm mappingWhiteToTransparentFrom: canvas form.
+ 	^form offset: bnds topLeft.
+ !

Item was added:
+ ----- Method: Morph>>sketchASilhouette (in category 'as yet unclassified') -----
+ sketchASilhouette
+ 	| w m |
+ 	w _ self world ifNil: [ActiveWorld ].
+ 	m _ w drawingClass withForm: self silhouetteForm.
+ 	m openInHand.!

Item was added:
+ ----- Method: Morph>>sketchIt (in category 'as yet unclassified') -----
+ sketchIt
+ 	| w m |
+ 	w _ self world ifNil: [ActiveWorld].
+ 	m _ w drawingClass withMorph: self.
+ 	m openInHand.!

Item was added:
+ ----- Method: Morph>>stencilASketch (in category 'as yet unclassified') -----
+ stencilASketch
+ 	| m |
+ 	self world ifNil: [^self ].
+ 	m _ SketchMorph withStencil: self.
+ 	m openInHand.!

Item was changed:
  ----- Method: PasteUpMorph>>grabFloodFromScreen: (in category 'world menu') -----
  grabFloodFromScreen: evt
  	"Allow the user to plant a flood seed on the Display, and create a new drawing morph from the resulting region. Attach the result to the hand."
  	| screenForm exterior p1 box |
  	Cursor crossHair showWhile: [p1 _ Sensor waitButton].
  	box _ Display floodFill: Color transparent at: p1.
  	exterior _ ((Display copy: box) makeBWForm: Color transparent) reverse.
  	self world invalidRect: box; displayWorldSafely.
  	(box area > (Display boundingBox area // 2))
  		ifTrue: [^ PopUpMenu notify: 'Sorry, the region was too big'].
  	(exterior deepCopy reverse anyShapeFill reverse)  "save interior bits"
  		displayOn: exterior at: 0 at 0 rule: Form and.
  	screenForm _ Form fromDisplay: box.
  	screenForm eraseShape: exterior.
  	screenForm isAllWhite ifFalse:
+ 		[(evt ifNil: [ActiveHand] ifNotNil: [ evt hand]) attachMorph: (self drawingClass withForm: screenForm)]!
- 		[evt hand attachMorph: (self drawingClass withForm: screenForm)]!

Item was added:
+ ----- Method: PolygonMorph class>>newFrom: (in category 'instance creation') -----
+ newFrom: aHand
+ 	"Rubber-band tool for polygons"
+ 	| polygon |
+ 	polygon _ self fromHand: aHand.
+ 	polygon makeClosed; color: (Color orange lighter alpha: 0.7).
+ 	polygon openInWorld: aHand world.
+ "
+ 	PolygonMorph newFrom: ActiveHand.
+ "
+ 	!

Item was added:
+ ----- Method: PolygonMorph class>>newLassoFrom: (in category 'instance creation') -----
+ newLassoFrom: aHand
+ 	"Smooth Polygon tool"
+ 	| polygon |
+ 	polygon _ self fromHandFreehand: aHand.
+ 	polygon makeClosed; color: (Color orange lighter alpha: 0.7).
+ 	polygon openInWorld: aHand world.
+ "
+ 	PolygonMorph newLassoOn: ActiveHand.
+ "
+ 	!

Item was added:
+ ----- Method: RectangleMorph class>>fromHand: (in category 'class initialization') -----
+ fromHand: hand
+ 	"Let the user draw a rectangle by indicating top left origin and bottom right corner"
+ 	| rect  |
+ 	rect := Rectangle fromUser.
+ 	^self authoringPrototype
+ 		position: rect origin;
+ 		extent: rect extent.
+ 
+ "
+ RectangleMorph fromHand: ActiveHand
+ "
+ !

Item was added:
+ ----- Method: RectangleMorph class>>newFrom: (in category 'class initialization') -----
+ newFrom: hand
+ 	"Let the user draw a rectangle by indicating top left origin and bottom right corner"
+ 	|  m |
+ 	m _ self fromHand: hand.
+ 	m openInWorld: hand world.
+ "
+ RectangleMorph fromHand: ActiveHand
+ "
+ !

Item was added:
+ ----- Method: SketchMorph class>>fromLasso (in category 'instance creation') -----
+ fromLasso
+ 	"Create a sketch by rubber-banding a region interactively"
+ 	| lasso |
+ 	lasso _ PolygonMorph fromHandFreehand: self currentHand.
+ 	lasso makeClosed.
+ 	(self withStencil: lasso) openInHand.
+ "
+ 	SketchMorph fromLasso.
+ "!

Item was added:
+ ----- Method: SketchMorph class>>fromPolygon (in category 'instance creation') -----
+ fromPolygon
+ 	"Create a sketch by rubber-banding a region"
+ 	| polygon |
+ 	polygon _ PolygonMorph fromHand: self currentHand.
+ 	polygon makeClosed.
+ 	(self withStencil: polygon) openInHand.
+ "
+ 	SketchMorph fromPolygon.
+ "!

Item was added:
+ ----- Method: SketchMorph class>>withMorph: (in category 'instance creation') -----
+ withMorph: aMorph
+ 	"Create a sketch from a Morph and its submorphs"
+ 
+ 	| bnds canvas |
+ 	bnds _ aMorph fullBounds.
+ 	canvas _ Display defaultCanvasClass extent: bnds extent.
+ 	canvas translateBy: bnds topLeft negated during: [ :tmpCanvas |
+ 		aMorph fullDrawOn: tmpCanvas].
+ 	^SketchMorph withForm: (canvas form offset: bnds topLeft).
+ 	!

Item was added:
+ ----- Method: SketchMorph class>>withStencil: (in category 'instance creation') -----
+ withStencil: stencilMorph
+ 	"Create a sketch from Display by using a morph as a stencil"
+ 
+ 	| w outline topLeft baseForm finalForm |
+ 	w _ stencilMorph world ifNil: [ActiveWorld].
+ 	outline _ stencilMorph silhouetteForm.
+ 	topLeft _ outline offset.
+ 	stencilMorph hide.
+ 	w displayWorldSafely.
+ 	baseForm _ stencilMorph pasteUpMorphOrWorld imageFormForRectangle: (topLeft extent: outline extent).
+ 	stencilMorph show.
+ 	finalForm _ (baseForm eraseShape: (outline reverse offset: 0 at 0)) trimBordersOfColor: Color transparent.
+ 	^SketchMorph withForm: finalForm.
+ 
+ "
+ 	(SketchMorph withStencil: (EllipseMorph new position: Display center)) openInHand
+ "
+ 	!



More information about the etoys-dev mailing list