author | Claus Gittinger <cg@exept.de> |
Sat, 14 Feb 2015 22:30:18 +0100 | |
changeset 6769 | 5421316e7200 |
parent 6202 | 020ebdb99a1e |
child 6953 | eac8b255a9e1 |
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 |
||
6769 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
5461 | 16 |
AbstractBackground subclass:#GradientBackground |
5705
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
17 |
instanceVariableNames:'color1 color2 direction cachedForm usedLength' |
5461 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20 |
category:'Graphics-Support' |
|
21 |
! |
|
22 |
||
23 |
!GradientBackground class methodsFor:'documentation'! |
|
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 2009 by eXept Software AG |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
5705
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
37 |
! |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
38 |
|
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
39 |
examples |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
40 |
" |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
41 |
|bg v| |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
42 |
|
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
43 |
bg := GradientBackground new color1:Color red color2:Color yellow. |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
44 |
v := View new extent:300@300. |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
45 |
v viewBackground:bg. |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
46 |
v open. |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
47 |
" |
5461 | 48 |
! ! |
49 |
||
6013 | 50 |
!GradientBackground class methodsFor:'instance creation'! |
51 |
||
52 |
horizontal:color1 to:color2 |
|
53 |
^ self new |
|
54 |
direction:#eastWest; |
|
55 |
color1:color1 color2:color2 |
|
56 |
||
57 |
" |
|
58 |
|bg v| |
|
59 |
||
60 |
bg := GradientBackground horizontal:Color red to:Color yellow. |
|
61 |
v := View new extent:300@300. |
|
62 |
v viewBackground:bg. |
|
63 |
v open. |
|
64 |
" |
|
6014 | 65 |
" |
66 |
|bg v| |
|
67 |
||
68 |
bg := GradientBackground horizontal:Color red to:Color yellow. |
|
69 |
v := View new extent:300@300. |
|
70 |
v viewBackground:bg. |
|
71 |
v open. |
|
72 |
" |
|
6013 | 73 |
! |
74 |
||
75 |
vertical:color1 to:color2 |
|
76 |
^ self new |
|
77 |
direction:#northSouth; |
|
78 |
color1:color1 color2:color2 |
|
79 |
||
80 |
" |
|
81 |
|bg v| |
|
82 |
||
83 |
bg := GradientBackground vertical:Color red to:Color yellow. |
|
84 |
v := View new extent:300@300. |
|
85 |
v viewBackground:bg. |
|
86 |
v open. |
|
87 |
" |
|
88 |
! ! |
|
89 |
||
6769 | 90 |
!GradientBackground class methodsFor:'queries'! |
91 |
||
92 |
possibleDirections |
|
93 |
^ #(#'northSouth' #'eastWest' ) |
|
94 |
! ! |
|
95 |
||
5684 | 96 |
!GradientBackground methodsFor:'accessing'! |
97 |
||
98 |
color1 |
|
99 |
^ color1 |
|
100 |
||
101 |
"Created: / 23-01-2011 / 02:01:29 / cg" |
|
102 |
! |
|
103 |
||
104 |
color1:aColor |
|
105 |
color1 := aColor. |
|
5705
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
106 |
cachedForm := nil. |
5684 | 107 |
|
108 |
"Created: / 23-01-2011 / 02:01:50 / cg" |
|
5705
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
109 |
"Modified: / 03-02-2011 / 19:49:18 / cg" |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
110 |
! |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
111 |
|
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
112 |
color1:aColor1 color2:aColor2 |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
113 |
color1 := aColor1. |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
114 |
color2 := aColor2. |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
115 |
cachedForm := nil. |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
116 |
|
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
117 |
"Created: / 03-02-2011 / 19:52:59 / cg" |
5684 | 118 |
! |
119 |
||
120 |
color2 |
|
121 |
^ color2 |
|
122 |
||
123 |
"Created: / 23-01-2011 / 02:01:32 / cg" |
|
124 |
! |
|
125 |
||
126 |
color2:aColor |
|
127 |
color2 := aColor. |
|
5705
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
128 |
cachedForm := nil. |
5684 | 129 |
|
130 |
"Created: / 23-01-2011 / 02:01:55 / cg" |
|
5705
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
131 |
"Modified: / 03-02-2011 / 19:49:23 / cg" |
5688 | 132 |
! |
133 |
||
134 |
direction |
|
135 |
"possible values: |
|
136 |
#northSouth |
|
137 |
#eastWest |
|
138 |
||
139 |
others are not yet supported |
|
140 |
" |
|
141 |
||
142 |
^ direction |
|
143 |
||
144 |
"Modified: / 23-01-2011 / 14:36:36 / cg" |
|
145 |
! |
|
146 |
||
147 |
direction:something |
|
148 |
"possible values: |
|
149 |
#northSouth |
|
150 |
#eastWest |
|
151 |
||
152 |
others are not yet supported |
|
153 |
" |
|
154 |
||
5705
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
155 |
direction ~= something ifTrue:[ |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
156 |
direction := something. |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
157 |
cachedForm := nil. |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
158 |
] |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
159 |
|
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
160 |
"Modified: / 03-02-2011 / 19:49:41 / cg" |
5738 | 161 |
! |
162 |
||
163 |
usedLength |
|
164 |
^ usedLength |
|
165 |
! |
|
166 |
||
167 |
usedLength:something |
|
168 |
usedLength := something. |
|
5705
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
169 |
! ! |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
170 |
|
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
171 |
!GradientBackground methodsFor:'converting'! |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
172 |
|
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
173 |
asFormOn:aDevice |
6014 | 174 |
|h w len| |
175 |
||
6102 | 176 |
usedLength == #full ifTrue:[ |
177 |
self halt:'unsupported'. |
|
178 |
^ nil |
|
179 |
]. |
|
5688 | 180 |
|
5705
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
181 |
cachedForm isNil ifTrue:[ |
6014 | 182 |
(len := usedLength) == #full ifTrue:[ |
183 |
len := nil |
|
184 |
]. |
|
5705
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
185 |
(direction == #northSouth or:[direction == nil]) ifTrue:[ |
6202
020ebdb99a1e
Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents:
6102
diff
changeset
|
186 |
h := len ? (aDevice height). "/ aView height. |
5705
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
187 |
w := 8. |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
188 |
] ifFalse:[ |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
189 |
h := 8. |
6202
020ebdb99a1e
Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents:
6102
diff
changeset
|
190 |
w := len ? (aDevice width). "/ aView width. |
5705
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
191 |
]. |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
192 |
cachedForm := Form width:w height:h depth:aDevice depth onDevice:aDevice. |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
193 |
"/ cachedForm clear. |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
194 |
self fillRectangleX:0 y:0 width:w height:h in:cachedForm |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
195 |
]. |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
196 |
|
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
197 |
^ cachedForm |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
198 |
|
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
199 |
"Created: / 03-02-2011 / 20:05:30 / cg" |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
200 |
! |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
201 |
|
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
202 |
onDevice:device |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
203 |
^ self asFormOn:device. |
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
204 |
|
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
205 |
"Created: / 03-02-2011 / 19:56:06 / cg" |
5684 | 206 |
! ! |
207 |
||
208 |
!GradientBackground methodsFor:'drawing'! |
|
209 |
||
210 |
fillRectangleX:x y:y width:w height:h in:aView |
|
211 |
"this is a first (very inefficient) try" |
|
212 |
||
5739
c4fbd37a6164
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5738
diff
changeset
|
213 |
|hAll wAll r1 r2 g1 g2 b1 b2 dR r dG g dB b scaleStartX scaleStartY |
5733
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
214 |
yRect hRun xRect wRun |
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
215 |
rC gC bC lastR lastG lastB |
5731
e638acae4e19
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5730
diff
changeset
|
216 |
minR maxR minG maxG minB maxB| |
5687
d4ab14b6cf0a
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5684
diff
changeset
|
217 |
|
5688 | 218 |
"/ always take the full-screen as reference |
219 |
"/ (so we do not have to care for changed gradient, when view changes size) |
|
5739
c4fbd37a6164
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5738
diff
changeset
|
220 |
usedLength notNil ifTrue:[ |
6014 | 221 |
usedLength == #full ifTrue:[ |
222 |
hAll := aView height. |
|
223 |
wAll := aView width. |
|
224 |
scaleStartX := 0. |
|
225 |
scaleStartY := 0. |
|
226 |
] ifFalse:[ |
|
227 |
hAll := usedLength. |
|
228 |
wAll := usedLength. |
|
229 |
scaleStartX := 0. |
|
230 |
scaleStartY := 0. |
|
231 |
] |
|
5739
c4fbd37a6164
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5738
diff
changeset
|
232 |
] ifFalse:[ |
6202
020ebdb99a1e
Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents:
6102
diff
changeset
|
233 |
hAll := aView device height. "/ aView height. |
020ebdb99a1e
Replace references to Diplay with "Screen current" - where appropriate
Stefan Vogel <sv@exept.de>
parents:
6102
diff
changeset
|
234 |
wAll := aView device width. "/ aView width. |
5739
c4fbd37a6164
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5738
diff
changeset
|
235 |
scaleStartX := x. |
c4fbd37a6164
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5738
diff
changeset
|
236 |
scaleStartY := y. |
c4fbd37a6164
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5738
diff
changeset
|
237 |
]. |
5684 | 238 |
|
239 |
r1 := color1 redByte. |
|
240 |
r2 := color2 redByte. |
|
241 |
g1 := color1 greenByte. |
|
242 |
g2 := color2 greenByte. |
|
243 |
b1 := color1 blueByte. |
|
244 |
b2 := color2 blueByte. |
|
245 |
||
5731
e638acae4e19
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5730
diff
changeset
|
246 |
minR := r1 min:r2. |
e638acae4e19
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5730
diff
changeset
|
247 |
maxR := r1 max:r2. |
e638acae4e19
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5730
diff
changeset
|
248 |
minG := g1 min:g2. |
e638acae4e19
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5730
diff
changeset
|
249 |
maxG := g1 max:g2. |
e638acae4e19
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5730
diff
changeset
|
250 |
minB := b1 min:b2. |
e638acae4e19
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5730
diff
changeset
|
251 |
maxB := b1 max:b2. |
e638acae4e19
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5730
diff
changeset
|
252 |
|
5728
c3c7f362b4c3
changed: #fillRectangleX:y:width:height:in:
Stefan Vogel <sv@exept.de>
parents:
5705
diff
changeset
|
253 |
aView lineStyle:#solid. |
c3c7f362b4c3
changed: #fillRectangleX:y:width:height:in:
Stefan Vogel <sv@exept.de>
parents:
5705
diff
changeset
|
254 |
|
5688 | 255 |
"/ individual lines; from top to bottom |
5705
56318de85b68
comment/format in: #initializeAllPluginClasses
Claus Gittinger <cg@exept.de>
parents:
5692
diff
changeset
|
256 |
(direction == #northSouth or:[direction == #vertical or:[direction == nil]]) ifTrue:[ |
5687
d4ab14b6cf0a
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5684
diff
changeset
|
257 |
dR := (r2 - r1) / hAll. |
5739
c4fbd37a6164
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5738
diff
changeset
|
258 |
r := r1 + (dR * scaleStartY). |
5687
d4ab14b6cf0a
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5684
diff
changeset
|
259 |
dG := (g2 - g1) / hAll. |
5739
c4fbd37a6164
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5738
diff
changeset
|
260 |
g := g1 + (dG * scaleStartY). |
5687
d4ab14b6cf0a
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5684
diff
changeset
|
261 |
dB := (b2 - b1) / hAll. |
5739
c4fbd37a6164
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5738
diff
changeset
|
262 |
b := b1 + (dB * scaleStartY). |
5733
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
263 |
|
5732
fba4327a852b
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5731
diff
changeset
|
264 |
r := (r max:minR) min:maxR. |
fba4327a852b
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5731
diff
changeset
|
265 |
g := (g max:minG) min:maxG. |
fba4327a852b
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5731
diff
changeset
|
266 |
b := (b max:minB) min:maxB. |
5684 | 267 |
|
5733
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
268 |
lastR := r asInteger. lastG := g asInteger. lastB := b asInteger. |
5732
fba4327a852b
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5731
diff
changeset
|
269 |
|
5733
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
270 |
yRect := y. |
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
271 |
hRun := 0. |
5731
e638acae4e19
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5730
diff
changeset
|
272 |
y to:y+h-1 do:[:yP | |
5684 | 273 |
rC := r asInteger. |
274 |
gC := g asInteger. |
|
275 |
bC := b asInteger. |
|
276 |
(rC ~~ lastR or:[gC ~~ lastG or:[bC ~~ lastB]]) ifTrue:[ |
|
5733
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
277 |
aView paint:(Color redByte:lastR greenByte:lastG blueByte:lastB). |
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
278 |
aView fillRectangleX:x y:yRect width:w height:hRun. |
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
279 |
yRect := yP. hRun := 0. |
5684 | 280 |
lastR := rC. lastG := gC. lastB := bC. |
281 |
]. |
|
5733
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
282 |
hRun := hRun + 1. |
5731
e638acae4e19
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5730
diff
changeset
|
283 |
r := ((r + dR) max:minR) min:maxR. |
e638acae4e19
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5730
diff
changeset
|
284 |
g := ((g + dG) max:minG) min:maxG. |
e638acae4e19
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5730
diff
changeset
|
285 |
b := ((b + dB) max:minB) min:maxB. |
5684 | 286 |
]. |
5733
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
287 |
hRun ~~ 0 ifTrue:[ |
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
288 |
aView paint:(Color redByte:lastR greenByte:lastG blueByte:lastB). |
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
289 |
aView fillRectangleX:x y:yRect width:w height:hRun. |
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
290 |
]. |
5688 | 291 |
^ self. |
292 |
]. |
|
293 |
||
294 |
"/ individual lines; from left to right |
|
295 |
(direction == #eastWest or:[direction == #horizontal]) ifTrue:[ |
|
296 |
dR := (r2 - r1) / wAll. |
|
5739
c4fbd37a6164
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5738
diff
changeset
|
297 |
r := r1 + (dR * scaleStartX). |
5688 | 298 |
dG := (g2 - g1) / wAll. |
5739
c4fbd37a6164
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5738
diff
changeset
|
299 |
g := g1 + (dG * scaleStartX). |
5688 | 300 |
dB := (b2 - b1) / wAll. |
5739
c4fbd37a6164
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5738
diff
changeset
|
301 |
b := b1 + (dB * scaleStartX). |
5733
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
302 |
|
5732
fba4327a852b
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5731
diff
changeset
|
303 |
r := (r max:minR) min:maxR. |
fba4327a852b
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5731
diff
changeset
|
304 |
g := (g max:minG) min:maxG. |
fba4327a852b
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5731
diff
changeset
|
305 |
b := (b max:minB) min:maxB. |
5688 | 306 |
|
5733
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
307 |
lastR := r asInteger. lastG := g asInteger. lastB := b asInteger. |
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
308 |
|
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
309 |
xRect := x. |
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
310 |
wRun := 0. |
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
311 |
|
5731
e638acae4e19
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5730
diff
changeset
|
312 |
x to:x+w-1 do:[:xP | |
5688 | 313 |
rC := r asInteger. |
314 |
gC := g asInteger. |
|
315 |
bC := b asInteger. |
|
316 |
(rC ~~ lastR or:[gC ~~ lastG or:[bC ~~ lastB]]) ifTrue:[ |
|
5733
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
317 |
aView paint:(Color redByte:lastR greenByte:lastG blueByte:lastB). |
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
318 |
aView fillRectangleX:xRect y:y width:wRun height:h. |
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
319 |
xRect := xP. wRun := 0. |
5688 | 320 |
lastR := rC. lastG := gC. lastB := bC. |
321 |
]. |
|
5733
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
322 |
wRun := wRun + 1. |
5731
e638acae4e19
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5730
diff
changeset
|
323 |
r := ((r + dR) max:minR) min:maxR. |
e638acae4e19
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5730
diff
changeset
|
324 |
g := ((g + dG) max:minG) min:maxG. |
e638acae4e19
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5730
diff
changeset
|
325 |
b := ((b + dB) max:minB) min:maxB. |
5688 | 326 |
]. |
5733
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
327 |
wRun ~~ 0 ifTrue:[ |
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
328 |
aView paint:(Color redByte:lastR greenByte:lastG blueByte:lastB). |
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
329 |
aView fillRectangleX:xRect y:y width:wRun height:h. |
08e2b386abef
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5732
diff
changeset
|
330 |
]. |
5688 | 331 |
^ self. |
5684 | 332 |
] |
333 |
||
334 |
"Created: / 23-01-2011 / 01:59:29 / cg" |
|
5739
c4fbd37a6164
changed: #fillRectangleX:y:width:height:in:
Claus Gittinger <cg@exept.de>
parents:
5738
diff
changeset
|
335 |
"Modified: / 06-04-2011 / 21:18:07 / cg" |
5684 | 336 |
! ! |
337 |
||
5461 | 338 |
!GradientBackground class methodsFor:'documentation'! |
339 |
||
6014 | 340 |
version |
6769 | 341 |
^ '$Header: /cvs/stx/stx/libview/GradientBackground.st,v 1.18 2015-02-14 21:30:18 cg Exp $' |
6014 | 342 |
! |
343 |
||
5461 | 344 |
version_CVS |
6769 | 345 |
^ '$Header: /cvs/stx/stx/libview/GradientBackground.st,v 1.18 2015-02-14 21:30:18 cg Exp $' |
5461 | 346 |
! ! |
6013 | 347 |