lerpColor

def setup
  colorMode(RGB)
  stroke(255)
  background(51)
  from = color(218, 165, 32)
  to   = color(72, 61, 139)

  colorMode(RGB) # Try changing to HSB.
  interA = lerpColor(from, to, 0.33)
  interB = lerpColor(from, to, 0.66)

  fill(from)
  rect(10, 20, 20, 60)

  fill(interA)
  rect(30, 20, 20, 60)

  fill(interB)
  rect(50, 20, 20, 60)

  fill(to)
  rect(70, 20, 20, 60)
end

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

[p5.js] lerpColor

概要

2つの色の中間にある色を生成します。

書式

lerpColor(c1, c2, amt)

引数

引数名内容備考オプションデフォルト値
c1色1p5.Colorオブジェクト
c2色2p5.Colorオブジェクト
amt中間度0~1

戻値

p5.Colorオブジェクト

備考

・引数 amdの値が小さいほど「色1」に近い色、引数 amdの値が大きいほど「色2」に近い色になります。

関連