<
I have created 4 images from pixels in a grid format. I want to flip two images in x and y axis. Rotate one image on its own places and keep one as it is. Please help.
PImage source, imgFlipxaxis, imgFlipyaxis, imgFlipxyaxis;
PFont font;
float r, angle = 0;
void setup() {
frameRate(24);
size(900, 600);
source = loadImage(“f.png”);
imgFlipxaxis= createImage(source.width, source.height, RGB);
imgFlipyaxis= createImage(source.width, source.height, RGB);
imgFlipxyaxis= createImage(source.width, source.height, RGB);
}
void draw(){
color p01;
float r01=0, g01=0, b01=0;
background(150,150,150);
//lights();
image(source, 0, 0);
image(imgFlipxaxis, 0, 300);
image(imgFlipyaxis, 300, 300);
source.loadPixels();
imgFlipxaxis.loadPixels();
imgFlipyaxis.loadPixels();
imgFlipxyaxis.loadPixels();
for (int x = 0; x < source.width; x++) {
for (int y = 0; y < source.height; y++ ) {
int loc = x + y*source.width;
p01 = source.pixels[loc]; // Read color from source01
r01 = red(p01);
g01 = green(p01);
b01 = blue(p01);
imgFlipxaxis.pixels[loc] = color(r01,g01,b01);
imgFlipyaxis.pixels[loc] = color(r01,g01,b01);
imgFlipxyaxis.pixels[loc] = color(r01,g01,b01);
}}
int flipXindex = 0;
for (int y = source.height-1; y>= 0; y–) {
for(int x = 0; x < source.width; x++) {
imgFlipxaxis.pixels[flipXindex++] = source.pixels[ y*source.width + x];
}
}
int flipYindex = 0;
for (int x = source.width+1; x<= 0; x++) {
for(int y = 0; y > source.height; y–) {
imgFlipyaxis.pixels[flipYindex++] = source.pixels[ x*source.height + y];
}
}
{
angle += 0.01;
pushMatrix();
translate(width/2, height/2);
scale(0.5);
rotate(angle);
image(imgFlipxyaxis, 600, 300);
popMatrix();
}
source.updatePixels();
imgFlipxaxis.updatePixels();
imgFlipyaxis.updatePixels();
imgFlipxyaxis.updatePixels();
}