fill

def setup
  # Grayscale integer value
  background(220)
  fill(51)
  rect(20, 20, 60, 60)
end
def setup
  # R, G & B integer values
  background(220)
  fill(255, 204, 0)
  rect(20, 20, 60, 60)
end
def setup
  # H, S & B integer values
  background(220)
  colorMode(HSB)
  fill(255, 204, 100)
  rect(20, 20, 60, 60)
end
def setup
  # Named SVG/CSS color string
  background(220)
  fill('red')
  rect(20, 20, 60, 60)
end
def setup
  # three-digit hexadecimal RGB notation
  background(220)
  fill('#fae')
  rect(20, 20, 60, 60)
end
def setup
  # six-digit hexadecimal RGB notation
  background(220)
  fill('#222222')
  rect(20, 20, 60, 60)
end
def setup
  # integer RGB notation
  background(220)
  fill('rgb(0, 255, 0)')
  rect(20, 20, 60, 60)
end
def setup
  # integer RGBA notation
  background(220)
  fill('rgba(0, 255, 0, 0.25)')
  rect(20, 20, 60, 60)
end
def setup
  # percentage RGB notation
  background(220)
  fill('rgb(100%, 0%, 10%)')
  rect(20, 20, 60, 60)
end
def setup
  # percentage RGBA notation
  background(220)
  fill('rgba(100%, 0%, 100%, 0.5)')
  rect(20, 20, 60, 60)
end
def setup
  # p5 Color object
  background(220)
  fill(color(0, 0, 255))
  rect(20, 20, 60, 60)
end

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

[p5.js] fill

概要

図形や文字の塗りつぶし色を設定します。

書式

fill(gray [, a])
fill(v1, v2, v3 [, a])
fill(values)
fill(colorstring)
fill(color)

引数

引数名内容備考オプションデフォルト値
grayグレースケール0~255
v1赤 または 色相0~255
colorModeの設定に依存
v2緑 または 彩度0~255
colorModeの設定に依存
v3青 または 輝度(明度)0~255
colorModeの設定に依存
values配列[v1, v2, v3, 透明度]
colorModeの設定に依存
colorstring色文字列
colorp5.Colorオブジェクト
a透明度0~255
(0 : 完全な透明)
colorModeの設定に依存
RGBモード : 255
HSLモード/HSBモード : 1

戻値

なし

備考

関連

colorMode
色(カラー)