[][src]Static p5_sys::global::textureWrap

pub static textureWrap: TextureWrapInternalType

Sets the global texture wrapping mode. This controls how textures behave when their uv's go outside of the 0 - 1 range. There are three options: CLAMP, REPEAT, and MIRROR.

CLAMP causes the pixels at the edge of the texture to extend to the bounds REPEAT causes the texture to tile repeatedly until reaching the bounds MIRROR works similarly to REPEAT but it flips the texture with every new tile

REPEAT & MIRROR are only available if the texture is a power of two size (128, 256, 512, 1024, etc.).

This method will affect all textures in your sketch until a subsequent textureWrap call is made.

If only one argument is provided, it will be applied to both the horizontal and vertical axes.

Examples

let img;
function preload() {
  img = loadImage('assets/rockies128.jpg');
}

function setup() {
  createCanvas(100, 100, WEBGL);
  textureWrap(MIRROR);
}

function draw() {
  background(0);

  let dX = mouseX;
  let dY = mouseY;

  let u = lerp(1.0, 2.0, dX);
  let v = lerp(1.0, 2.0, dY);

  scale(width / 2);

  texture(img);

  beginShape(TRIANGLES);
  vertex(-1, -1, 0, 0, 0);
  vertex(1, -1, 0, u, 0);
  vertex(1, 1, 0, u, v);

  vertex(1, 1, 0, u, v);
  vertex(-1, 1, 0, 0, v);
  vertex(-1, -1, 0, 0, 0);
  endShape();
}

Parameters

wrapX either CLAMP, REPEAT, or MIRROR

wrapY? either CLAMP, REPEAT, or MIRROR