3267 |
3267 |
3268 changeHLS |
3268 changeHLS |
3269 "interactive Hue/Light/Saturation editing" |
3269 "interactive Hue/Light/Saturation editing" |
3270 |
3270 |
3271 |bindings hueShift lightValue saturationValue originalColormap firstChange acceptChannel |
3271 |bindings hueShift lightValue saturationValue originalColormap firstChange acceptChannel |
3272 shiftAction colorHolder avgColor shiftedColor| |
3272 shiftAction avgColorHolder avgColor shiftedColor shiftProcess readySema| |
3273 |
3273 |
3274 originalColormap := imageEditView image colorMap copy. |
3274 readySema := Semaphore new. |
3275 avgColor := imageEditView image averageColor. |
3275 [ |
|
3276 originalColormap := imageEditView image colorMap copy. |
|
3277 avgColor := imageEditView image averageColor. |
|
3278 readySema signal. |
|
3279 ] forkAt:7. |
3276 |
3280 |
3277 acceptChannel := TriggerValue new. |
3281 acceptChannel := TriggerValue new. |
|
3282 avgColorHolder := avgColor asValue. |
3278 |
3283 |
3279 firstChange := true. |
3284 firstChange := true. |
3280 |
3285 |
3281 shiftedColor := [:clr :hShift :lFactor :sFactor | |
3286 shiftedColor := [:clr :hShift :lFactor :sFactor | |
3282 Color |
3287 Color |
3283 hue:((clr hue) ? 0 + hShift) |
3288 hue:((clr hue) ? 0 + hShift) |
3284 light:((clr light * lFactor / 100) min:100) |
3289 light:((clr light * lFactor / 100) min:100) |
3285 saturation:((clr saturation * sFactor / 100) min:100)]. |
3290 saturation:((clr saturation * sFactor / 100) min:100)]. |
|
3291 |
3286 shiftAction := |
3292 shiftAction := |
3287 [ |
3293 [ |
3288 |hShift lFactor sFactor| |
3294 |hShift lFactor sFactor| |
3289 |
3295 |
3290 acceptChannel value:true. |
3296 acceptChannel value:true. |
3291 |
3297 |
3292 firstChange ifTrue:[ |
3298 firstChange ifTrue:[ |
3293 imageEditView makeUndo. |
3299 imageEditView makeUndo. |
3294 firstChange := false. |
3300 firstChange := false. |
3295 ]. |
3301 ]. |
|
3302 readySema notNil ifTrue:[readySema wait. readySema := nil]. |
3296 |
3303 |
3297 hShift := hueShift value. |
3304 hShift := hueShift value. |
3298 lFactor := lightValue value. |
3305 lFactor := lightValue value. |
3299 sFactor := saturationValue value. |
3306 sFactor := saturationValue value. |
3300 |
3307 |
3301 colorHolder value:(shiftedColor value:avgColor value:hShift value:lFactor value:sFactor). |
3308 avgColorHolder value:(shiftedColor value:avgColor value:hShift value:lFactor value:sFactor). |
3302 imageEditView image colorMap:originalColormap copy. |
3309 |
3303 imageEditView image colorMapProcessing:[:clr | shiftedColor value:clr value:hShift value:lFactor value:sFactor]. |
3310 shiftProcess notNil ifTrue:[ |
3304 self updateImage. |
3311 shiftProcess terminate. |
3305 self updateInfoLabel. |
3312 shiftProcess waitUntilTerminated. |
|
3313 shiftProcess := nil. |
|
3314 ]. |
|
3315 shiftProcess := |
|
3316 [ |
|
3317 [ |
|
3318 imageEditView image colorMap:originalColormap copy. |
|
3319 imageEditView image colorMapProcessing:[:clr | shiftedColor value:clr value:hShift value:lFactor value:sFactor]. |
|
3320 self updateImage. |
|
3321 self updateInfoLabel. |
|
3322 ] ensure:[ shiftProcess := nil ]. |
|
3323 ] forkAt:7. |
3306 ]. |
3324 ]. |
3307 |
3325 |
3308 bindings := IdentityDictionary new. |
3326 bindings := IdentityDictionary new. |
3309 bindings at:#hueShiftAmount put:(hueShift := 0 asValue). |
3327 bindings at:#hueShiftAmount put:(hueShift := 0 asValue). |
3310 (bindings at:#hueShiftAmount) onChangeEvaluate:shiftAction. |
3328 (bindings at:#hueShiftAmount) onChangeEvaluate:shiftAction. |
3314 |
3332 |
3315 bindings at:#saturationAmount put:(saturationValue := 100 asValue). |
3333 bindings at:#saturationAmount put:(saturationValue := 100 asValue). |
3316 (bindings at:#saturationAmount) onChangeEvaluate:shiftAction. |
3334 (bindings at:#saturationAmount) onChangeEvaluate:shiftAction. |
3317 |
3335 |
3318 bindings at:#acceptChannel put:acceptChannel. |
3336 bindings at:#acceptChannel put:acceptChannel. |
3319 bindings at:#hlsColor put:(colorHolder := avgColor asValue). |
3337 bindings at:#hlsColor put:avgColorHolder. |
3320 |
3338 |
3321 (self openDialogInterface:#changeHLSDialogSpec withBindings:bindings) |
3339 (self openDialogInterface:#changeHLSDialogSpec withBindings:bindings) |
3322 ifFalse:[ |
3340 ifFalse:[ |
3323 firstChange ~~ true ifTrue:[ |
3341 firstChange ~~ true ifTrue:[ |
3324 imageEditView undo |
3342 imageEditView undo |