We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello!
I am trying to get the right half of my processing window to replicate whatever is happening (in this case showing 3d shapes) on the left half of the window - in other words, a stereo effect. I have tried torturing the code found here which mirrors one side, in order to get it to replicate and not mirror, but without any success at all. Playing with the numbers via trial and error just gives me distorted results.
Does anyone have a clue what I could do? Thank you very much!
void setup(){
size(800,400, P2D);
}
void draw(){
background(250);
fill(0);
rect(0,0,200,400);
fill(255);
rect(0,200,200,400);
fill(255,0,0);
ellipse(mouseX, mouseY,20,20);
flipHalf();
}
void flipHalf() {
beginShape();
texture(get());
vertex(width/2, 0, width/2, 0);
vertex(width, 0, 0, 0);
vertex(width, height, 0, height);
vertex(width/2, height, width/2, height);
endShape();
}
Answers
@jetjaguar -- don't overthink it. If you want to copy the left half of your sketch to the right half, just use
copy()
at the end of your draw loop.Here is a simple example based on your code above:
P.S. "distorted results" may mean that you are using x1,y1,x2,y2 -- copy uses x,y,w,h. The w,h values in the first four arguments and in second four should be the same numbers or there will be distortion.
@jetjaguar -- you can also create a
PGraphics
image and then draw it twice on the main canvas withimage()
. Both approaches work but PGraphics is more flexible than copy if you want different compositions with multiple images, partial overlapping, etc.Here is the same sketch as above, only using PGraphics instead of copy:
copy(0, 0, width/2, height, width/2, 0, width/2, height);
This works perfectly for what I need, it copies everything. Thank you so much Jeremy!