i tried to put the mask image code in the setup but now the masking won't work anymore..
if you could help a processing newbie it would be awesome...
- import processing.video.*;
- Movie myMovie;
- int a = 0;
- PImage img, maskImg;
- Movie [] eye = new Movie [2];
- Circle [] circles = new Circle[2];
- void setup()
- {
- eye[0] = new Movie(this, "eye.mov");
- eye[0].loop();
- eye[1] = new Movie(this, "eye2.mov");
- eye[1].loop();
- maskImg = loadImage("mask-bg.jpg");
- eye[a].mask(maskImg);
- size(1920, 1000);
- smooth();
- for (int i = 0; i < circles.length; i++)
- {
- circles[i] = new Circle();
- }
- }
- void movieEvent(Movie m) {
- m.read();
- }
- void draw()
- {
- background(0);
- for (int i = 0; i < circles.length; i++)
- {
- circles[i].display();
- }
- }
- void mouseDragged()
- {
- for (int i = 0; i < circles.length; i++)
- {
- circles[i].move();
- }
- }
- class Circle
- {
- float r;
- float xpos;
- float ypos;
- int eyer=0;
- Circle()
- {
- xpos = random(width);
- ypos = random(height);
- noFill();
- r = 50;
- }
- void display()
- {
- noStroke();
- if (a == eye.length) {
- a = 0;
- }
- if (a==1) {
- imageMode(CENTER);
- image(eye[a], xpos, ypos, 304, 224);
- }
- else {
- image(eye[a], xpos, ypos, 200, 150);
- }
- a++;
- loop();
- }
- void move()
- {
- if (dist(mouseX, mouseY, xpos, ypos)<r)
- {
- xpos = mouseX;
- ypos = mouseY;
- if (xpos>width || ypos>height) {
- xpos = 0;
- ypos = 0;
- }
- }
- }
- }