GradientBackground.st
changeset 5739 c4fbd37a6164
parent 5738 b69308a38fb6
child 6013 aee5be18d9a1
--- a/GradientBackground.st	Wed Apr 06 21:11:14 2011 +0200
+++ b/GradientBackground.st	Wed Apr 06 21:18:38 2011 +0200
@@ -154,15 +154,24 @@
 fillRectangleX:x y:y width:w height:h in:aView
     "this is a first (very inefficient) try"
 
-    |hAll wAll r1 r2 g1 g2 b1 b2 dR r dG g dB b 
+    |hAll wAll r1 r2 g1 g2 b1 b2 dR r dG g dB b scaleStartX scaleStartY
      yRect hRun xRect wRun 
      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)
-    hAll := usedLength ? (Display height). "/ aView height.
-    wAll := usedLength ? (Display width).  "/ aView width.
+    usedLength notNil ifTrue:[
+        hAll := usedLength.
+        wAll := usedLength.
+        scaleStartX := 0.
+        scaleStartY := 0.
+    ] ifFalse:[
+        hAll := Display height. "/ aView height.
+        wAll := Display width.  "/ aView width.
+        scaleStartX := x.
+        scaleStartY := y.
+    ].
 
     r1 := color1 redByte.
     r2 := color2 redByte.
@@ -183,11 +192,11 @@
     "/ individual lines; from top to bottom
     (direction == #northSouth or:[direction == #vertical or:[direction == nil]]) ifTrue:[
         dR := (r2 - r1) / hAll.
-        r := r1 + (dR * y).
+        r := r1 + (dR * scaleStartY).
         dG := (g2 - g1) / hAll.
-        g := g1 + (dG * y).
+        g := g1 + (dG * scaleStartY).
         dB := (b2 - b1) / hAll.
-        b := b1 + (dB * y).
+        b := b1 + (dB * scaleStartY).
 
         r := (r max:minR) min:maxR. 
         g := (g max:minG) min:maxG.
@@ -222,11 +231,11 @@
     "/ individual lines; from left to right
     (direction == #eastWest or:[direction == #horizontal]) ifTrue:[
         dR := (r2 - r1) / wAll.
-        r := r1 + (dR * x).
+        r := r1 + (dR * scaleStartX).
         dG := (g2 - g1) / wAll.
-        g := g1 + (dG * x).
+        g := g1 + (dG * scaleStartX).
         dB := (b2 - b1) / wAll.
-        b := b1 + (dB * x).
+        b := b1 + (dB * scaleStartX).
 
         r := (r max:minR) min:maxR. 
         g := (g max:minG) min:maxG.
@@ -260,11 +269,11 @@
     ]
 
     "Created: / 23-01-2011 / 01:59:29 / cg"
-    "Modified: / 24-03-2011 / 09:59:20 / cg"
+    "Modified: / 06-04-2011 / 21:18:07 / cg"
 ! !
 
 !GradientBackground class methodsFor:'documentation'!
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libview/GradientBackground.st,v 1.12 2011-04-06 19:11:14 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/GradientBackground.st,v 1.13 2011-04-06 19:18:38 cg Exp $'
 ! !