color

概要

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

[p5.js] color

サンプル

def setup
  background(220)
  c = color(255, 204, 0)
  fill(c)
  noStroke
  rect(30, 20, 55, 55)
end
def setup
  background(220)
  c = color(255, 204, 0)
  fill(c)
  noStroke
  ellipse(25, 25, 80, 80)
  # Using only one value generates a grayscale value.
  c = color(65)
  fill(c)
  ellipse(75, 75, 80, 80)
end
def setup
  # You can use named SVG & CSS colors
  background(220)
  c = color('magenta')
  fill(c)
  noStroke
  rect(20, 20, 60, 60)
end
def setup
  # Example of hex color codes
  background(220)
  noStroke
  c = color('#0f0')
  fill(c)
  rect(0, 10, 45, 80)
  c = color('#00ff00')
  fill(c)
  rect(55, 10, 45, 80)
end
def setup
  background(220)
  noStroke
  c = color('rgb(0, 0, 255)')
  fill(c)
  rect(10, 10, 35, 35)
  c = color('rgb(0%, 0%, 100%)')
  fill(c)
  rect(55, 10, 35, 35)
  c = color('rgba(0, 0, 255, 1)')
  fill(c)
  rect(10, 55, 35, 35)
  c = color('rgba(0%, 0%, 100%, 1)')
  fill(c)
  rect(55, 55, 35, 35)
end
def setup
  # HSL color can also be specified by value
  background(220)
  c = color('hsl(160, 100%, 50%)')
  noStroke()
  fill(c)
  rect(0, 10, 45, 80)
  c = color('hsla(160, 100%, 50%, 0.5)')
  fill(c)
  rect(55, 10, 45, 80)
end
def setup
  # HSB color can also be specified
  background(220)
  c = color('hsb(160, 100%, 50%)')
  noStroke
  fill(c)
  rect(0, 10, 45, 80)
  c = color('hsba(160, 100%, 50%, 0.5)')
  fill(c)
  rect(55, 10, 45, 80)
end
def setup
  background(220)
  noStroke
  c = color(50, 55, 100)
  fill(c)
  rect(0, 10, 45, 80)
  colorMode(HSB, 100)
  c = color(50, 55, 100)
  fill(c)
  rect(55, 10, 45, 80)
end

構文

戻値