# HG changeset patch # User Claus Gittinger # Date 1193957301 -3600 # Node ID 398c9aba65883fbe672883fca40542a36ac8338c # Parent 88d55c87942d95ff7568a7ecf48a9fea2ee04765 pen width diff -r 88d55c87942d -r 398c9aba6588 ImageEditor.st --- a/ImageEditor.st Wed Oct 31 11:40:49 2007 +0100 +++ b/ImageEditor.st Thu Nov 01 23:48:21 2007 +0100 @@ -2183,6 +2183,11 @@ itemValue: changeHLS translateLabel: true ) + (MenuItem + label: 'Colorize...' + itemValue: colorize + translateLabel: true + ) ) nil nil @@ -2236,6 +2241,35 @@ itemValue: doChangeGridMagnification translateLabel: true ) + (MenuItem + label: 'Pen' + translateLabel: true + submenu: + (Menu + ( + (MenuItem + label: '1' + itemValue: penWidth: + translateLabel: true + argument: 1 + ) + (MenuItem + label: '5' + itemValue: penWidth: + translateLabel: true + argument: 5 + ) + (MenuItem + label: '10' + itemValue: penWidth: + translateLabel: true + argument: 10 + ) + ) + nil + nil + ) + ) ) nil nil @@ -2257,8 +2291,6 @@ nil nil ) - - "Modified: / 23-10-2006 / 23:16:47 / cg" ! menuMouseButtonColors @@ -4114,6 +4146,104 @@ "Modified: / 20-07-2007 / 09:18:59 / cg" ! +colorize + "interactive Hue editing" + + |bindings hueShift lightValue saturationValue originalColormap firstChange acceptChannel + shiftAction avgColorHolder avgColor shiftedColor shiftProcess readySema + originalPixels p| + + "/ compute the averageColor in the background (while asking user) + readySema := Semaphore new. + [ + |image| + + image := imageEditView image. + originalColormap := image colorMap copy. + avgColor := image averageColor. + originalPixels := image bits. + readySema signal. + ] forkAt:7. + + acceptChannel := TriggerValue new. + avgColorHolder := avgColor asValue. + + firstChange := true. + + shiftedColor := [:clr :hShift :lFactor :sFactor | + Color + hue:((clr hue) ? 0 + hShift) + light:((clr light * lFactor / 100) "min:100") + saturation:(((clr saturation max:20) * sFactor / 100) "min:100")]. + + + shiftAction := + [ + |hShift lFactor sFactor| + + acceptChannel value:true. + + firstChange ifTrue:[ + imageEditView makeUndo. + firstChange := false. + ]. + readySema notNil ifTrue:[readySema wait. readySema := nil]. + + hShift := hueShift value. + lFactor := lightValue value. + sFactor := saturationValue value. + + avgColorHolder value:(shiftedColor value:avgColor value:hShift value:lFactor value:sFactor). + + shiftProcess notNil ifTrue:[ + shiftProcess terminate. + shiftProcess waitUntilTerminated. + shiftProcess := nil. + ]. + shiftProcess := + [ + [ + imageEditView image + colorMap:originalColormap copy; + bits:originalPixels copy; + release; + colorMapProcessing:[:clr | shiftedColor value:clr value:hShift value:lFactor value:sFactor]. + self updateImage. + self updateInfoLabel. + self updateImagePreView. + ] ensure:[ shiftProcess := nil ]. + ] forkAt:7. + ]. + + bindings := IdentityDictionary new. + bindings at:#hueShiftAmount put:(hueShift := 0 asValue). + hueShift onChangeEvaluate:shiftAction. + + bindings at:#lightAmount put:(lightValue := 100 asValue). + lightValue onChangeEvaluate:shiftAction. + + bindings at:#saturationAmount put:(saturationValue := 100 asValue). + saturationValue onChangeEvaluate:shiftAction. + + bindings at:#acceptChannel put:acceptChannel. + bindings at:#hlsColor put:avgColorHolder. + + (self openDialogInterface:#changeHLSDialogSpec withBindings:bindings) + ifFalse:[ + firstChange ~~ true ifTrue:[ + imageEditView undo + ] + ]. + + (p := shiftProcess) notNil ifTrue:[ + p waitUntilTerminated. + ]. + self updateImage. + self updateImagePreView. + + "Created: / 01-11-2007 / 23:27:37 / cg" +! + compressColorMap "calculates a new color map for the image, using only used colors" @@ -5373,6 +5503,12 @@ imageEditView invalidate ] +! + +penWidth:n + imageEditView penWidth:n + + "Created: / 01-11-2007 / 23:47:48 / cg" ! ! !ImageEditor class methodsFor:'documentation'!