[−][src]Static p5_sys::global::texture
pub static texture: TextureInternalType
Texture for geometry. You can view other possible materials in this example.
Examples
let img;
function preload() {
img = loadImage('assets/laDefense.jpg');
}
function setup() {
createCanvas(100, 100, WEBGL);
}
function draw() {
background(0);
rotateZ(frameCount * 0.01);
rotateX(frameCount * 0.01);
rotateY(frameCount * 0.01);
//pass image as texture
texture(img);
box(200, 200, 200);
}
let pg;
function setup() {
createCanvas(100, 100, WEBGL);
pg = createGraphics(200, 200);
pg.textSize(75);
}
function draw() {
background(0);
pg.background(255);
pg.text('hello!', 0, 100);
//pass image as texture
texture(pg);
rotateX(0.5);
noStroke();
plane(50);
}
let vid;
function preload() {
vid = createVideo('assets/fingers.mov');
vid.hide();
}
function setup() {
createCanvas(100, 100, WEBGL);
}
function draw() {
background(0);
//pass video frame as texture
texture(vid);
rect(-40, -40, 80, 80);
}
function mousePressed() {
vid.loop();
}
Parameters
tex
2-dimensional graphics
to render as texture