changed: #fillRectangleX:y:width:height:in:
authorClaus Gittinger <cg@exept.de>
Wed, 23 Mar 2011 18:41:13 +0100
changeset 5731 e638acae4e19
parent 5730 74d4e149580b
child 5732 fba4327a852b
changed: #fillRectangleX:y:width:height:in:
GradientBackground.st
--- a/GradientBackground.st	Wed Mar 23 17:39:25 2011 +0100
+++ b/GradientBackground.st	Wed Mar 23 18:41:13 2011 +0100
@@ -147,7 +147,8 @@
     "this is a first (very inefficient) try"
 
     |hAll wAll r1 r2 g1 g2 b1 b2 dR r dG g dB b 
-     xRight yBot rC gC bC lastR lastG lastB|
+     xRight yBot rC gC bC lastR lastG lastB 
+     minR maxR minG maxG minB maxB|
 
     "/ always take the full-screen as reference
     "/ (so we do not have to care for changed gradient, when view changes size)
@@ -161,6 +162,13 @@
     b1 := color1 blueByte.
     b2 := color2 blueByte.
 
+    minR := r1 min:r2.
+    maxR := r1 max:r2.
+    minG := g1 min:g2.
+    maxG := g1 max:g2.
+    minB := b1 min:b2.
+    maxB := b1 max:b2.
+
     aView lineStyle:#solid.
 
     "/ individual lines; from top to bottom
@@ -173,7 +181,7 @@
         b := b1 + (dB * y).
 
         xRight := x+w-1.
-        0 to:hAll-1 do:[:yP |
+        y to:y+h-1 do:[:yP |
             rC := r asInteger.
             gC := g asInteger.
             bC := b asInteger.
@@ -182,12 +190,11 @@
                 lastR := rC. lastG := gC. lastB := bC.
             ].
             "xRight+1 since X11 does not show the last point of a line"
-            aView displayLineFromX:x y:y+yP toX:xRight+1 y:y+yP.
-            r := (r + dR) "min:r2". "used to do min:r2 here, but this does not work if r2 < r1 and dR is negative"
-            g := (g + dG) "min:g2".
-            b := (b + dB) "min:b2".
+            aView displayLineFromX:x y:yP toX:xRight+1 y:yP.
+            r := ((r + dR) max:minR) min:maxR. 
+            g := ((g + dG) max:minG) min:maxG.
+            b := ((b + dB) max:minB) min:maxB.
         ].
-        aView fillRectangleX:x y:hAll-1 width:w height:(h-hAll+1).
         ^ self.
     ].
 
@@ -201,7 +208,7 @@
         b := b1 + (dB * y).
 
         yBot := y+h-1.
-        0 to:wAll-1 do:[:xP |
+        x to:x+w-1 do:[:xP |
             rC := r asInteger.
             gC := g asInteger.
             bC := b asInteger.
@@ -210,21 +217,20 @@
                 lastR := rC. lastG := gC. lastB := bC.
             ].
             "yBot+1 since X11 does not show the last point of a line"
-            aView displayLineFromX:x+xP y:y toX:x+xP y:yBot+1.
-            r := (r + dR) "min:r2".
-            g := (g + dG) "min:g2".
-            b := (b + dB) "min:b2".
+            aView displayLineFromX:xP y:y toX:xP y:yBot+1.
+            r := ((r + dR) max:minR) min:maxR. 
+            g := ((g + dG) max:minG) min:maxG.
+            b := ((b + dB) max:minB) min:maxB.
         ].
-        aView fillRectangleX:wAll y:y width:(w-wAll+1) height:h.
         ^ self.
     ]
 
     "Created: / 23-01-2011 / 01:59:29 / cg"
-    "Modified: / 23-03-2011 / 17:39:05 / cg"
+    "Modified: / 23-03-2011 / 18:41:05 / cg"
 ! !
 
 !GradientBackground class methodsFor:'documentation'!
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libview/GradientBackground.st,v 1.8 2011-03-23 16:39:25 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/GradientBackground.st,v 1.9 2011-03-23 17:41:13 cg Exp $'
 ! !