Video Masked Within Multiple Triangles
in
Core Library Questions
•
2 years ago
I want to take video and mask it within four triangles. These triangles would also end up expanding and contracting to the beat of some music. I'd tried some things but it's not working out. Is there anyone who'd be able to help me out? Sorry in advance if I'm a total noob.
Here's the code I'm working with:
Here's the code I'm working with:
// IMPORT
// video
import processing.video.*;
// define initial variables and video parameters
Capture myCapture;
// audio
import ddf.minim.*;
import ddf.minim.signals.*;
// define initial audio parameters
Minim minim;
AudioPlayer mysound;
AudioMetaData meta;
void setup() {
size(600,600);
background(255);
smooth();
noStroke();
// audio setup
minim = new Minim(this);
mysound = minim.loadFile("02 Dirty Back Road-cut.mp3", 1000);
//change the end number, set a buffersize
meta = mysound.getMetaData();
// loop the audiotrack:
mysound.loop();
// video setup
myCapture = new Capture(this, 750, 600, 30); // set width, height and frame rate here
}
void draw() {
if (myCapture.available() == true) {
myCapture.read();
}
image(myCapture, -75, 0);
//fill(myCapture);
// triangle 1: top-left
triangle(300, 290.914, 300, 148.99, 370.957, 219.952);
// triangle 2: left
triangle(307.33, 300.005, 378, 229.038, 378, 370.962);
// triangle 3: bottom-right
triangle(300, 307.086, 300, 449.01, 229.033, 378.053);
// triangle 4: right
triangle(291.957, 300, 221, 229.038, 221, 370.962);
}
// if user clicks mouse, restart the track.
void mousePressed() {
mysound.loop();
}
// always close Minim audio classes when you finish with them
void stop() {
mysound.close();
minim.stop();
super.stop();
}
2