0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

P5.js 日本語リファレンス(alpha)

Last updated at Posted at 2020-04-30

このページでは[「P5.js 日本語リファレンス」] (https://qiita.com/bit0101/items/91818244dc26c767a0fe) の alpha関数を説明します。

alpha()

説明文

指定した色からアルファ値(透明度)を取得します。

構文

alpha(color)

パラメタ

  • color
    p5.Color | Number[ ] | String:p5.Colorオブジェクト、カラーコンポーネント、CSSカラー

戻り値

Number:アルファ値

function draw() {
  background(220);
  noStroke();

  colorMode(RGB, 255); // カラーモードをRGBに設定
  let c1 = color(0, 255, 0, 180); // RGBで緑色を設定
  fill(c1);
  rect(15, 15, 35, 70);
  let val1 = alpha(c1); // アルファ値180を取得する
  fill(val1);
  rect(50, 15, 35, 70);

  colorMode(HSB, 100); // カラーモードをHSBに設定
  let c2 = color(100, 100, 100, 70); // HSBで赤色を設定
  fill(c2);
  rect(100, 15, 35, 70);
  let val2 = alpha(c2); // アルファ値70を取得する
  fill(val2);
  rect(135, 15, 35, 70);
}

実行結果

alpha.JPG

著作権

p5.js was created by Lauren McCarthy and is developed by a community of collaborators, with support from the Processing Foundation and NYU ITP. Identity and graphic design by Jerel Johnson.

ライセンス

Creative Commons(CC BY-NC-SA 4.0) に従います。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?