author | Claus Gittinger <cg@exept.de> |
Sun, 23 Jan 2011 12:53:48 +0100 | |
changeset 5687 | d4ab14b6cf0a |
parent 5684 | c6029a2cf7c0 |
child 5688 | 0fec2a60ad63 |
permissions | -rw-r--r-- |
5461 | 1 |
" |
2 |
COPYRIGHT (c) 2009 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
"{ Package: 'stx:libview' }" |
|
13 |
||
14 |
AbstractBackground subclass:#GradientBackground |
|
15 |
instanceVariableNames:'color1 color2 direction' |
|
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Graphics-Support' |
|
19 |
! |
|
20 |
||
21 |
!GradientBackground class methodsFor:'documentation'! |
|
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 2009 by eXept Software AG |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! ! |
|
36 |
||
5684 | 37 |
!GradientBackground methodsFor:'accessing'! |
38 |
||
39 |
color1 |
|
40 |
^ color1 |
|
41 |
||
42 |
"Created: / 23-01-2011 / 02:01:29 / cg" |
|
43 |
! |
|
44 |
||
45 |
color1:aColor |
|
46 |
color1 := aColor. |
|
47 |
||
48 |
"Created: / 23-01-2011 / 02:01:50 / cg" |
|
49 |
! |
|
50 |
||
51 |
color2 |
|
52 |
^ color2 |
|
53 |
||
54 |
"Created: / 23-01-2011 / 02:01:32 / cg" |
|
55 |
! |
|
56 |
||
57 |
color2:aColor |
|
58 |
color2 := aColor. |
|
59 |
||
60 |
"Created: / 23-01-2011 / 02:01:55 / cg" |
|
61 |
! ! |
|
62 |
||
63 |
!GradientBackground methodsFor:'drawing'! |
|
64 |
||
65 |
fillRectangleX:x y:y width:w height:h in:aView |
|
66 |
"this is a first (very inefficient) try" |
|
67 |
||
5687
d4ab14b6cf0a
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5684
diff
changeset
|
68 |
|hAll r1 r2 g1 g2 b1 b2 dR r dG g dB b xRight rC gC bC lastR lastG lastB| |
d4ab14b6cf0a
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5684
diff
changeset
|
69 |
|
d4ab14b6cf0a
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5684
diff
changeset
|
70 |
hAll := 1000. "/ aView height. |
5684 | 71 |
|
72 |
r1 := color1 redByte. |
|
73 |
r2 := color2 redByte. |
|
74 |
g1 := color1 greenByte. |
|
75 |
g2 := color2 greenByte. |
|
76 |
b1 := color1 blueByte. |
|
77 |
b2 := color2 blueByte. |
|
78 |
||
79 |
direction = #horizontal ifTrue:[ |
|
80 |
self halt |
|
81 |
] ifFalse:[ |
|
5687
d4ab14b6cf0a
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5684
diff
changeset
|
82 |
dR := (r2 - r1) / hAll. |
5684 | 83 |
r := r1 + (dR * y). |
5687
d4ab14b6cf0a
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5684
diff
changeset
|
84 |
dG := (g2 - g1) / hAll. |
5684 | 85 |
g := g1 + (dG * y). |
5687
d4ab14b6cf0a
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5684
diff
changeset
|
86 |
dB := (b2 - b1) / hAll. |
5684 | 87 |
b := b1 + (dB * y). |
88 |
||
89 |
xRight := x+w-1. |
|
90 |
0 to:h-1 do:[:yP | |
|
91 |
rC := r asInteger. |
|
92 |
gC := g asInteger. |
|
93 |
bC := b asInteger. |
|
94 |
(rC ~~ lastR or:[gC ~~ lastG or:[bC ~~ lastB]]) ifTrue:[ |
|
95 |
aView foreground:(Color redByte:rC greenByte:gC blueByte:bC). |
|
96 |
lastR := rC. lastG := gC. lastB := bC. |
|
97 |
]. |
|
98 |
aView displayLineFromX:x y:y+yP toX:xRight y:y+yP. |
|
99 |
r := r + dR. |
|
100 |
g := g + dG. |
|
101 |
b := b + dB. |
|
102 |
]. |
|
103 |
] |
|
104 |
||
105 |
"Created: / 23-01-2011 / 01:59:29 / cg" |
|
5687
d4ab14b6cf0a
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5684
diff
changeset
|
106 |
"Modified: / 23-01-2011 / 12:53:36 / cg" |
5684 | 107 |
! ! |
108 |
||
5461 | 109 |
!GradientBackground class methodsFor:'documentation'! |
110 |
||
111 |
version_CVS |
|
5687
d4ab14b6cf0a
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5684
diff
changeset
|
112 |
^ '$Header: /cvs/stx/stx/libview/GradientBackground.st,v 1.3 2011-01-23 11:53:48 cg Exp $' |
5461 | 113 |
! ! |