We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi,
I'm working on a final project for a class and I want to create an interactive piece with 4 mirrored quadrants. I found code to get the left half to reflect on the right half of the composition. Any suggestions on how I can get the bottom half to mirror the top half as well?
float r, w;
PImage leftHalf;
import processing.pdf.*;
void setup(){
size(720,720);
background(255);
frameRate(1);
beginRecord(PDF, "P4Reflect-1.pdf");
}
void draw(){
r = random(0,360);
w = random(5,50);
fill(75,0,130);
stroke(w);
line(0, r, mouseX, mouseY);
leftHalf = get(0, 0, width/2, height);
translate(width, 0);
scale(-1, 1);
image(leftHalf, 0, 0);
}
void mousePressed(){
endRecord();
exit();
}
Answers
Use height/2 and also scale(1,-1) and scale(-1,-1).
Kf
When scale() is called with -1 in the x or y argument, it flips or mirrors all future drawing commands along that axis.
Starting with an image in the lower right corner, you could flip it backwards to the lower left... then upside down to the upper left.... then forward to the upper right:
http://OpenProcessing.org/sketch/139280