Loading...
Logo
Processing Forum

Mirroring image

in Core Library Questions  •  2 years ago  
Is this possible (both horizontal and vertical mirroring) for images?

Replies(1)

Re: Mirroring image

2 years ago
You can do it with scale. If you remember to also translate and scale back before doing other stuff.

Try something likes this:

Copy code
  1. PImage img = loadImage("image.png");
  2. // Flip about x-axis
  3. pushMatrix();
  4. translate(0, img.height);
  5. scale(1, -1);
  6. image(img, 0, 0);
  7. popMatrix();
  8. //Flip about y-axis
  9. pushMatrix();
  10. translate(0, img.height);
  11. scale(1, -1);
  12. image(img, 0, 0);
  13. popMatrix();
  14. // Flip around both
  15. pushMatrix();
  16. translate(img.width, img.height);
  17. scale(-1, -1);
  18. image(img, 0, 0);
  19. popMatrix();