shutter = loadSound('mixkit-camera-shutter-click-1133.wav')
mouse = loadImage('mouse.png')
key = loadImage('keyboard.png')
createCanvas(windowWidth*0.78, windowHeight);
video = createCapture(VIDEO);
video.size(height, height / 1.125);
frameHeight = height / 1.125
frameY = height - video.height / 2
mouse.resize(width / 5, 0)
image(mouse, width / 10, height - height /2.5)
image(key, width - width / 12, height - height / 2.2)
textAlign(CENTER, CENTER)
text('Click anywhere', width / 10, height - height / 3)
text('to capture a frame', width / 10, height - height / 3 + height / 50)
text('Press SPACE BAR', width - width / 10, height - height / 3)
text('to play the animation', width - width / 10, height - height / 3 + height / 50)
rect(0, 0, width, height / 2.9)
image(video, width / 2, frameY);
image(frames[frames.length - 1], width / 2, frameY, frameWidth, frameHeight);
if (isPlaying && frames.length > 0) {
image(frames[currentIndex], width / 2, frameY, frameWidth, frameHeight);
if (millis() - lastFrameTime > 100) {
currentIndex = (currentIndex + 1) % frames.length;
lastFrameTime = millis();
function mousePressed() {
if (mouseX > 0 || mouseY > height / 5) {
textAlign(CENTER, CENTER)
mouse.resize(width / 5, 0)
image(mouse, width / 10, height - height /2.5)
image(key, width - width / 12, height - height / 2.2)
textAlign(CENTER, CENTER)
text('Click anywhere', width / 10, height - height / 3)
text('to capture a frame', width / 10, height - height / 3 + height / 50)
text('Press SPACE BAR', width - width / 10, height - height / 3)
text('to play the animation', width - width / 10, height - height / 3 + height / 50)
frameHeight = height / 1.125
function captureFrame() {
frames.push(video.get());
function toggleAnimation() {
lastFrameTime = millis();
alert('Capture frames first!');
function displayThumbnails() {
if (hideThumbs === false) {
const thumbnailSize = height / 7.05;
text('FIRST FRAME', width / 12, height / 25)
text('none yet', width / 12, height / 5)
text(frames.length + ' TOTAL FRAMES', width/2, height / 25)
let animationLength = frames.length / 30
text('your animation will be ' + nfc(animationLength, 2) + ' seconds long', width / 2, height / 12)
text('LAST FRAME', width - width / 12, height / 25)
text('none yet', width - width / 12, height / 5)
image(frames[0], thumbnailSize*1.05, (thumbnailSize/1.5) + height / 10, thumbnailSize*2, thumbnailSize*2);
image(frames[frames.length - 1], width - (thumbnailSize*1.05), (thumbnailSize/1.5) + height / 10, thumbnailSize*2, thumbnailSize*2);