LoginSignup
4
4

More than 5 years have passed since last update.

Pixi.js v4で自前のcanvas使う

Posted at

自分用メモ

公式みるとcanvas作るときにはこんな感じ

// Create the application
const app = new PIXI.Application();

// Add the view to the DOM
document.body.appendChild(app.view);

これでbodyにcanvasタグ追加してくれる。
でもcanvasにクラスとか振れない、optionにも直接それっぽいのがないので、
optionの中のviewを使った。

<canvas class="any-class" id="js-canvas"></canvas>

それをnew の際のoptionに渡すと、クラスが振られたcanvasが生成される

// optionを渡す
const app = new PIXI.Application({
    view : document.getElementById("js-canvas")
});

// これは一緒
document.body.appendChild(app.view);

こんなんでいけた

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