1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
/* <copyright>
This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
</copyright> */
var Montage = require("montage").Montage;
var FlowPathLerp = exports.FlowPathLerp = Montage.create(Montage, {
_path1: {
enumerable: false,
value: null
},
_path2: {
enumerable: false,
value: null
},
_interpolant: {
enumerable: false,
value: 0
},
path1: {
get: function () {
return this._path1;
},
set: function (value) {
this._path1 = value;
this.resultPath = true;
}
},
path2: {
get: function () {
return this._path2;
},
set: function (value) {
this._path2 = value;
this.resultPath = true;
}
},
interpolant: {
get: function () {
return this._interpolant;
},
set: function (value) {
this._interpolant = value;
this.resultPath = true;
}
},
_resultPath: {
enumerable: false,
value: null
},
resultPath: {
get: function () {
return this._resultPath;
},
set: function () {
var self = this;
this._resultPath = {
value: function (slide) {
var v1=self._path1.value(slide),
v2=self._path2.value(slide),
m1=1-self._interpolant,
m2=self._interpolant,
result={},
i;
for (i in v1) {
if (v1.hasOwnProperty(i)&&(i!="style")) {
if (v2.hasOwnProperty(i)) {
if ((typeof v1[i]==="number")&&(typeof v2[i]==="number")) {
result[i]=v1[i]*m1+v2[i]*m2;
} else {
result[i]=v1[i];
}
} else {
result[i]=v1[i];
}
}
}
for (i in v2) {
if (v2.hasOwnProperty(i)&&(i!="style")&&(!v1.hasOwnProperty(i))) {
result[i]=v2[i];
}
}
if (v1.style) {
result.style={};
for (i in v1.style) {
if (v1.style.hasOwnProperty(i)) {
if ((v2.style)&&(v2.style.hasOwnProperty(i))&&(typeof v1.style[i]==="number")&&(typeof v2.style[i]==="number")) {
result.style[i]=v1.style[i]*m1+v2.style[i]*m2;
} else {
result.style[i]=v1.style[i];
}
}
}
}
return result;
}
};
}
}
});
|