是否可以像 JQuery 那样将 P5 封装到一个全局变量中 $
Is it possible to encapsulate P5 into a global variable like JQuery does with $
我想知道是否可以从全局变量中删除整个 P5(或任何其他帧 work/lib)
并将其放入一个全局变量中,而无需实际编辑 P5.JS 项目本身。
就像 JQuery 对 $ 符号所做的一样。所以你实际上可以声明名为 point 或 mouseX 的变量,它们是 P5 变量并且会与你的变量冲突。
例如
window.P5 = (some way to get the all instance form the P5);
let point = {myPont:..., props....};
let canvasPoint = P5.point(...);
当然可以。使用 instance mode.
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);
我想知道是否可以从全局变量中删除整个 P5(或任何其他帧 work/lib) 并将其放入一个全局变量中,而无需实际编辑 P5.JS 项目本身。
就像 JQuery 对 $ 符号所做的一样。所以你实际上可以声明名为 point 或 mouseX 的变量,它们是 P5 变量并且会与你的变量冲突。
例如
window.P5 = (some way to get the all instance form the P5);
let point = {myPont:..., props....};
let canvasPoint = P5.point(...);
当然可以。使用 instance mode.
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);