LoginSignup
0
0

More than 3 years have passed since last update.

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

Last updated at Posted at 2020-10-20

このページでは「P5.js 日本語リファレンス」 の ambientMaterial関数を説明します。

ambientMaterial()

説明文

オブジェクトに使用するマテリアル(素材)の反射色を定義します。環境光(ambientLight)によって反射状況が変わります。たとえば、環境光に赤が含まれているとき、マテリアルに赤が含まれていればオブジェクトは光を反射します。逆にマテリアルに赤が含まれていなければオブジェクトは光を反射しません。

構文

ambientMaterial(v1, [v2], [v3])

ambientMaterial(color)

パラメタ

gray 値を指定するとき

  • v1
    Number:グレー値

RGB または HSB を指定するとき

  • v1
    Number:赤または色相値(Hue)

  • v2
    Number:緑または彩度値(Saturation)

  • v3
    Number:青または明度値(Brightness)

  • color
    Number[] | 文字列 | p5.color:color、color Array または CSS color 文字列

例1

// 環境光(ambientLight)は緑です。左側の box は緑を含ま
// ないので光を反射しませんが、右の box は緑を含むので
// 光を反射します。
function setup() {
  createCanvas(300, 300, WEBGL);
//  colorMode(RGB);
}

function draw() {
  background(100);
  ambientLight(0, 255, 0); // 緑の環境光

  translate(-30, 0);
  ambientMaterial(255, 0, 255); //緑色を含まない
  box(50, 50, 50); // 左側のbox

  translate(60, 0);
  ambientMaterial(255, 200, 255); //緑色を含む
  box(50, 50, 50); // 右側のbox
}

実行結果

著作権

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