-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathCycle Composition Background Color.jsx
36 lines (31 loc) · 1.1 KB
/
Cycle Composition Background Color.jsx
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
/**
* @name Cycle Composition Background Color
* @version 2.1
* @author Kyle Martinez <www.kyle-martinez.com>
*
* @description Cycle the composition background color between "black", "gray", and "white".
*
* @license This script is provided "as is," without warranty of any kind, expressed or implied. In
* no event shall the author be held liable for any damages arising in any way from the use of this
* script.
*
* I'm just trying to help make life as an After Effects animator a little easier.
*/
(function cycleCompositionBackgroundColor() {
function getAverage(value) {
return (value[0] + value[1] + value[2]) / 3;
}
function getOldValue(value) {
return Math.round(value * 2) / 2;
}
function getNewValue(value) {
return (value + 0.5) % 1.5;
}
app.beginUndoGroup("Cycle Composition Background Color");
var comp = app.project.activeItem;
var avgValue = getAverage(comp.bgColor);
var oldValue = getOldValue(avgValue);
var newValue = getNewValue(oldValue);
comp.bgColor = [newValue, newValue, newValue];
app.endUndoGroup();
})();