bugs fixed in undo/mask and pasting
authortz
Tue, 21 Jul 1998 13:27:34 +0200
changeset 898 d2ae6ce33fec
parent 897 43f9bdc12ae4
child 899 43b744c647ba
bugs fixed in undo/mask and pasting
ImageEditor.st
--- a/ImageEditor.st	Mon Jul 20 18:15:07 1998 +0200
+++ b/ImageEditor.st	Tue Jul 21 13:27:34 1998 +0200
@@ -109,6 +109,7 @@
     "returns the list of default color maps for a new image"
 
     |colorMap|
+
     (colorMap := OrderedCollection new)
         add: Color black;
         add: Color white;
@@ -118,28 +119,29 @@
         add: Color cyan;
         add: Color yellow;
         add: Color magenta;
-        add: (Color red: 50 green: 0 blue: 0);
-        add: (Color red: 0 green: 50 blue: 0);
-        add: (Color red: 0 green: 0 blue: 50);
-        add: (Color red: 0 green: 50 blue: 50);
-        add: (Color red: 50 green: 50 blue: 0);
-        add: (Color red: 50 green: 0 blue: 50);
-        add: Color gray;
-        add: Color lightGray.                                
+        add: (Color redByte: 127 greenByte:   0 blueByte:   0);
+        add: (Color redByte:   0 greenByte: 127 blueByte:   0);
+        add: (Color redByte:   0 greenByte:   0 blueByte: 127);
+        add: (Color redByte:   0 greenByte: 127 blueByte: 127);
+        add: (Color redByte: 127 greenByte: 127 blueByte:   0);
+        add: (Color redByte: 127 greenByte:   0 blueByte: 127);
+        add: (Color redByte: 127 greenByte: 127 blueByte: 127);
+        add: (Color redByte: 170 greenByte: 170 blueByte: 170).
+
     0 to: 5 do:
     [:r|                                                    
         0 to: 5 do:         
         [:g|
             0 to: 5 do:                             
             [:b|
-                colorMap add: (Color red: (r*100//5) ceiling green: (g*100//5) ceiling blue: (b*100//5) ceiling)
+                colorMap add: (Color redByte: (r*255//5) ceiling greenByte: (g*255//5) ceiling blueByte: (b*255//5) ceiling)
             ]
         ]
     ].
 
     1 to: 25 do:
     [:g|                             
-        colorMap add: (Color gray: (g*100//26) ceiling)
+        colorMap add: (Color redByte: (g*255//26) ceiling greenByte: (g*255//26) ceiling blueByte: (g*255//26) ceiling)
     ].
 
     ^Dictionary new
@@ -1120,12 +1122,17 @@
          self colorMapMode: colorMapMode value: nil
     ].                               
     self imageEditView selectColors: (Array with: (self listOfColors at: 1) with: (self listOfColors at: 2 ifAbsent: [self listOfColors at: 1])).
-    (self image mask notNil and: [(self listOfColors includes: (Color basicNew setColorId:0)) not])
+
+    self image mask notNil
     ifTrue:
     [         
         colorMapMode := colorMapMode, ' + mask'.
-        self listOfColors addFirst: (Color basicNew setColorId:0).
-        self imageEditView selectColors: (Array with: (self listOfColors at: 2 ifAbsent: [self listOfColors at: 1]) with: (self listOfColors at: 1)).
+        (self listOfColors detect: [:clr| clr = (Color basicNew setColorId:0)] ifNone: nil) isNil
+        ifTrue:
+        [
+            self listOfColors addFirst: (Color basicNew setColorId:0).
+            self imageEditView selectColors: (Array with: (self listOfColors at: 2 ifAbsent: [self listOfColors at: 1]) with: (self listOfColors at: 1)).
+        ]
     ].
     self selectionOfColor value: 0.
     self selectionOfColor value: (self listOfColors indexOf: self imageEditView selectedColor).