class: Color expecco_2_4_0 expecco_2_4_1
authorStefan Vogel <sv@exept.de>
Tue, 11 Dec 2012 16:06:34 +0100
changeset 5965 4f8e9e2ec50b
parent 5964 7c901cc6c8ef
child 5966 30fb4bd577c7
class: Color added: #contrastingBlackOrWhite
Color.st
--- a/Color.st	Tue Nov 27 19:03:42 2012 +0100
+++ b/Color.st	Tue Dec 11 16:06:34 2012 +0100
@@ -5028,6 +5028,12 @@
     "Modified: 10.2.1997 / 22:08:14 / cg"
 !
 
+contrastingBlackOrWhite
+    "answer either black or white, whichever gives a better contrast"
+
+    ^ self brightness < 0.65 ifTrue:[self class white] ifFalse:[self class black]
+!
+
 darkened
     "return a new color, which is slightly darker than the receiver"
 
@@ -5550,11 +5556,11 @@
 !Color class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Color.st,v 1.223 2012-11-24 12:54:33 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Color.st,v 1.224 2012-12-11 15:06:34 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libview/Color.st,v 1.223 2012-11-24 12:54:33 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Color.st,v 1.224 2012-12-11 15:06:34 stefan Exp $'
 ! !
 
 Color initialize!