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