We are about to switch to a new forum software. Until then we have removed the registration on this forum.
In one of my previous question it was suggested that I use beginShape(QUADS) to display an image. I was unsure what the third and fourth arguments in the vertex(); were after that, so I decided to experiment. This is my code, but it does not display an image at all.
PImage blob;
void setup() {
size(800,800,P2D);
blob = loadImage("ASD.jpg");
}
void draw() {
background(255);
beginShape(QUADS);
texture(blob);
noStroke();
vertex(100,100,0,0);
vertex(100,200,0,1);
vertex(200,200,1,1);
vertex(200,100,1,0);
endShape();
}
If someone can explain to me what the 0s and 1s mean as the 3rd and 4th arguments in the vertexes of a beginShape(QUADS) function, that would be awesome!
Answers
https://www.processing.org/reference/vertex_.html
u: float: horizontal coordinate for the texture mapping
v: float: vertical coordinate for the texture mapping
You need to set the texture mode to normalized.
That is probably displaying a quad but you're texturing it with the top left pixel of the image
According to the example, the u and v stand for pixel numbers. But the example that koogs gave in my previous question used 1s and 0s. What do the 0s and 1s stand for?
relation here could mean 1 = 100 % and 0 = automatic.
reference for vertex
This function is also used to map a texture onto geometry. The texture() function declares the texture to apply to the geometry and the u and v coordinates set define the mapping of this texture to the form. By default, the coordinates used for u and v are specified in relation to the image's size in pixels, but this relation can be changed with textureMode().
https://www.processing.org/reference/vertex_.html
Also see reference textureMode
https://www.processing.org/reference/textureMode_.html