我想知道是否有可能从全局变量中删除整个P5(或其他任何框架工作/库),并将其放入一个全局变量中,而不实际编辑P5.JS项目--它是self。
就像JQuery对$符号所做的一样。因此,您实际上可以声明名为point的变量,或者是mouseX变量,这些变量是P5变量,并且将与变量发生冲突。
所以,例如
window.P5 = (some way to get the all instance form the P5);
let point = {myPont:..., props....};
let canvasPoint = P5.point(...);发布于 2017-10-08 00:10:04
好的。使用实例模式。
var s = function( sketch ) {
var x = 100;
var y = 100;
sketch.setup = function() {
sketch.createCanvas(200, 200);
};
sketch.draw = function() {
sketch.background(0);
sketch.fill(255);
sketch.rect(x,y,50,50);
};
};
var myp5 = new p5(s);https://stackoverflow.com/questions/46626297
复制相似问题