#FEATURE by cg
class: ImageEditView
comment/format in:
#drawingAlpha
#drawingColorOrNil
#initialize
changed:
#filledBoxAt:
#pointAt:width:
#selectedColor
--- a/ImageEditView.st Tue Sep 05 10:41:02 2017 +0200
+++ b/ImageEditView.st Tue Sep 05 16:45:34 2017 +0200
@@ -213,7 +213,7 @@
^ drawingAlpha ? 100
"Created: / 05-09-2017 / 09:11:32 / cg"
- "Modified: / 05-09-2017 / 10:40:25 / cg"
+ "Modified: / 05-09-2017 / 10:47:18 / cg"
!
drawingAlpha:anAlphaValue
@@ -477,16 +477,22 @@
clr isNil ifTrue:[ clr := Color black ].
image hasAlphaChannel ifTrue:[
+ clr isPseudoColor ifTrue:[
+ "/ the mask is selected - return a pseudoColor holding ONLY the alpha value
+ "/ will be detected in the drawing operations to change the alpha value only
+ ^ TranslucentColor new
+ alpha:((drawingAlpha ? 100) / 100)
+ ].
+
^ (TranslucentColor
scaledRed:clr scaledRed
scaledGreen:clr scaledGreen
scaledBlue:clr scaledBlue)
- alpha:(drawingAlpha ? 1.0)
+ alpha:((drawingAlpha ? 100) / 100)
].
^ clr
- "Modified: / 23-02-2017 / 10:17:06 / cg"
- "Modified (format): / 05-09-2017 / 09:10:35 / cg"
+ "Modified (format): / 05-09-2017 / 12:21:53 / cg"
!
selectedColor: aColor
@@ -1266,6 +1272,7 @@
^ nil
"Created: / 03-02-2017 / 21:58:01 / cg"
+ "Modified: / 05-09-2017 / 10:49:34 / cg"
!
drawingPixelOrNil
@@ -2010,7 +2017,7 @@
"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|
+ |draw imagePoint clr pix oldColor newColor|
imagePoint := aPoint // magnification.
(imagePoint x between:0 and:image width-1) ifFalse:[^ self].
@@ -2019,7 +2026,19 @@
draw :=
[:point |
(clr := self drawingColorOrNil) notNil ifTrue:[
- image atImageAndMask:point put:clr.
+ clr isPseudoColor ifTrue:[
+ "/ only set the alpha value
+ newColor := (image colorAt:point) alpha:clr alpha.
+ image atImageAndMask:point put:newColor
+ ] ifFalse:[
+ clr alpha == 1 ifTrue:[
+ image atImageAndMask:point put:clr.
+ ] ifFalse:[
+ oldColor := image colorAt:point.
+ newColor := clr alphaMixed:clr alpha with:oldColor.
+ image atImageAndMask:point put:newColor
+ ].
+ ].
] ifFalse:[
(pix := self drawingPixelOrNil) notNil ifTrue:[
image atImageAndMask:point putValue:pix.
@@ -2045,8 +2064,7 @@
self setModified.
"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"
+ "Modified: / 05-09-2017 / 14:43:04 / cg"
!
shiftImageHorizontal:shiftH vertical:shiftV
@@ -2368,15 +2386,11 @@
self
commonBoxOperation:[:box :colorOrPixel |
- colorOrPixel isColor notNil ifTrue:[
- image fillRectangle:box withColor:colorOrPixel.
- ] ifFalse:[
- image fillRectangle:box withValue:colorOrPixel.
- ].
+ image fillRectangle:box with:colorOrPixel.
]
at:aPoint
- "Modified: / 16-02-2017 / 12:08:46 / cg"
+ "Modified: / 05-09-2017 / 14:50:51 / cg"
!
filledCircleAt: aPoint
@@ -3382,7 +3396,7 @@
self editMode:EditModePoint.
- "Modified: / 05-09-2017 / 10:40:54 / cg"
+ "Modified: / 05-09-2017 / 10:47:11 / cg"
! !
!ImageEditView methodsFor:'loading & saving'!