We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Reflect 180 degrees, easy
Page Index Toggle Pages: 1
Reflect 180 degrees, easy? (Read 814 times)
Reflect 180 degrees, easy?
Aug 23rd, 2009, 10:58am
 
I have a quad shape that I would like to reflect (like a mirror), while still keeping the original shape?
Is this possible without making a new quad() shape?
Re: Reflect 180 degrees, easy?
Reply #1 - Aug 23rd, 2009, 1:25pm
 
You can do the trick by copying the pixels line by line :

Quote:
background(255);
quad(20,1,50,20,60,48,20,40);
loadPixels();
for (int y = 0; y < height/2; y++) {
  for (int x = 0; x < width; x++) {
    pixels[(height-1-y)*width+x] = pixels[y*width+x];
  }
}
updatePixels();
Re: Reflect 180 degrees, easy?
Reply #2 - Aug 23rd, 2009, 8:21pm
 
Or, if you're using P3D or OPENGL mode, you could use:

quad(your quad points);

pushMatrix();
translate(xshift, yshift); // move somewhere else
rotateY(PI): // spin 180° on the Y axis (backwards), and/or:
rotateX(PI): // spin 180° on the X axis (upside-down)
quad(your quad points);
popMatrix();
Page Index Toggle Pages: 1