Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : mask on a videoloop is blinking

$
0
0
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...

  1. import processing.video.*;

  2. Movie myMovie;

  3. int a = 0;
  4. PImage img, maskImg;

  5. Movie [] eye = new Movie [2];
  6. Circle [] circles = new Circle[2];

  7. void setup()
  8. {
  9.   eye[0] = new Movie(this, "eye.mov");
  10.   eye[0].loop();

  11.   eye[1] = new Movie(this, "eye2.mov");
  12.   eye[1].loop();

  13.   maskImg = loadImage("mask-bg.jpg");
  14.   eye[a].mask(maskImg);

  15.   size(1920, 1000);
  16.   smooth();

  17.   for (int i = 0; i < circles.length; i++)
  18.   {
  19.     circles[i] = new Circle();
  20.   }
  21. }

  22. void movieEvent(Movie m) {
  23.   m.read();
  24. }

  25. void draw()
  26. {
  27.   background(0);

  28.   for (int i = 0; i < circles.length; i++)
  29.   {
  30.     circles[i].display();
  31.   }
  32. }

  33. void mouseDragged()
  34. {
  35.   for (int i = 0; i < circles.length; i++)
  36.   {
  37.     circles[i].move();
  38.   }
  39. }

  40. class Circle
  41. {
  42.   float r;
  43.   float xpos;
  44.   float ypos;
  45.   int eyer=0;

  46.   Circle()
  47.   {
  48.     xpos = random(width);
  49.     ypos = random(height);
  50.     noFill();
  51.     r = 50;
  52.   }
  53.   void display()
  54.   {   
  55.     noStroke();

  56.     if (a == eye.length) {
  57.       a = 0;
  58.     }
  59.     if (a==1) {
  60.       imageMode(CENTER);
  61.       image(eye[a], xpos, ypos, 304, 224);
  62.     }
  63.     else {
  64.       image(eye[a], xpos, ypos, 200, 150);
  65.     }
  66.     a++;
  67.     loop();
  68.   }

  69.   void move()
  70.   {
  71.     if (dist(mouseX, mouseY, xpos, ypos)<r)
  72.     {
  73.       xpos = mouseX;
  74.       ypos = mouseY;
  75.       if (xpos>width || ypos>height) {
  76.         xpos = 0;
  77.         ypos = 0;
  78.       }
  79.     }
  80.   }
  81. }

Viewing all articles
Browse latest Browse all 1768

Trending Articles