Skip to content

textureWrap()

Defines if textures repeat or draw once within a texture map. The two parameters are CLAMP (the default behavior) and REPEAT.

Examples

textureWrap example 1

local img

require("L5")

function setup()
  size(300, 300)
  img = loadImage("assets/flower.jpg")
  textureMode(NORMAL)
  windowTitle("textureWrap example")
  describe("The texture is applied and tiled or clamped to the custom shape")
end

function draw() 
  background(0)
  translate(width/2, height/2)
  rotate(map(mouseX, 0, width, -PI, PI))
  if mouseIsPressed then
    textureWrap(REPEAT)
  else 
    textureWrap(CLAMP)
  end

  beginShape()
  texture(img)
  vertex(-100, -100, 0, 0)
  vertex(100, -100, 2, 0)
  vertex(100, 100, 2, 2)
  vertex(-100, 100, 0, 2)
  endShape()
end

Syntax

textureWrap(wrap)

Parameters

wrap: Either CLAMP (default) or REPEAT.


This reference page contains content adapted from p5.js and Processing by p5.js Contributors and Processing Foundation, licensed under CC BY-NC-SA 4.0.