Angular9与WEBGL一起使用p5.js

时间:2020-05-23 17:57:58

标签: p5.js angular9

我已经成功将p5导入了angular 9

import p5 from 'p5' //gives error, but somehow works

[...]

export class DrawEngineComponent implements OnInit {

  private p5;

  constructor() { }

  ngOnInit() {
    this.createCanvas();
  }

  private createCanvas() {
    this.p5 = new p5(this.sketch);
  }

  private sketch(p: any) {

    p.setup = () => {
      p.createCanvas(700, 600, ).parent('engine');
    };

    p.draw = () => {
      p.background(255, 0, 0);
      p.fill(0);
      p.rect(p.width / 2, p.height / 2, 50, 50);

    }

  }

}

在p5官方网站上阅读"createCanvas"参考文献时,我注意到有一个用于导入WEBGL的可选参数。

我找不到有关如何将此“ renderer”参数导入Angular9以在p5中使用的参考。

0 个答案:

没有答案