--- a/ImageEditView.st Thu Feb 16 01:29:06 2017 +0100
+++ b/ImageEditView.st Thu Feb 16 12:38:42 2017 +0100
@@ -351,6 +351,14 @@
]
!
+selectMaskForDrawing
+ self selectedColor:(Color black).
+ self selectedColorIndex:nil.
+ self changed:#selectedColor with:(Color black).
+
+ "Created: / 16-02-2017 / 09:57:40 / cg"
+!
+
selectedColor
|clr|
@@ -829,7 +837,8 @@
("self selectedColor notNil" true
and: [self imageContainsPoint:p])
- ifTrue:[
+ ifTrue:[
+ "/ shift click: select the pixel-color
(self inPasteMode not
and:[self sensor shiftDown]) ifTrue:[
(image maskAt:(p // magnification)) == 0 ifTrue:[
@@ -839,14 +848,13 @@
clr := image colorAt:(p // magnification).
].
pickedColorHolder notNil ifTrue:[
- "/ select the color under the cursor, place it into the
- "/ pickedColorHolder/
pickedColorHolder value:clr.
].
self selectedColor:clr.
masked ifTrue:[self selectedColorIndex:nil].
self changed:#selectedColor with:clr.
] ifFalse:[
+ "/ normal click:
(readOnly not
or:[editMode == EditModeCopy
or:[editMode == EditModeSpecialOperation]]
@@ -860,6 +868,7 @@
clickInfoCallBack value:button value:p
].
"/ editMode is something like #point, #rectangle etc.
+ "/ so we call pointAt: / rectAt: / filledBoxAt: etc. here
[
self perform: (editMode, 'At:') asSymbol with:p
] on:Error do:[:ex |
@@ -874,6 +883,7 @@
]
"Modified: / 03-05-2011 / 12:26:06 / cg"
+ "Modified (comment): / 16-02-2017 / 11:09:34 / cg"
!
buttonRelease:button x:x y:y
@@ -929,8 +939,43 @@
!ImageEditView methodsFor:'image editing'!
boxAt: aPoint
- "drag a rectangular outline,
- when released draw a rectangle with the currently selected color"
+ "called from button-press/button motion while in box-drawing mode:
+ drag a rectangular outline,
+ when released, draw a rectangle with the currently selected color"
+
+ self
+ commonBoxOperation:[:box :colorOrPixel |
+ colorOrPixel isColor notNil ifTrue:[
+ image drawRectangle:box withColor:colorOrPixel.
+ ] ifFalse:[
+ image drawRectangle:box withValue:colorOrPixel.
+ ].
+ ]
+ at:aPoint
+
+ "Modified: / 16-02-2017 / 11:22:11 / cg"
+!
+
+circleAt: aPoint
+ "called from button-press/button motion while in circle-drawing mode:
+ drag an ellipse,
+ when released, draw an ellipse with the currently selected color"
+
+ self
+ commonBoxOperation:[:box :colorOrPixel |
+ colorOrPixel isColor notNil ifTrue:[
+ image drawEllipse:box withColor:colorOrPixel.
+ ] ifFalse:[
+ image drawEllipse:box withValue:colorOrPixel.
+ ].
+ ]
+ at:aPoint
+
+ "Modified: / 16-02-2017 / 11:22:37 / cg"
+!
+
+commonBoxOperation:action at:aPoint
+ "common code for filling/drawing."
|choosenBox imageBox clr pix|
@@ -939,44 +984,10 @@
choosenBox notNil ifTrue:[
imageBox := choosenBox origin//magnification extent: (choosenBox extent//magnification).
(clr := self drawingColorOrNil) notNil ifTrue:[
- image drawRectangle:imageBox withColor:clr.
+ action value:imageBox value:clr.
] ifFalse:[
(pix := self drawingPixelOrNil) notNil ifTrue:[
- image drawRectangle:imageBox withValue:pix.
- ].
- ].
- image restored.
- self redraw: (choosenBox expandedBy: 1).
-
-"/ "/ cg: what a kludge - please change to use a valueHolder,
-"/ "/ which gets the information ...
-"/ masterApplication imagePreView redraw: (imageBox expandedBy: 1).
-
- "/ cg: still a kludge - but less ugly
- self changed:#subImageIn with:(imageBox expandedBy: 1).
-
- self setModified.
- ].
- ].
-
- "Modified: / 03-02-2017 / 22:01:02 / cg"
-!
-
-circleAt: aPoint
- "drag an ellipse,
- when released draw an ellipse with the currently selected color"
-
- |choosenBox imageBox clr pix|
-
- (clr := self selectedColor) notNil ifTrue:[
- choosenBox := self dragRectangleStartingAt: aPoint emphasis: #box.
- choosenBox notNil ifTrue:[
- imageBox := choosenBox origin//magnification extent: (choosenBox extent//magnification).
- (clr := self drawingColorOrNil) notNil ifTrue:[
- image drawEllipse:imageBox withColor:clr.
- ] ifFalse:[
- (pix := self drawingPixelOrNil) notNil ifTrue:[
- image drawEllipse:imageBox withValue:pix.
+ action value:imageBox value:pix.
].
].
image restored.
@@ -989,12 +1000,13 @@
].
].
- "Modified: / 03-02-2017 / 22:01:28 / cg"
+ "Created: / 16-02-2017 / 11:20:49 / cg"
!
copyAt: aPoint
- "drag a filled box,
- when released copy the selected rectangle to the clipboard"
+ "called from button-press/button motion while in copy-drawing mode:
+ drag a filled box,
+ when released, copy the selected rectangle to the clipboard"
|choosenBox box copiedImage|
@@ -1008,7 +1020,8 @@
self redraw:(choosenBox expandedBy:1)
]
- "Modified: / 21.8.1998 / 20:16:41 / cg"
+ "Modified: / 21-08-1998 / 20:16:41 / cg"
+ "Modified (comment): / 16-02-2017 / 11:15:09 / cg"
!
copyImageToClipboard
@@ -1139,7 +1152,8 @@
!
fillAt: aPoint
- "perform a flood-fill with the currently selected color"
+ "called from button-press motion while in floo-fill drawing mode:
+ perform a flood-fill with the currently selected color"
windowGroup withExecuteCursorDo:[
|filledPoints clr|
@@ -1169,40 +1183,43 @@
self updateActivity:''
]
- "Modified (format): / 03-02-2017 / 22:02:46 / cg"
+ "Modified (comment): / 16-02-2017 / 11:14:55 / cg"
!
filledBoxAt: aPoint
- "drag a filled box,
- when released fill a rectangular area with the currently selected color"
-
- |choosenBox imageBox clr pix|
-
- (clr := self selectedColor) notNil ifTrue:[
- choosenBox := self dragRectangleStartingAt: aPoint emphasis: #filledBox.
- choosenBox notNil ifTrue:[
- imageBox := choosenBox origin//magnification extent: (choosenBox extent//magnification).
-
- (clr := self drawingColorOrNil) notNil ifTrue:[
- image fillRectangle:imageBox withColor:clr.
+ "called from button-press/button motion while in filled rectangle-drawing mode:
+ drag a filled box,
+ when released, fill a rectangular area with the currently selected color"
+
+ self
+ commonBoxOperation:[:box :colorOrPixel |
+ colorOrPixel isColor notNil ifTrue:[
+ image fillRectangle:box withColor:colorOrPixel.
] ifFalse:[
- (pix := self drawingPixelOrNil) notNil ifTrue:[
- image fillRectangle:imageBox withValue:pix.
-"/ maskVal := pix isNil ifTrue:[0] ifFalse:[1].
-"/ image mask notNil ifTrue:[
-"/ image mask fillRectangle:imageBox withValue:maskVal
-"/ ].
- ].
+ image fillRectangle:box withValue:colorOrPixel.
].
- image restored.
- self redraw: (choosenBox expandedBy: 1).
-
- self changed:#subImageIn with:(imageBox expandedBy: 1).
- self setModified.
]
- ]
-
- "Modified: / 03-02-2017 / 22:03:12 / cg"
+ at:aPoint
+
+ "Modified: / 16-02-2017 / 12:08:46 / cg"
+!
+
+filledCircleAt: aPoint
+ "called from button-press/button motion while in filled circle-drawing mode:
+ drag a filled ellipse,
+ when released, fill an ellipse with the currently selected color"
+
+ self
+ commonBoxOperation:[:box :colorOrPixel |
+ colorOrPixel isColor notNil ifTrue:[
+ image fillEllipse:box withColor:colorOrPixel.
+ ] ifFalse:[
+ image fillEllipse:box withValue:colorOrPixel.
+ ].
+ ]
+ at:aPoint
+
+ "Created: / 16-02-2017 / 11:10:17 / cg"
!
flipSubImage:how in:imageBox
@@ -1384,14 +1401,54 @@
"Modified: / 20-11-2007 / 17:26:50 / cg"
!
+maskOutsideCircleAt: aPoint
+ "called from button-press/button motion while in filled rectangle-drawing mode:
+ drag a box,
+ when released, mask everything outside the rectangular area"
+
+ self
+ commonBoxOperation:[:box :colorOrPixel |
+ image mask fillRectangle:(image bounds) withValue:0.
+ image mask fillEllipse:box withValue:1.
+ ]
+ at:aPoint.
+
+ image restored.
+ self invalidate.
+
+ "Created: / 16-02-2017 / 12:33:25 / cg"
+!
+
+maskOutsideRectAt: aPoint
+ "called from button-press/button motion while in filled rectangle-drawing mode:
+ drag a box,
+ when released, mask everything outside the rectangular area"
+
+ self
+ commonBoxOperation:[:box :colorOrPixel |
+ image mask fillRectangle:(image bounds) withValue:0.
+ image mask fillRectangle:box withValue:1.
+ ]
+ at:aPoint.
+
+ image restored.
+ self invalidate.
+
+ "Created: / 16-02-2017 / 12:33:06 / cg"
+!
+
pasteAt: aPoint
- "paste the image in the clipboard at aPoint"
+ "called from button-press/button motion while in paste mode:
+ paste the image in the clipboard at aPoint"
self pasteAt:aPoint mode:nil.
+
+ "Modified (comment): / 16-02-2017 / 11:13:54 / cg"
!
pasteAt: aPoint mode:modeSymbol
- "paste the image in the clipboard at aPoint"
+ "called from button-press/button motion while in paste mode:
+ paste the image in the clipboard at aPoint"
|answer anyColorMissing choosenBox imagePoint imgX imgY copiedImage imageBox newColorMap
existingColors newColors allColors currentColorMap newColormap anyColorAdded oldColorMap|
@@ -1599,23 +1656,29 @@
]
"Modified: / 03-02-2017 / 17:10:05 / cg"
- "Modified (format): / 13-02-2017 / 20:22:57 / cg"
+ "Modified (comment): / 16-02-2017 / 11:13:59 / cg"
!
pasteUnderAt: aPoint
- "pasteUnder the image in the clipboard at aPoint.
+ "called from button-press/button motion while in paste mode:
+ pasteUnder the image in the clipboard at aPoint.
In this mode, only pixels which are not equal to
the current color or masked are pasted."
self pasteAt:aPoint mode:#under.
+
+ "Modified (comment): / 16-02-2017 / 11:14:04 / cg"
!
pasteWithMaskAt: aPoint
- "paste the image in the clipboard at aPoint.
+ "called from button-press/button motion while in paste mode:
+ paste the image in the clipboard at aPoint.
In this mode, both the mask and the image pixel are pasted"
self pasteAt:aPoint mode:#withMask.
+
+ "Modified (comment): / 16-02-2017 / 11:14:08 / cg"
!
performSpecialOperationOn:imageBox withColor:clr
@@ -1804,15 +1867,18 @@
!
pointAt:aPoint
- "draw a single pixel with the currently selected color"
+ "called from button-press/button motion while in point-drawing mode:
+ draw a single pixel with the currently selected color"
self pointAt:aPoint width:self penWidth.
"Modified: / 15-02-2012 / 22:47:30 / cg"
+ "Modified (comment): / 16-02-2017 / 11:13:06 / cg"
!
pointAt:aPoint width:pw
- "draw a single pixel (or dot of width pw) with the currently selected color"
+ "called from button-press/button motion while in point-drawing mode:
+ draw a single pixel (or dot of width pw) with the currently selected color"
|draw imagePoint clr pix|
@@ -1850,6 +1916,7 @@
"Created: / 15-02-2012 / 22:47:08 / cg"
"Modified: / 03-02-2017 / 21:59:41 / cg"
+ "Modified (comment): / 16-02-2017 / 11:12:52 / cg"
!
shiftImageHorizontal:shiftH vertical:shiftV
@@ -1951,7 +2018,8 @@
!
smoothAt:aPoint
- "smoth (average) a single pixel with pixels around"
+ "called from button-press/button motion while in smoothing mode:
+ smoth (average) a single pixel with pixels around"
|draw imagePoint x y w h|
@@ -1984,11 +2052,12 @@
redByte:(sumRed / 9) rounded
greenByte:(sumGreen / 9) rounded
blueByte:(sumBlue / 9) rounded.
+
image colorMap isNil ifTrue:[
-Transcript
- show:(image colorAt:point);
- show:' -> ';
- showCR:newClr.
+ "/ Transcript
+ "/ show:(image colorAt:point);
+ "/ show:' -> ';
+ "/ showCR:newClr.
image atImageAndMask:point put:newClr.
] ifFalse:[
image atImageAndMask:point put:(image colorMap colorNearestTo:newClr).
@@ -1998,6 +2067,8 @@
draw value:imagePoint.
self setModified.
+
+ "Modified: / 16-02-2017 / 12:34:41 / cg"
!
specialOperationAt: aPoint
@@ -2030,7 +2101,8 @@
!
sprayAt: aPoint
- "start spraying with the currently selected color"
+ "called from button-press/button motion while in spray mode:
+ start spraying with the currently selected color"
|clr|
@@ -2038,6 +2110,8 @@
sprayPosition := aPoint.
self startSpray.
].
+
+ "Modified (comment): / 16-02-2017 / 11:12:28 / cg"
!
text:aString at:aPoint