Color.st
changeset 7798 8af654223c89
parent 7782 5c396aabbe58
child 7830 fa41edb7876a
child 9044 02110132774b
--- a/Color.st	Thu Jan 26 11:52:50 2017 +0100
+++ b/Color.st	Thu Jan 26 13:55:35 2017 +0100
@@ -3214,78 +3214,78 @@
 
     "get hls (since we dither anyway, round them a bit"
 
-    Color withHLSFromScaledRed:rV scaledGreen:gV scaledBlue:bV do:[:h :l :s |
-	h notNil ifTrue:[
-	    rh := (h * 3.0) rounded / 3.0.
-	].
-	rl := (l * 3.0) rounded / 3.0.
-	rs := (s * 3.0) rounded / 3.0.
+    Color withHLSFromScaledRed:rV scaledGreen:gV scaledBlue:bV do:[:hue :light :saturation |
+        hue notNil ifTrue:[
+            rh := (hue * 3.0) rounded / 3.0.
+        ].
+        rl := (light * 3.0) rounded / 3.0.
+        rs := (saturation * 3.0) rounded / 3.0.
     ].
 
     rh isNil ifTrue:[
-	"achromatic,  dither between achromatic colors"
-
-	lowL := nil.
-	hiL := nil.
-
-	"find the 2 bounding colors"
-	aDevice deviceColors do:[:aColor |
-	    aColor colorId notNil ifTrue:[
-
-		Color withHLSFromRed:aColor red green:aColor green blue:aColor blue do:[:h :l :s |
-		    | cl |
-
-		    h isNil ifTrue:[
-			cl := (l * 3.0) rounded / 3.0.
-
-			cl > rl ifTrue:[
-			    hiL isNil ifTrue:[
-				hiL := aColor.
-				hiValL := cl.
-			    ] ifFalse:[
-				cl < hiValL ifTrue:[
-				    hiL := aColor.
-				    hiValL := cl.
-				]
-			    ]
-			] ifFalse:[
-			    lowL isNil ifTrue:[
-				lowL := aColor.
-				lowValL := cl
-			    ] ifFalse:[
-				cl > lowValL ifTrue:[
-				    lowL := aColor.
-				    lowValL := cl
-				]
-			    ]
-			]
-		    ]
-		]
-	    ]
-	].
-
-	(lowL notNil and:[hiL notNil]) ifTrue:[
-	    ^ self
-		monoDitherFor:1.0 / (hiValL - lowValL) * (rl - lowValL)
-		between:lowL and:hiL
-		on:aDevice
-		into:aBlock
-	].
-	"cannot happen, should always find at least black and white"
-	'Color [info]: oops - color to dither is not bound by b&w' infoPrintCR.
-
-	^ aBlock value:nil value:nil
+        "achromatic,  dither between achromatic colors"
+
+        lowL := nil.
+        hiL := nil.
+
+        "find the 2 bounding colors"
+        aDevice deviceColors do:[:aColor |
+            aColor colorId notNil ifTrue:[
+
+                Color withHLSFromRed:aColor red green:aColor green blue:aColor blue do:[:hue :light :saturation |
+                    | cl |
+
+                    hue isNil ifTrue:[
+                        cl := (light * 3.0) rounded / 3.0.
+
+                        cl > rl ifTrue:[
+                            hiL isNil ifTrue:[
+                                hiL := aColor.
+                                hiValL := cl.
+                            ] ifFalse:[
+                                cl < hiValL ifTrue:[
+                                    hiL := aColor.
+                                    hiValL := cl.
+                                ]
+                            ]
+                        ] ifFalse:[
+                            lowL isNil ifTrue:[
+                                lowL := aColor.
+                                lowValL := cl
+                            ] ifFalse:[
+                                cl > lowValL ifTrue:[
+                                    lowL := aColor.
+                                    lowValL := cl
+                                ]
+                            ]
+                        ]
+                    ]
+                ]
+            ]
+        ].
+
+        (lowL notNil and:[hiL notNil]) ifTrue:[
+            ^ self
+                monoDitherFor:1.0 / (hiValL - lowValL) * (rl - lowValL)
+                between:lowL and:hiL
+                on:aDevice
+                into:aBlock
+        ].
+        "cannot happen, should always find at least black and white"
+        'Color [info]: oops - color to dither is not bound by b&w' infoPrintCR.
+
+        ^ aBlock value:nil value:nil
     ].
 
     "chromatic case"
 
     aDevice hasColors ifFalse:[
-	"no chance, return nil values"
-	^ aBlock value:nil value:nil
+        "no chance, return nil values"
+        ^ aBlock value:nil value:nil
     ].
     (Red isNil or:[Green isNil or:[Blue isNil]]) ifTrue:[
-	"if we where not able to get primary colors: no chance"
-	^ aBlock value:nil value:nil
+        "if we where not able to get primary colors: no chance"
+        ^ aBlock value:nil value:nil
     ].
 
     "try to find two bounding colors with same hue and saturation;
@@ -3299,139 +3299,139 @@
     hiH := nil.
 
     aDevice deviceColors do:[:aColor |
-	aColor colorId notNil ifTrue:[
-	    Color withHLSFromRed:aColor red green:aColor green blue:aColor blue do:[:h :l :s |
-		| cl ch cs|
-
-		h notNil ifTrue:[
-		   ch := (h * 3.0) rounded / 3.0.
-		] ifFalse:[
-		   ch := nil
-		].
-		cl := (l * 3.0) rounded / 3.0.
-		cs := (s * 3.0) rounded / 3.0.
-
-		((ch = rh) and:[cs = rs]) ifTrue:[
-		    "found a color with same saturation and same hue, keep for light"
-
-		    cl > rl ifTrue:[
-			hiL isNil ifTrue:[
-			    hiL := aColor.
-			    hiValL := cl
-			] ifFalse:[
-			    cl < hiValL ifTrue:[
-				hiL := aColor.
-				hiValL := cl
-			    ]
-			].
-		    ] ifFalse:[
-			lowL isNil ifTrue:[
-			    lowL := aColor.
-			    lowValL := cl
-			] ifFalse:[
-			    cl > lowValL ifTrue:[
-				lowL := aColor.
-				lowValL := cl
-			    ]
-			]
-		    ]
-		].
-
-		(((ch = rh) or:[ch == nil]) and:[cl = rl]) ifTrue:[
-		    "found a color with same light and same hue, keep for saturation"
-
-		    cs > rs ifTrue:[
-			hiS isNil ifTrue:[
-			    hiS := aColor.
-			    hiValS := cs
-			] ifFalse:[
-			    cs < hiValS ifTrue:[
-				hiS := aColor.
-				hiValS := cs
-			    ]
-			].
-		    ] ifFalse:[
-			lowS isNil ifTrue:[
-			    lowS := aColor.
-			    lowValS := cs
-			] ifFalse:[
-			    cs > lowValS ifTrue:[
-				lowS := aColor.
-				lowValS := cs
-			    ]
-			]
-		    ]
-		].
-
-		rh notNil ifTrue:[
-		    cl = rl ifTrue:[
-			cs = rs ifTrue:[
-			    ch notNil ifTrue:[
-				d := (ch - rh) abs.
-				d > 300 ifTrue:[
-				    rh > 180 ifTrue:[
-					ch := ch + 360
-				    ] ifFalse:[
-					ch := ch - 360
-				    ].
-				].
-				ch > rh ifTrue:[
-				    hiH isNil ifTrue:[
-					hiH := aColor.
-					hiValH := ch
-				    ] ifFalse:[
-					ch < hiValH ifTrue:[
-					    hiH := aColor.
-					    hiValH := ch
-					]
-				    ]
-				] ifFalse:[
-				    lowH isNil ifTrue:[
-					lowH := aColor.
-					lowValH := ch
-				    ] ifFalse:[
-					ch > lowValH ifTrue:[
-					    lowH := aColor.
-					    lowValH := ch
-					]
-				    ]
-				]
-			    ]
-			]
-		    ]
-		]
-	    ]
-	]
+        aColor colorId notNil ifTrue:[
+            Color withHLSFromRed:aColor red green:aColor green blue:aColor blue do:[:hue :light :saturation |
+                | cl ch cs|
+
+                hue notNil ifTrue:[
+                   ch := (hue * 3.0) rounded / 3.0.
+                ] ifFalse:[
+                   ch := nil
+                ].
+                cl := (light * 3.0) rounded / 3.0.
+                cs := (saturation * 3.0) rounded / 3.0.
+
+                ((ch = rh) and:[cs = rs]) ifTrue:[
+                    "found a color with same saturation and same hue, keep for light"
+
+                    cl > rl ifTrue:[
+                        hiL isNil ifTrue:[
+                            hiL := aColor.
+                            hiValL := cl
+                        ] ifFalse:[
+                            cl < hiValL ifTrue:[
+                                hiL := aColor.
+                                hiValL := cl
+                            ]
+                        ].
+                    ] ifFalse:[
+                        lowL isNil ifTrue:[
+                            lowL := aColor.
+                            lowValL := cl
+                        ] ifFalse:[
+                            cl > lowValL ifTrue:[
+                                lowL := aColor.
+                                lowValL := cl
+                            ]
+                        ]
+                    ]
+                ].
+
+                (((ch = rh) or:[ch isNil]) and:[cl = rl]) ifTrue:[
+                    "found a color with same light and same hue, keep for saturation"
+
+                    cs > rs ifTrue:[
+                        hiS isNil ifTrue:[
+                            hiS := aColor.
+                            hiValS := cs
+                        ] ifFalse:[
+                            cs < hiValS ifTrue:[
+                                hiS := aColor.
+                                hiValS := cs
+                            ]
+                        ].
+                    ] ifFalse:[
+                        lowS isNil ifTrue:[
+                            lowS := aColor.
+                            lowValS := cs
+                        ] ifFalse:[
+                            cs > lowValS ifTrue:[
+                                lowS := aColor.
+                                lowValS := cs
+                            ]
+                        ]
+                    ]
+                ].
+
+                rh notNil ifTrue:[
+                    cl = rl ifTrue:[
+                        cs = rs ifTrue:[
+                            ch notNil ifTrue:[
+                                d := (ch - rh) abs.
+                                d > 300 ifTrue:[
+                                    rh > 180 ifTrue:[
+                                        ch := ch + 360
+                                    ] ifFalse:[
+                                        ch := ch - 360
+                                    ].
+                                ].
+                                ch > rh ifTrue:[
+                                    hiH isNil ifTrue:[
+                                        hiH := aColor.
+                                        hiValH := ch
+                                    ] ifFalse:[
+                                        ch < hiValH ifTrue:[
+                                            hiH := aColor.
+                                            hiValH := ch
+                                        ]
+                                    ]
+                                ] ifFalse:[
+                                    lowH isNil ifTrue:[
+                                        lowH := aColor.
+                                        lowValH := ch
+                                    ] ifFalse:[
+                                        ch > lowValH ifTrue:[
+                                            lowH := aColor.
+                                            lowValH := ch
+                                        ]
+                                    ]
+                                ]
+                            ]
+                        ]
+                    ]
+                ]
+            ]
+        ]
     ].
 
     "found bounds for light ?"
 
     lowL notNil ifTrue:[
-	rl = lowValL ifTrue:[
-	    ^ aBlock value:lowL value:nil
-	].
-	hiL notNil ifTrue:[
-	    ^ self
-		monoDitherFor:1.0 / (hiValL - lowValL) / (rl - lowValL)
-		between:lowL and:hiL
-		on:aDevice
-		into:aBlock
-	].
-	"found bound for light - dither with white"
-	^ self
-	    monoDitherFor:1.0 / (100 - lowValL) / (rl - lowValL)
-	    between:lowL and:White
-	    on:aDevice
-	    into:aBlock
+        rl = lowValL ifTrue:[
+            ^ aBlock value:lowL value:nil
+        ].
+        hiL notNil ifTrue:[
+            ^ self
+                monoDitherFor:1.0 / (hiValL - lowValL) / (rl - lowValL)
+                between:lowL and:hiL
+                on:aDevice
+                into:aBlock
+        ].
+        "found bound for light - dither with white"
+        ^ self
+            monoDitherFor:1.0 / (100 - lowValL) / (rl - lowValL)
+            between:lowL and:White
+            on:aDevice
+            into:aBlock
     ].
 
     "found bound for light - dither with black"
     hiL notNil ifTrue:[
-	^ self
-	    monoDitherFor:1.0 / (hiValL) / (rl)
-	    between:Black and:hiL
-	    on:aDevice
-	    into:aBlock
+        ^ self
+            monoDitherFor:1.0 / (hiValL) / (rl)
+            between:Black and:hiL
+            on:aDevice
+            into:aBlock
     ].
 
 
@@ -3439,32 +3439,32 @@
 
     (lowS notNil and:[hiS notNil]) ifTrue:[
 "
-	'saturation dither' printNewline.
+        'saturation dither' printNewline.
 "
-	^ self
-	    monoDitherFor:1.0 / (hiValS - lowValS) / (rs - lowValS)
-	    between:lowS and:hiS
-	    on:aDevice
-	    into:aBlock
+        ^ self
+            monoDitherFor:1.0 / (hiValS - lowValS) / (rs - lowValS)
+            between:lowS and:hiS
+            on:aDevice
+            into:aBlock
     ].
 
     "found bounds for hue ?"
 
     (lowH notNil and:[hiH notNil]) ifTrue:[
 "
-	'hue dither' printNewline.
+        'hue dither' printNewline.
 "
-	hiValH < lowValH ifTrue:[
-	    hiValH := hiValH + 360
-	].
-
-	d := hiValH - lowValH.
-
-	^ self
-	    monoDitherFor:1.0 / (d / (rh - lowValH))
-	    between:lowH and:hiH
-	    on:aDevice
-	    into:aBlock
+        hiValH < lowValH ifTrue:[
+            hiValH := hiValH + 360
+        ].
+
+        d := hiValH - lowValH.
+
+        ^ self
+            monoDitherFor:1.0 / (d / (rh - lowValH))
+            between:lowH and:hiH
+            on:aDevice
+            into:aBlock
     ].
 
     ^ aBlock value:nil value:nil