changed: #fillRectangleX:y:width:height:in:
authorClaus Gittinger <cg@exept.de>
Thu, 24 Mar 2011 09:59:57 +0100
changeset 5733 08e2b386abef
parent 5732 fba4327a852b
child 5734 232e20790a17
changed: #fillRectangleX:y:width:height:in: start-color fix; tuned by drawing rectangles.
GradientBackground.st
--- a/GradientBackground.st	Thu Mar 24 09:51:49 2011 +0100
+++ b/GradientBackground.st	Thu Mar 24 09:59:57 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 
+     yRect hRun xRect wRun 
+     rC gC bC lastR lastG lastB 
      minR maxR minG maxG minB maxB|
 
     "/ always take the full-screen as reference
@@ -179,27 +180,34 @@
         g := g1 + (dG * y).
         dB := (b2 - b1) / hAll.
         b := b1 + (dB * y).
+
         r := (r max:minR) min:maxR. 
         g := (g max:minG) min:maxG.
         b := (b max:minB) min:maxB.
 
-        xRight := x+w-1.
-        "xRight+1 since X11 does not show the last point of a line"
-        xRight := xRight+1.
+        lastR := r asInteger. lastG := g asInteger. lastB := b asInteger.
 
+        yRect := y.
+        hRun := 0.
         y to:y+h-1 do:[:yP |
             rC := r asInteger.
             gC := g asInteger.
             bC := b asInteger.
             (rC ~~ lastR or:[gC ~~ lastG or:[bC ~~ lastB]]) ifTrue:[
-                aView paint:(Color redByte:rC greenByte:gC blueByte:bC).
+                aView paint:(Color redByte:lastR greenByte:lastG blueByte:lastB).
+                aView fillRectangleX:x y:yRect width:w height:hRun.
+                yRect := yP. hRun := 0.
                 lastR := rC. lastG := gC. lastB := bC.
             ].
-            aView displayLineFromX:x y:yP toX:xRight y:yP.
+            hRun := hRun + 1.
             r := ((r + dR) max:minR) min:maxR. 
             g := ((g + dG) max:minG) min:maxG.
             b := ((b + dB) max:minB) min:maxB.
         ].
+        hRun ~~ 0 ifTrue:[
+            aView paint:(Color redByte:lastR greenByte:lastG blueByte:lastB).
+            aView fillRectangleX:x y:yRect width:w height:hRun.
+        ].
         ^ self.
     ].
 
@@ -211,36 +219,44 @@
         g := g1 + (dG * x).
         dB := (b2 - b1) / wAll.
         b := b1 + (dB * x).
+
         r := (r max:minR) min:maxR. 
         g := (g max:minG) min:maxG.
         b := (b max:minB) min:maxB.
 
-        yBot := y+h-1.
-        "yBot+1 since X11 does not show the last point of a line"
-        yBot := yBot+1.
+        lastR := r asInteger. lastG := g asInteger. lastB := b asInteger.
+
+        xRect := x.
+        wRun := 0.
+
         x to:x+w-1 do:[:xP |
             rC := r asInteger.
             gC := g asInteger.
             bC := b asInteger.
             (rC ~~ lastR or:[gC ~~ lastG or:[bC ~~ lastB]]) ifTrue:[
-                aView paint:(Color redByte:rC greenByte:gC blueByte:bC).
+                aView paint:(Color redByte:lastR greenByte:lastG blueByte:lastB).
+                aView fillRectangleX:xRect y:y width:wRun height:h.
+                xRect := xP. wRun := 0.
                 lastR := rC. lastG := gC. lastB := bC.
             ].
-            "yBot+1 since X11 does not show the last point of a line"
-            aView displayLineFromX:xP y:y toX:xP y:yBot.
+            wRun := wRun + 1.
             r := ((r + dR) max:minR) min:maxR. 
             g := ((g + dG) max:minG) min:maxG.
             b := ((b + dB) max:minB) min:maxB.
         ].
+        wRun ~~ 0 ifTrue:[
+            aView paint:(Color redByte:lastR greenByte:lastG blueByte:lastB).
+            aView fillRectangleX:xRect y:y width:wRun height:h.
+        ].
         ^ self.
     ]
 
     "Created: / 23-01-2011 / 01:59:29 / cg"
-    "Modified: / 24-03-2011 / 09:51:31 / cg"
+    "Modified: / 24-03-2011 / 09:59:20 / cg"
 ! !
 
 !GradientBackground class methodsFor:'documentation'!
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libview/GradientBackground.st,v 1.10 2011-03-24 08:51:49 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/GradientBackground.st,v 1.11 2011-03-24 08:59:57 cg Exp $'
 ! !