-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathx_imgseq.js
More file actions
210 lines (168 loc) · 3.74 KB
/
x_imgseq.js
File metadata and controls
210 lines (168 loc) · 3.74 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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
// websites for Warping
// https://moviola.com/technique/retime-repair/
// https://www.provideocoalition.com/slow-mo-blues-fixing-bad-optical-flow-retimes/
autowatch = 1;
inlets = 1;
outlets = 4;
include('easingfunctions.js');
include('scalingfunctions.js');
var t = this.patcher;
// -------------------------------------------------
// Size Manegment
output = new Global('player');
output.screensize;
output.fps;
// -------------------------------------------------
// SEQUENCE Control
var imagecount;
var transitiontime;
var holdtime;
var fps = output.fps;
var loop;
var currentframe = 1;
var fade = 0;
var transition = 1;
var framehold = 0;
var easingmode = 0;
function setstate(x) {
state = x;
return state;
}
function setlength(s) {
imagecount = s;
return imagecount;
}
function setloop(i) {
loop = i;
return loop;
}
function sethold(s) {
var fps = output.fps;
holdtime = s;
return holdtime;
}
function settransition(s) {
var fps = output.fps;
transitiontime = s;
return transitiontime;
}
function seteasing(i) {
easingmode = i;
return easingmode;
}
function ease(f) {
switch (easingmode) {
case 0:
x = Linear(f);
break;
case 1:
x = InOutSine(f);
break;
case 2:
x = InOutExpo(f);
break;
case 3:
x = InOutQuint(f);
break;
case 4:
x = InOutQuad(f);
break;
case 5:
x = InOutQuart(f);
break;
case 6:
x = InOutCubic(f);
break;
case 7: // not working because of Math.sqrt
x = InOutCirc(f);
break;
default:
}
return x;
}
function getall() {
var fps = output.fps;
post('\n' + 'Imagecount ' + imagecount);
post('\n' + 'Transitiontime ' + transition);
post('\n' + 'Frameholdtime ' + framehold);
post('\n' + 'FPS ' + fps);
post('\n' + 'Status: ' + state);
post('\n' + 'Transition ' + transition);
post('\n' + 'Loop ' + loop);
}
// -------------------------------------------------
// set transition
// FADING FUNCTION between Textures
// fades from one Frame to the next
// check easingfunctions.js
var transitionframe = 0;
var holdframe = 0;
var state = 0;
function bang() {
// MAIN COUNTING FUNCTION
if (imagecount > 0) {
switch (state) {
case 1:
switch (transition) {
case 1:
// transition from one frame to the next
// transitiontime = x frames
if (transitionframe < transitiontime) {
transitionframe += 1;
outlet(0,'tr_frame', transitionframe);
}
else {
transition = 0;
transitionframe = 0;
if (currentframe <= imagecount) {
currentframe += 1;
}
else {
if (loop == 1) {
currentframe = 1;
}
else {
var status = t.getnamed('status');
status.message(0);
}
}
}
break;
case 0:
// Transition is over and we proceed to Holdtime if defined
// Time to stop at one frame before transit to the next
// Holdtime = x frames
if ( holdtime > 0) {
if ( holdframe < holdtime) {
holdframe += 1;
outlet(0,'ho_frame',holdframe);
}
else {
transition = 1;
holdframe = 0;
}
}
else {
transition = 1;
}
break;
default:
}
break;
case 0:
break;
default:
}
var fadedirection = Math.floor(currentframe % 2);
var fadetime = normalize(transitionframe,0,1,0,transitiontime);
// check if we have currentframe is even with %2 = 0
if (fadedirection == 0 ) {
fade = 1- ease(fadetime);
} else {
fade = ease(fadetime);
}
outlet(3,fadedirection);
outlet(1,Math.floor(currentframe));
outlet(2,'blendamount', fade);
}
}