lerp

def setup
  background(200)
  a = 20
  b = 80
  c = lerp(a, b, 0.2)
  d = lerp(a, b, 0.5)
  e = lerp(a, b, 0.8)

  y = 50

  strokeWeight(5)
  stroke(0)     # Draw the original points in black
  point(a, y)
  point(b, y)

  stroke(100)   # Draw the lerp points in gray
  point(c, y)
  point(d, y)
  point(e, y)
end

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

[p5.js] lerp

概要

2つの数値の中間にある数値を計算します。

書式

lerp(start, stop, amt)

引数

引数名内容備考オプションデフォルト値
start最初の数値
stop2番目の数値
amt中間度0~1

戻値

2つの数値の中間にある数値

備考

関連