mirror of
https://github.com/hanzoui/mixlab-nodes.git
synced 2026-10-30 20:48:06 +00:00
55 lines
1.2 KiB
HTML
55 lines
1.2 KiB
HTML
<!DOCTYPE html>
|
|
<meta charset="utf-8">
|
|
<title>Preview</title>
|
|
|
|
<body>
|
|
<!-- <script src="./p5.js"></script> -->
|
|
<script src="./src/CCapture.js"></script>
|
|
<script>
|
|
let capturer = new CCapture({
|
|
format: 'png',
|
|
framerate: 60,
|
|
verbose: true
|
|
});
|
|
|
|
|
|
var capturer_start = (t = 1) => {
|
|
if (frameCount === t && capturer) {
|
|
capturer.start();
|
|
}
|
|
}
|
|
|
|
|
|
var capturer_end = (t = 24) => {
|
|
// console.log(frameCount < t, frameCount, t)
|
|
if (frameCount < t && capturer) {
|
|
capturer.capture(canvas, t);
|
|
} else if (capturer) {
|
|
capturer.save((frames) => {
|
|
window.parent.postMessage(
|
|
{
|
|
frames,
|
|
from: 'p5.widget',
|
|
status: 'save',
|
|
encoder: true
|
|
},
|
|
'*'
|
|
)
|
|
});
|
|
capturer.stop();
|
|
capturer = null;
|
|
}
|
|
}
|
|
|
|
// 监听来自iframe的消息
|
|
window.addEventListener('message', (event) => {
|
|
const data = event.data;
|
|
if (data.from === 'p5.widget' && data.status === 'stop') {
|
|
window.location.reload()
|
|
}
|
|
});
|
|
|
|
</script>
|
|
|
|
<script src="./preview-frame.bundle.js"></script>
|
|
</body> |