map

概要

p5.jsリファレンス(参考情報)

[p5.js] map

サンプル

def setup
  background(220)
  value = 25
  m = map(value, 0, 100, 0, width)
  ellipse(m, 50, 10, 10)
end
def setup
  noStroke
end

def draw
  background(204)
  x1 = map(mouseX, 0, width, 25, 75)
  ellipse(x1, 25, 25, 25)
  # This ellipse is constrained to the 0-100 range
  # after setting withinBounds to true
  x2 = map(mouseX, 0, width, 0, 100, true)
  ellipse(x2, 75, 25, 25)
end

構文

戻値