Hello Processors, thank you for your time. I have a loop that changes the size of mp4’s (images), using the key “s” I stop the loop and restart it with key “p”. I want to click on any of the images and randomly tint. I try doing this by creating a counter and using a for loop, it is not working, but that wont do what I want exactly, which is tinting any of the vids I decide to click.
import processing.video.*;
Movie myMovie;
int tintCounter;
boolean resize = true;
int x = 0;
int y = 0;
void setup() {
size(600, 800);
myMovie = new Movie(this, "fogata.mp4");
myMovie.loop();
}
void draw() {
if (resize=true) {
background(255);
for ( float i = .2; i<5; i++) {
for ( float x = .15; x<2; x++) {
image(myMovie, 300 * x, 200 * i, mouseX+(4096/20)-25, mouseY+(2160/20)-25);
}
}
}
if (resize=false) {
x = tintCounter;
tint(0);
}
if (keyCode=='S') {
resize=false;
background(255);
for ( float i = .2; i<5; i++) {
for ( float x = .15; x<2; x++) {
image(myMovie, 300*x, 200 * i, 4096/20, 2160/20);
}
}
}
if (keyCode=='P') {
resize=true;
}
}
// Called every time a new frame is available to read
void movieEvent(Movie m) {
m.read();
}
void mousePressed(){
tintCounter++;
tintCounter%=8;
}
Study the following changes. I have implemented the solution only for selecting the image along the width. You need to add changes to select the image along the height. Combining the selection along the width and height allows you to choose a single image.
Also notice that this
if(resize=true)
is not the same as
if(resize==true)
The second one is correct.
Kf
import processing.video.*;
Movie myMovie;
int tintCounter;
boolean resize = true;
int x = 0;
int y = 0;
float tilew;
float tileh;
void setup() {
size(600, 800);
myMovie = new Movie(this, "transit.mov");
myMovie.loop();
}
void draw() {
background(255);
if (resize==true) {
tilew=mouseX+(4096/20)-25;
tileh=mouseY+(2160/20)-25;
}
for ( float i = .2; i<5; i++) {
for ( float x = .15; x<2; x++) {
if(resize==false && mouseX > (300*x) && mouseX < (300*x+tilew) )
tint(50);
else
noTint();
image(myMovie, 300 * x, 200 * i, tilew, tileh);
}
}
}
void keyReleased() {
if (key=='p') {
resize=true;
}
if (key=='s') {
resize=false;
}
}
// Called every time a new frame is available to read
void movieEvent(Movie m) {
m.read();
}
void mousePressed() {
tintCounter++;
tintCounter%=8;
}
4096 is the width of the raw video. If I use the system’s variable ‘width’ it distorts the video… I figured I can do what I want with object oriented programing.