MCPcopy Create free account
hub / github.com/bwasti/mebm / split

Method split

script.js:1239–1274  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1237 }
1238
1239 split() {
1240 if (!this.selected_layer) {
1241 return;
1242 }
1243 let l = this.selected_layer;
1244 if (!(l instanceof VideoLayer)) {
1245 return;
1246 }
1247 if (!l.ready) {
1248 return;
1249 }
1250 if (l.start_time > this.time) {
1251 return;
1252 }
1253 if (l.start_time + l.total_time < this.time) {
1254 return;
1255 }
1256 let nl = new VideoLayer({
1257 name: l.name + "NEW",
1258 _leave_empty: true
1259 });
1260 const pct = (this.time - l.start_time) / l.total_time;
1261 const split_idx = Math.round(pct * l.frames.length);
1262 nl.frames = l.frames.splice(0, split_idx);
1263 this.add(nl);
1264 nl.start_time = l.start_time;
1265 nl.total_time = pct * l.total_time;
1266 l.start_time = l.start_time + nl.total_time;
1267 l.total_time = l.total_time - nl.total_time;
1268 nl.width = l.width;
1269 nl.height = l.height;
1270 nl.canvas.width = l.canvas.width;
1271 nl.canvas.height = l.canvas.height;
1272 nl.resize(); // fixup thumbnail
1273 nl.ready = true;
1274 }
1275
1276 onend(callback) {
1277 this.onend_callback = callback;

Callers 5

renderMethod · 0.80
addURIMethod · 0.80
script.jsFile · 0.80
exportVideoFunction · 0.80
uploadSupportedTypeFunction · 0.80

Calls 2

addMethod · 0.95
resizeMethod · 0.45

Tested by

no test coverage detected