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

mask on a videoloop is blinking

$
0
0
posted this again because i think this has to be in the forum Programming Questions but the post went into Core Library Questions:

hi there i got a problem with my videoloops that are masked with a jpg.
at the end of the loop when the video is jumping to the beginning for one frame the mask is not working
and the unmasked video is blinking for one frame...

anybody knows that problem?

heres the code

  1. import processing.video.*;

  2. Movie myMovie;

  3. int a = 0;


  4. //// Arrays für eye movie & Circle Class
  5. Movie [] eye = new Movie [16];
  6. Circle [] circles = new Circle[16];

  7.  
  8. void setup()
  9. {
  10.   

  11.  
  12.   
  13. //// Zuweisung der Filme zu den Arrays  
  14.   eye[0] = new Movie(this, "eye.mov");
  15.   eye[0].loop();
  16.   
  17.   eye[1] = new Movie(this, "eye2.mov");
  18.   eye[1].loop();
  19.   
  20.   eye[2] = new Movie(this, "eye.mov");
  21.   eye[2].loop();
  22.    
  23.   eye[3] = new Movie(this, "eye2.mov");
  24.   eye[3].loop();
  25.   
  26.   eye[4] = new Movie(this, "eye.mov");
  27.   eye[4].loop();
  28.   
  29.   eye[5] = new Movie(this, "eye2.mov");
  30.   eye[5].loop();
  31.   
  32.   eye[6] = new Movie(this, "eye.mov");
  33.   eye[6].loop();
  34.   
  35.   eye[7] = new Movie(this, "eye2.mov");
  36.   eye[7].loop();
  37.   
  38.   eye[8] = new Movie(this, "eye.mov");
  39.   eye[8].loop();
  40.    
  41.   eye[9] = new Movie(this, "eye2.mov");
  42.   eye[9].loop();
  43.   
  44.  eye[10] = new Movie(this, "eye.mov");
  45.   eye[10].loop();
  46.   
  47.   eye[11] = new Movie(this, "eye2.mov");
  48.   eye[11].loop();
  49.   
  50. eye[12] = new Movie(this, "eye.mov");
  51.   eye[12].loop();
  52.   
  53.     eye[13] = new Movie(this, "eye2.mov");
  54.   eye[13].loop();
  55.   
  56.  eye[14] = new Movie(this, "eye.mov");
  57.   eye[14].loop();
  58.    
  59.     eye[15] = new Movie(this, "eye2.mov");
  60.   eye[15].loop();
  61.   
  62.  /** eye[16] = new Movie(this, "eye.mov");
  63.   eye[16].loop();
  64.   
  65.   eye[17] = new Movie(this, "eye2.mov");
  66.   eye[17].loop();
  67.   
  68.   eye[18] = new Movie(this, "eye2.mov");
  69.   eye[18].loop();
  70.   
  71.   eye[19] = new Movie(this, "eye.mov");
  72.   eye[19].loop();
  73.   
  74.   eye[20] = new Movie(this, "eye2.mov");
  75.   eye[20].loop();
  76.   
  77.   **/
  78.   
  79.   
  80.   size(1920,1000);
  81.   smooth();
  82.   
  83. /// if schleife welche die Circles erstellt

  84.   for (int i = 0; i < circles.length; i++)
  85.   {
  86.     circles[i] = new Circle();
  87.   }

  88. }





  89.  
  90. void draw()
  91. {

  92.   

  93.  background(0);
  94.  
  95.  
  96.   for (int i = 0; i < circles.length; i++)
  97.   {
  98.     circles[i].display();
  99.   }
  100.   

  101.   
  102. }


  103.  
  104. //funktion welche die objekte draggable machen
  105. void mouseDragged()
  106. {
  107.   for (int i = 0; i < circles.length; i++)
  108.   {
  109.     circles[i].move();
  110.   }
  111. }



  112. // die Circle Klasse 
  113. class Circle
  114. {
  115.   float r;
  116.   float xpos;
  117.   float ypos;
  118.   int eyer=0;
  119.  
  120.   Circle()
  121.   {

  122.   
  123.   
  124.     xpos = random(width);
  125.     ypos = random(height);
  126.    noFill();
  127.     r = 50;
  128.     
  129.          
  130.     
  131.   }
  132.  void display()
  133.   {
  134.     

  135.     noStroke();
  136.     //fill(255,80);
  137.     
  138.      if (a == eye.length){
  139.       a = 0;
  140.     }
  141.    
  142.      
  143.     if (a==5){
  144.     
  145.       rectMode(CENTER); 
  146.       
  147.      
  148.      PImage img, maskImg;
  149.   maskImg = loadImage("mask-bg.jpg");
  150.   eye[a].mask(maskImg);
  151.   image(eye[a],xpos,ypos,304,224);

  152.     }else{
  153.       

  154.      PImage img, maskImg;
  155.   maskImg = loadImage("mask-bg.jpg");
  156.   eye[a].mask(maskImg);
  157.   image(eye[a],xpos,ypos,200,150);
  158.     imageMode(CENTER);

  159.   }
  160.     a++;

  161.     
  162.    // rect(xpos,ypos,r*2,r*2);
  163.     loop();
  164.   }
  165.   
  166.  
  167.   void move()
  168.   {
  169.     if(dist(mouseX,mouseY,xpos,ypos)<r)
  170.     {
  171.       xpos = mouseX;
  172.       ypos = mouseY;
  173.       if (xpos>width || ypos>height) {
  174.         xpos = 0;
  175.         ypos = 0;
  176.       }
  177.     }
  178.   }
  179. }



  180. void movieEvent(Movie m) {
  181.   m.read();
  182. }

Viewing all articles
Browse latest Browse all 1768

Trending Articles