LoginSignup
0
1

More than 3 years have passed since last update.

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

Last updated at Posted at 2020-05-11

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

createCanvas()

説明文

スケッチにキャンバス要素を作成してその寸法をピクセル単位で設定します。このメソッドは、セットアップの開始時に一度だけ呼び出す必要があります。スケッチで createCanvas() を複数回呼び出すと非常に予測できない動作が発生します。複数の描画キャンバスが必要な場合は createGraphics を使用できます(デフォルトでは非表示ですが表示できます)

システム変数 width と height は, この関数に渡されるパラメータによって設定されます。 createCanvas() を使用しない場合、ウィンドウのデフォルトサイズは100x100ピクセルになります。

キャンバスを配置するその他の方法については, キャンバスの配置Wikiページを参照してください。

構文

createCanvas(w, h, [renderer])

パラメタ

  • w

    Number:キャンバスの幅

  • h

    Number:キャンバスの高さ

  • renderer

    定数:P2D または WEBGL(オプション)

戻り値

p5.Renderer

function setup() {
  createCanvas(100, 50);
  background(200, 250, 0); // 黄緑色
  line(0, 0, width, height);
}

実行結果

createCanvas.png

著作権

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
1
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
1