How to move an image including horizontal and vertical inversion

Hello,

My aim is to get the same behavior than line(x1, y1, x2, y2) but with a PNG image image(img, x1, y1, x2, y2) using the imageMode(CORNERS);

My PNG image have a transparent background and the line go from the upper-left corner to the bottom-right corner.

This point requires the inversion of the image when the x2, y2 coordinates are lower than x1, y1. And here is my problem because I don’t know how to get this inversion. The image is always in the same “order”.

I have a small sketch to figure all of that i necessary.

Thank you !

You can use https://processing.org/reference/scale_.html

pushMatrix();
scale(-1, 1);//or something like that
image(...
popMatrix();

Thank you a lot.
I will check this way as soon as possible.

Hello,

Consider examples here:
https://processing.org/reference/vertex_.html

I modified code from the above link:

//https://processing.org/reference/vertex_.html

size(512, 256, P3D);
PImage img = loadImage("hiclipart.com.png");

noStroke();
background(0);

beginShape();
texture(img);
tint(255, 255, 0);
// "laDefense.jpg" is 100x100 pixels in size so
// the values 0 and 100 are used for the
// parameters "u" and "v" to map it directly
// to the vertex points
vertex(0, 0,     0, 0);
vertex(255, 0,   255, 0);
vertex(255, 255, 255, 255);
vertex(0, 255,   0, 255);
endShape();

translate(256, 0, 0);
  
beginShape();
texture(img);
tint(0, 255, 0);
// "laDefense.jpg" is 100x100 pixels in size so
// the values 0 and 100 are used for the
// parameters "u" and "v" to map it directly
// to the vertex points
vertex(0, 0,     255, 255);
vertex(255, 0,   255, 0);
vertex(255, 255, 0, 0);
vertex(0, 255,   0, 255);
endShape();  

You will have to modify u, v mapping to suit your needs.

Rename to test.png:
hiclipart.com

Output:
image