Chris Muller uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-cmm.457.mcz ==================== Summary ==================== Name: Morphic-cmm.457 Author: cmm Time: 2 August 2010, 6:31:17.394 pm UUID: 5d35793d-32ee-49cc-8a14-b4e2ef43db03 Ancestors: Morphic-ar.456 Refactor SketchMorph repainting items, separating the domain work from the user-interface. =============== Diff against Morphic-ar.456 =============== Item was changed: ----- Method: SketchMorph>>erasePixelsOfColor: (in category 'menu') ----- + erasePixelsOfColor: aColor - erasePixelsOfColor: evt "Let the user specifiy a color such that all pixels of that color should be erased; then do the erasure" + | newBounds | + originalForm + mapColor: aColor + to: Color transparent. + newBounds := originalForm rectangleEnclosingPixelsNotOfColor: Color transparent. + self form: (originalForm copy: newBounds)! - - | c r | - self changeColorTarget: self selector: #rememberedColor: originalColor: nil hand: evt hand. "color to erase" - c := self rememberedColor ifNil: [Color red]. - originalForm mapColor: c to: Color transparent. - r := originalForm rectangleEnclosingPixelsNotOfColor: Color transparent. - self form: (originalForm copy: r). - - ! Item was added: + ----- Method: SketchMorph>>erasePixelsUsing: (in category 'menu') ----- + erasePixelsUsing: evt + "Let the user specifiy a color such that all pixels of that color should be erased; then do the erasure" + self + changeColorTarget: self + selector: #rememberedColor: + originalColor: nil + hand: evt hand. + self rememberedColor "color to erase" + ifNil: [ ^ self ] + ifNotNilDo: + [ : chosenColor | self erasePixelsOfColor: chosenColor ]! Item was added: + ----- Method: SketchMorph>>recolorPixelsOfColor:with: (in category 'menu') ----- + recolorPixelsOfColor: originalColor with: newColor + "Let the user select a color to be remapped, and then a color to map that color to, then carry it out." + | d newForm map | + d := originalForm depth. + newForm := Form extent: originalForm extent depth: d. + map := (Color cachedColormapFrom: d to: d) copy. + map at: (originalColor indexInMap: map) put: (newColor pixelValueForDepth: d). + newForm copyBits: newForm boundingBox + from: originalForm at: 0@0 + colorMap: map. + self form: newForm. + ! Item was changed: ----- Method: Morph>>addPaintingItemsTo:hand: (in category 'menus') ----- addPaintingItemsTo: aMenu hand: aHandMorph | subMenu movies | subMenu := MenuMorph new defaultTarget: self. subMenu add: 'repaint' translated action: #editDrawing. subMenu add: 'set rotation center' translated action: #setRotationCenter. subMenu add: 'reset forward-direction' translated action: #resetForwardDirection. subMenu add: 'set rotation style' translated action: #setRotationStyle. subMenu add: 'erase pixels of color' translated + action: #erasePixelsUsing:. - action: #erasePixelsOfColor:. subMenu add: 'recolor pixels of color' translated + action: #recolorPixelsUsing:. - action: #recolorPixelsOfColor:. subMenu add: 'reduce color palette' translated action: #reduceColorPalette:. subMenu add: 'add a border around this shape...' translated action: #addBorderToShape:. movies := (self world rootMorphsAt: aHandMorph targetPoint) select: [:m | (m isKindOf: MovieMorph) or: [m isSketchMorph]]. movies size > 1 ifTrue: [subMenu add: 'insert into movie' translated action: #insertIntoMovie:]. aMenu add: 'painting...' translated subMenu: subMenu! Item was added: + ----- Method: SketchMorph>>recolorPixelsUsing: (in category 'menu') ----- + recolorPixelsUsing: evt + "Let the user select a color to be remapped, and then a color to map that color to, then carry it out." + | originalColor newColor | + self inform: 'choose the color you want to replace' translated. + self + changeColorTarget: self + selector: #rememberedColor: + originalColor: nil + hand: evt hand. + "color to replace" + originalColor := self rememberedColor ifNil: [ ^ self ]. + self inform: 'now choose the color you want to replace it with' translated. + self + changeColorTarget: self + selector: #rememberedColor: + originalColor: originalColor + hand: evt hand. + "new color" + newColor := self rememberedColor ifNil: [ ^ self ]. + self + recolorPixelsOfColor: originalColor + with: newColor! Item was removed: - ----- Method: SketchMorph>>recolorPixelsOfColor: (in category 'menu') ----- - recolorPixelsOfColor: evt - "Let the user select a color to be remapped, and then a color to map that color to, then carry it out." - - | c d newForm map newC | - self inform: 'choose the color you want to replace' translated. - self changeColorTarget: self selector: #rememberedColor: originalColor: nil hand: evt hand. "color to replace" - c := self rememberedColor ifNil: [Color red]. - self inform: 'now choose the color you want to replace it with' translated. - self changeColorTarget: self selector: #rememberedColor: originalColor: c hand: evt hand. "new color" - newC := self rememberedColor ifNil: [Color blue]. - d := originalForm depth. - newForm := Form extent: originalForm extent depth: d. - map := (Color cachedColormapFrom: d to: d) copy. - map at: (c indexInMap: map) put: (newC pixelValueForDepth: d). - newForm copyBits: newForm boundingBox - from: originalForm at: 0@0 - colorMap: map. - self form: newForm. - ! |
Free forum by Nabble | Edit this page |