Loading...
Logo
Processing Forum

image trail effect

in Programming Questions  •  1 year ago  
Hello All, I am trying to mask the one Image using the another image of based on the position of the mouse. Only the surface where the mouse move will get masked and it should create the trail effect which slowly fades out(say 5 sec) after the mouse passes the area. 
   So far I have archieved to get trail effect but I am having problem with the masking. this is my code which I have used. im my code i want to display image pixels instead of ellipse.



PImage img;
int val = 255;
PImage myImg;

//int a = 10;

void setup() {

  size(640, 480);
  
  frameRate(30);
  img = loadImage("building.jpg");
  //image(img,0,0, width, height);
  myImg = loadImage("denmark.jpg");
   
  noStroke();
  smooth();
  
}


void draw() {
 
   
 // background(0);
  
  tint(255, val);
  image(myImg, 0, 0);
  
  fill(0, 10);
  rect(0, 0, width, height);
 
}

void mouseMoved(){
  val = 0;
 // a = 255;
  fill(255, 0, 0, 255);
  noStroke(); 
  ellipse(mouseX, mouseY, 60, 60);
}

Replies(6)

" I am having problem with the masking"
Well, I don't even see your masking in this code...
I am sorry, I am really a beginner in processing. Actually I want to create trail effect with second image(img ..see code) pixels which show the image part where the mouse will go and once the mouse stops the earliar image(my Img) should be back on display. I am using copy fuction to to show the image pixels on the mouseX and MouseY movement but I dont knw how to get the earliar image to display once the mouse stops. see the code to get the idea. correct me if I am wrong somewhere...cheers

Here is my modified code


PImage img;
int val = 255;
PImage myImg;

void setup() {
  
  size(640, 480);
  img = loadImage("building.jpg");
  //image(img,0,0, width, height);
  myImg = loadImage("denmark.jpg");
  
}

void draw() {
  //background(0);
  tint(255, val);
  image(myImg, 0, 0);

  fill(0, 2);
  rect(0, 0, width, height);
  fill(255, 0, 0);
  noStroke(); 
  // ellipse(mouseX, mouseY, 60, 60);
  // tint(255, val-=5);
  // image(pg,mouseX, mouseY);
  tint(255, val-=5);
  copy(img, mouseX, mouseY, 80, 80, mouseX, mouseY, 80, 80); 
  //blend(img,  mouseX, mouseY, 80, 80, mouseX, mouseY, 80, 80, BLEND);
}

pls help guys...
No time right now, but I will go back to the thread later. Have you tried to search the forum of examples of masking images?
yes, I have searched for the examples in the forum and reference also. but I am stuck in this problem.
Perhaps add something like
Copy code
  1.   if (pmouseX == mouseX && pmouseY == mouseY)
  2.   {
  3.     tint(255);
  4.     image(myImg, 0, 0);
  5.   }
at the end of draw().