-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcombiner.js
More file actions
76 lines (60 loc) · 1.99 KB
/
combiner.js
File metadata and controls
76 lines (60 loc) · 1.99 KB
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
// Generated by CoffeeScript 1.10.0
(function() {
var Combiner, Common,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Common = require('./common');
Combiner = (function(superClass) {
extend(Combiner, superClass);
function Combiner(left1, right1, method) {
this.left = left1;
this.right = right1;
this.method = method;
}
Combiner.prototype.valueAt = function(time) {
return this.method(this.left.valueAt(time), this.right.valueAt(time));
};
Combiner.add = function(left, right) {
return new Combiner(left, right, function(a, b) {
return a + b;
});
};
Combiner.subtract = function(left, right) {
return new Combiner(left, right, function(a, b) {
return a - b;
});
};
Combiner.multiply = function(left, right) {
return new Combiner(left, right, function(a, b) {
return a * b;
});
};
Combiner.divide = function(left, right) {
return new Combiner(left, right, function(a, b) {
return a / b;
});
};
Combiner.exponent = function(left, right) {
return new Combiner(left, right, function(a, b) {
return Math.pow(a, b);
});
};
Combiner.modulo = function(left, right) {
return new Combiner(left, right, function(a, b) {
return a % b;
});
};
Combiner.mix = function(left, right) {
return new Combiner(left, right, function(a, b) {
var z;
a = (a + 1) / 2;
b = (b + 1) / 2;
z = a < 0.5 && b < 0.5 ? 2 * a * b : 2 * (a + b) - (2 * a * b) - 1;
return (z * 2) - 1;
});
};
return Combiner;
})(Common);
module.exports = Combiner;
}).call(this);
//# sourceMappingURL=combiner.js.map