Files
processing4/java/examples/Topics/Textures/TextureQuad/TextureQuad.pde
Casey Reas 5b0214704c
2011-09-18 06:31:29 +00:00

32 lines
722 B
Plaintext

/**
* Texture Quad.
*
* Load an image and draw it onto a quad. The texture() function sets
* the texture image. The vertex() function maps the image to the geometry.
*/
// The next line is needed if running in JavaScript Mode with Processing.js
/* @pjs preload="berlin-1.jpg"; */
PImage img;
void setup() {
size(640, 360, P3D);
img = loadImage("berlin-1.jpg");
noStroke();
}
void draw() {
background(0);
translate(width / 2, height / 2);
rotateY(map(mouseX, 0, width, -PI, PI));
rotateZ(PI/6);
beginShape();
texture(img);
vertex(-100, -100, 0, 0, 0);
vertex(100, -100, 0, img.width, 0);
vertex(100, 100, 0, img.width, img.height);
vertex(-100, 100, 0, 0, img.height);
endShape();
}