ImageEditor.st
changeset 1651 577ddbd9fb26
parent 1650 cb63d6bf76c1
child 1652 d6d40619e21a
--- a/ImageEditor.st	Mon Nov 04 21:34:41 2002 +0100
+++ b/ImageEditor.st	Mon Nov 04 21:57:39 2002 +0100
@@ -666,8 +666,8 @@
         #name: #changeHLSDialogSpec
         #window: 
        #(#WindowSpec
-          #label: 'Shift Hue'
-          #name: 'Shift Hue'
+          #label: 'HLS Edit Dialog'
+          #name: 'HLS Edit Dialog'
           #min: #(#Point 10 10)
           #max: #(#Point 800 478)
           #bounds: #(#Rectangle 16 46 328 229)
@@ -678,13 +678,13 @@
            #(#LabelSpec
               #label: 'Hue-Shift:'
               #name: 'HueLabel'
-              #layout: #(#LayoutFrame 14 0 21 0 90 0 43 0)
+              #layout: #(#LayoutFrame 20 0 21 0 120 0 43 0)
               #translateLabel: true
               #adjust: #right
             )
            #(#InputFieldSpec
               #name: 'HueShiftEntryField'
-              #layout: #(#LayoutFrame 95 0 21 0 138 0 43 0)
+              #layout: #(#LayoutFrame 123 0 21 0 166 0 43 0)
               #tabable: true
               #model: #hueShiftAmount
               #type: #numberInRange
@@ -695,22 +695,22 @@
             )
            #(#ThumbWheelSpec
               #name: 'HueWheel'
-              #layout: #(#LayoutFrame 152 0 22 0 269 0 42 0)
+              #layout: #(#LayoutFrame 180 0 22 0 297 0 42 0)
               #model: #hueShiftAmount
               #orientation: #horizontal
               #step: 1
               #endlessRotation: true
             )
            #(#LabelSpec
-              #label: 'Light:'
+              #label: 'Light Factor:'
               #name: 'LightLabel'
-              #layout: #(#LayoutFrame 14 0 50 0 90 0 72 0)
+              #layout: #(#LayoutFrame 18 0 50 0 120 0 72 0)
               #translateLabel: true
               #adjust: #right
             )
            #(#InputFieldSpec
               #name: 'LightEntryField'
-              #layout: #(#LayoutFrame 95 0 50 0 138 0 72 0)
+              #layout: #(#LayoutFrame 123 0 50 0 166 0 72 0)
               #tabable: true
               #model: #lightAmount
               #type: #numberInRange
@@ -721,22 +721,22 @@
             )
            #(#ThumbWheelSpec
               #name: 'LightWheel'
-              #layout: #(#LayoutFrame 152 0 51 0 269 0 71 0)
+              #layout: #(#LayoutFrame 180 0 51 0 297 0 71 0)
               #model: #lightAmount
               #orientation: #horizontal
               #stop: 1000
               #step: 1
             )
            #(#LabelSpec
-              #label: 'Saturation:'
+              #label: 'Saturation Factor:'
               #name: 'SaturationLabel'
-              #layout: #(#LayoutFrame 14 0 79 0 90 0 101 0)
+              #layout: #(#LayoutFrame 9 0 79 0 120 0 101 0)
               #translateLabel: true
               #adjust: #right
             )
            #(#InputFieldSpec
               #name: 'SaturationEntryField'
-              #layout: #(#LayoutFrame 95 0 79 0 138 0 101 0)
+              #layout: #(#LayoutFrame 123 0 79 0 166 0 101 0)
               #tabable: true
               #model: #saturationAmount
               #type: #numberInRange
@@ -747,7 +747,7 @@
             )
            #(#ThumbWheelSpec
               #name: 'SaturationWheel'
-              #layout: #(#LayoutFrame 152 0 80 0 269 0 100 0)
+              #layout: #(#LayoutFrame 180 0 80 0 297 0 100 0)
               #model: #saturationAmount
               #orientation: #horizontal
               #stop: 1000
@@ -757,7 +757,7 @@
               #name: 'HueColorLabel'
               #layout: #(#LayoutFrame 10 0.0 109 0 -10 1.0 148 0)
               #translateLabel: true
-              #backgroundChannel: #hueColor
+              #backgroundChannel: #hlsColor
             )
            #(#HorizontalPanelViewSpec
               #name: 'HorizontalPanel1'
@@ -3269,14 +3269,20 @@
     "interactive Hue/Light/Saturation editing"
 
     |bindings hueShift lightValue saturationValue originalColormap firstChange acceptChannel 
-     shiftAction colorHolder|
+     shiftAction colorHolder avgColor shiftedColor|
 
     originalColormap := imageEditView image colorMap copy.
+    avgColor := imageEditView image averageColor.
 
     acceptChannel := TriggerValue new.
 
     firstChange := true.
 
+    shiftedColor := [:clr :hShift :lFactor :sFactor |
+                        Color 
+                                hue:((clr hue) ? 0 + hShift) 
+                                light:((clr light * lFactor / 100) min:100)
+                                saturation:((clr saturation * sFactor / 100) min:100)].
     shiftAction := 
         [
             |hShift lFactor sFactor|
@@ -3292,12 +3298,9 @@
             lFactor := lightValue value.
             sFactor := saturationValue value.
 
-            colorHolder value:(Color hue:hShift light:(lFactor min:100) saturation:(sFactor min:100)).
+            colorHolder value:(shiftedColor value:avgColor value:hShift value:lFactor value:sFactor).
             imageEditView image colorMap:originalColormap copy.
-            imageEditView image colorMapProcessing:[:clr | Color 
-                                                                hue:((clr hue) ? 0 + hShift) 
-                                                                light:((clr light * lFactor / 100) min:100)
-                                                                saturation:((clr saturation * sFactor / 100) min:100)].
+            imageEditView image colorMapProcessing:[:clr | shiftedColor value:clr value:hShift value:lFactor value:sFactor].
             self updateImage.
             self updateInfoLabel.
         ].
@@ -3313,7 +3316,7 @@
     (bindings at:#saturationAmount) onChangeEvaluate:shiftAction.
 
     bindings at:#acceptChannel put:acceptChannel.
-    bindings at:#hueColor put:(colorHolder := Color white asValue).
+    bindings at:#hlsColor put:(colorHolder := avgColor asValue).
 
     (self openDialogInterface:#changeHLSDialogSpec withBindings:bindings) 
     ifFalse:[