updating image from external class
in
Programming Questions
•
6 months ago
Just for fun-- I'm trying to figure out how to update a PImage from an external class. The class is working ( I can trace it and see outlines briefly of what it is changing) , but it's not showing up on the main window. Can someone give me a hand?
Abbreviated code:
void setup(){
size(600,800);
myImg=loadImage("starter.jpg");
}
void draw(){
image(myImg,0,0,width,height);
}
void keyPressed(){
if (key=='s'){
stutter= new Stutter(myImg,width,height,6);
//tried both of these since updated image is not reloading over original
//stutter.upDate();
// upDate();
}
class Stutter{
Stutter(PImage img, int w, int h, int it){
// …. code…… this all works as desired
for (int i=0; i<it; i++){
dW=int(random(srcW/2, srcW));
dx=int(random(rndX,rndX+2));
copy(rndX, rndY, srcW, srcH, dx, dy, dW, srcH);
dy=dy+srcH;
}
upDate(img,w,h);
}
//tried this to fix problem.
// should I write it to another PGraphic????
void upDate(PImage img, int w, int h){
image(img,0,0,w,h);
}
}
1