|
Sorry if it's a dumb question, I'm pretty newbie... Btw, when I try to just use it - nothing happens, when I try to use it in node.js mode - I get strange errors. If it's not possible yet - it would be a nice addition, making from znote/notebookJS a nice sketchbook for generative art. |
Replies: 3 comments 2 replies
|
Hi @lsooxlla8 👋, It's a good question! I never test to run P5. Some 3D lib like D3 could be hard to run into this embedded environment due to the complex ESM modules. I open a task right now to see if I need to update Znote or if I just need to provide an example to load P5. Anthony |
|
After a quick test, I run P5.js without modification 😊 Below the example: import p5 from 'p5';
const s = p => {
let x = 100;
let y = 100;
p.setup = function() {
p.createCanvas(700, 410);
};
p.draw = function() {
p.background(0);
p.fill(255);
p.rect(x, y, 50, 50);
};
};
htmlEl.innerHTML = ''; // reset result div before rerun code
const P5 = new p5(s, htmlEl); // htmlEl is the HTML element injected by Znote as an entry point for the result of your code block |

After a quick test, I run P5.js without modification 😊
But this is a quick test and I guess there are probably issues with the P5 dependencies (maybe).
If you have any problem, share me your examples to help me identify the issues (if there is)
Below the example:
Try to install P5 npm package:
npm i -S p5