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 日本語リファレンス(resizeCanvas)

Last updated at Posted at 2020-05-11

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

resizeCanvas()

説明文

キャンバスを指定した幅と高さにサイズ変更します。キャンバスがクリアされ、draw() がすぐに呼び出され、スケッチがサイズ変更されたキャンバスに自分自身を再レンダリングできるようになります。

構文

resizeCanvas(w, h, [noRedraw])

パラメタ

  • w
    Number:キャンバスの幅

  • h
    Number:キャンバスの高さ

  • noRedraw
    Boolean:キャンバスをすぐに再描画しない(オプション)

function setup() {
  createCanvas(windowWidth, windowHeight);
}

function draw() {
  if (frameCount < 200){
    // frameCount に合わせてキャンバスサイズを変更する
    resizeCanvas(frameCount, frameCount);
    background(0, 100, 200);
  }
}

実行結果

著作権

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?