Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / gfx / fx.js @ 9

History | View | Annotate | Download (4.54 KB)

1 9 andrej.cim
/*
2
        Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3
        Available via Academic Free License >= 2.1 OR the modified BSD license.
4
        see: http://dojotoolkit.org/license for details
5
*/
6
7
8
if(!dojo._hasResource["dojox.gfx.fx"]){
9
dojo._hasResource["dojox.gfx.fx"]=true;
10
dojo.provide("dojox.gfx.fx");
11
dojo.require("dojox.gfx.matrix");
12
(function(){
13
var d=dojo,g=dojox.gfx,m=g.matrix;
14
var _1=function(_2,_3){
15
this.start=_2,this.end=_3;
16
};
17
d.extend(_1,{getValue:function(r){
18
return (this.end-this.start)*r+this.start;
19
}});
20
var _4=function(_5,_6,_7){
21
this.start=_5,this.end=_6;
22
this.units=_7;
23
};
24
d.extend(_4,{getValue:function(r){
25
return (this.end-this.start)*r+this.start+this.units;
26
}});
27
var _8=function(_9,_a){
28
this.start=_9,this.end=_a;
29
this.temp=new dojo.Color();
30
};
31
d.extend(_8,{getValue:function(r){
32
return d.blendColors(this.start,this.end,r,this.temp);
33
}});
34
var _b=function(_c){
35
this.values=_c;
36
this.length=_c.length;
37
};
38
d.extend(_b,{getValue:function(r){
39
return this.values[Math.min(Math.floor(r*this.length),this.length-1)];
40
}});
41
var _d=function(_e,_f){
42
this.values=_e;
43
this.def=_f?_f:{};
44
};
45
d.extend(_d,{getValue:function(r){
46
var ret=dojo.clone(this.def);
47
for(var i in this.values){
48
ret[i]=this.values[i].getValue(r);
49
}
50
return ret;
51
}});
52
var _10=function(_11,_12){
53
this.stack=_11;
54
this.original=_12;
55
};
56
d.extend(_10,{getValue:function(r){
57
var ret=[];
58
dojo.forEach(this.stack,function(t){
59
if(t instanceof m.Matrix2D){
60
ret.push(t);
61
return;
62
}
63
if(t.name=="original"&&this.original){
64
ret.push(this.original);
65
return;
66
}
67
if(!(t.name in m)){
68
return;
69
}
70
var f=m[t.name];
71
if(typeof f!="function"){
72
ret.push(f);
73
return;
74
}
75
var val=dojo.map(t.start,function(v,i){
76
return (t.end[i]-v)*r+v;
77
}),_13=f.apply(m,val);
78
if(_13 instanceof m.Matrix2D){
79
ret.push(_13);
80
}
81
},this);
82
return ret;
83
}});
84
var _14=new d.Color(0,0,0,0);
85
var _15=function(_16,obj,_17,def){
86
if(_16.values){
87
return new _b(_16.values);
88
}
89
var _18,_19,end;
90
if(_16.start){
91
_19=g.normalizeColor(_16.start);
92
}else{
93
_19=_18=obj?(_17?obj[_17]:obj):def;
94
}
95
if(_16.end){
96
end=g.normalizeColor(_16.end);
97
}else{
98
if(!_18){
99
_18=obj?(_17?obj[_17]:obj):def;
100
}
101
end=_18;
102
}
103
return new _8(_19,end);
104
};
105
var _1a=function(_1b,obj,_1c,def){
106
if(_1b.values){
107
return new _b(_1b.values);
108
}
109
var _1d,_1e,end;
110
if(_1b.start){
111
_1e=_1b.start;
112
}else{
113
_1e=_1d=obj?obj[_1c]:def;
114
}
115
if(_1b.end){
116
end=_1b.end;
117
}else{
118
if(typeof _1d!="number"){
119
_1d=obj?obj[_1c]:def;
120
}
121
end=_1d;
122
}
123
return new _1(_1e,end);
124
};
125
g.fx.animateStroke=function(_1f){
126
if(!_1f.easing){
127
_1f.easing=d._defaultEasing;
128
}
129
var _20=new d.Animation(_1f),_21=_1f.shape,_22;
130
d.connect(_20,"beforeBegin",_20,function(){
131
_22=_21.getStroke();
132
var _23=_1f.color,_24={},_25,_26,end;
133
if(_23){
134
_24.color=_15(_23,_22,"color",_14);
135
}
136
_23=_1f.style;
137
if(_23&&_23.values){
138
_24.style=new _b(_23.values);
139
}
140
_23=_1f.width;
141
if(_23){
142
_24.width=_1a(_23,_22,"width",1);
143
}
144
_23=_1f.cap;
145
if(_23&&_23.values){
146
_24.cap=new _b(_23.values);
147
}
148
_23=_1f.join;
149
if(_23){
150
if(_23.values){
151
_24.join=new _b(_23.values);
152
}else{
153
_26=_23.start?_23.start:(_22&&_22.join||0);
154
end=_23.end?_23.end:(_22&&_22.join||0);
155
if(typeof _26=="number"&&typeof end=="number"){
156
_24.join=new _1(_26,end);
157
}
158
}
159
}
160
this.curve=new _d(_24,_22);
161
});
162
d.connect(_20,"onAnimate",_21,"setStroke");
163
return _20;
164
};
165
g.fx.animateFill=function(_27){
166
if(!_27.easing){
167
_27.easing=d._defaultEasing;
168
}
169
var _28=new d.Animation(_27),_29=_27.shape,_2a;
170
d.connect(_28,"beforeBegin",_28,function(){
171
_2a=_29.getFill();
172
var _2b=_27.color,_2c={};
173
if(_2b){
174
this.curve=_15(_2b,_2a,"",_14);
175
}
176
});
177
d.connect(_28,"onAnimate",_29,"setFill");
178
return _28;
179
};
180
g.fx.animateFont=function(_2d){
181
if(!_2d.easing){
182
_2d.easing=d._defaultEasing;
183
}
184
var _2e=new d.Animation(_2d),_2f=_2d.shape,_30;
185
d.connect(_2e,"beforeBegin",_2e,function(){
186
_30=_2f.getFont();
187
var _31=_2d.style,_32={},_33,_34,end;
188
if(_31&&_31.values){
189
_32.style=new _b(_31.values);
190
}
191
_31=_2d.variant;
192
if(_31&&_31.values){
193
_32.variant=new _b(_31.values);
194
}
195
_31=_2d.weight;
196
if(_31&&_31.values){
197
_32.weight=new _b(_31.values);
198
}
199
_31=_2d.family;
200
if(_31&&_31.values){
201
_32.family=new _b(_31.values);
202
}
203
_31=_2d.size;
204
if(_31&&_31.units){
205
_34=parseFloat(_31.start?_31.start:(_2f.font&&_2f.font.size||"0"));
206
end=parseFloat(_31.end?_31.end:(_2f.font&&_2f.font.size||"0"));
207
_32.size=new _4(_34,end,_31.units);
208
}
209
this.curve=new _d(_32,_30);
210
});
211
d.connect(_2e,"onAnimate",_2f,"setFont");
212
return _2e;
213
};
214
g.fx.animateTransform=function(_35){
215
if(!_35.easing){
216
_35.easing=d._defaultEasing;
217
}
218
var _36=new d.Animation(_35),_37=_35.shape,_38;
219
d.connect(_36,"beforeBegin",_36,function(){
220
_38=_37.getTransform();
221
this.curve=new _10(_35.transform,_38);
222
});
223
d.connect(_36,"onAnimate",_37,"setTransform");
224
return _36;
225
};
226
})();
227
}