--- a/Color.st Sat Apr 19 18:10:04 1997 +0200
+++ b/Color.st Sun Apr 20 12:45:23 1997 +0200
@@ -308,16 +308,29 @@
for dithering (although, with only black, white, red, green and blue,
dithered images look very poor)."
- |colors white black red green blue|
+ |colors white black red green blue clr|
(aDevice notNil and:[aDevice ditherColors isNil]) ifTrue:[
white := (self red:100 green:100 blue:100) exactOn:aDevice.
+ white colorId isNil ifTrue:[
+ 'Color [warning]: cannot allocate white color' errorPrintCR.
+ ].
black := (self red:0 green:0 blue:0) exactOn:aDevice.
+ black colorId isNil ifTrue:[
+ 'Color [warning]: cannot allocate black color' errorPrintCR.
+ ].
aDevice hasColors ifTrue:[
red := (self red:100 green:0 blue:0) exactOn:aDevice.
green := (self red:0 green:100 blue:0) exactOn:aDevice.
blue := (self red:0 green:0 blue:100) exactOn:aDevice.
+ (red isNil or:[red colorId isNil
+ or:[green isNil or:[green colorId isNil
+ or:[blue isNil or:[blue colorId isNil]]]]]) ifTrue:[
+ 'Color [warning]: cannot allocate primary color' errorPrintCR.
+ aDevice hasColors:false.
+ red := green := blue := nil.
+ ]
].
aDevice == Display ifTrue:[
@@ -339,15 +352,16 @@
"
colors := OrderedCollection new.
- colors add:((self gray:50) exactOn:aDevice).
+ clr := (self gray:50) exactOn:aDevice.
+ (clr notNil and:[clr colorId notNil]) ifTrue:[
+ colors add:clr
+ ].
colors add:white; add:black; add:red; add:green; add:blue.
colors add:((self red:100 green:100 blue:0) exactOn:aDevice).
colors add:((self red:100 green:0 blue:100) exactOn:aDevice).
colors add:((self red:0 green:100 blue:100) exactOn:aDevice).
-
- colors := colors select:[:clr | clr notNil].
].
aDevice hasGreyscales ifTrue:[
@@ -361,12 +375,13 @@
colors add:((self gray:33) exactOn:aDevice).
colors add:((self gray:67) exactOn:aDevice).
colors add:((self gray:75) exactOn:aDevice).
-
- colors := colors select:[:clr | clr notNil].
].
colors notNil ifTrue:[
- aDevice setDitherColors:(colors asArray).
+ colors := colors select:[:clr | clr notNil and:[clr colorId notNil]].
+ colors size > 2 ifTrue:[
+ aDevice setDitherColors:(colors asArray).
+ ]
]
]
]
@@ -2172,6 +2187,8 @@
minDelta := 9999999.
+ colors isNil ifTrue:[^ nil].
+
colors do:[:aColor |
|cr cg cb|
@@ -3396,9 +3413,23 @@
"/ dither between those two colors
].
].
+
clr1 := clr1 exactOn:aDevice.
clr2 := clr2 exactOn:aDevice.
+ (clr1 isNil or:[clr2 isNil]) ifTrue:[
+ "/ fall back to b&w dither
+ aDevice blackpixel == 0 ifTrue:[
+ clr1 := Black.
+ clr2 := White.
+ newFraction := fraction.
+ ] ifFalse:[
+ clr1 := White.
+ clr2 := Black.
+ newFraction := 1 - fraction
+ ]
+ ].
+
^ self monoDitherFor:newFraction
between:clr1 and:clr2
on:aDevice into:aBlock
@@ -4058,6 +4089,6 @@
!Color class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/Color.st,v 1.94 1997-04-04 13:45:13 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/Color.st,v 1.95 1997-04-20 10:45:23 cg Exp $'
! !
Color initialize!