-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add an P5js element #858
Comments
I also think that a P5js editor would also be a worthwhile addition. This should behave similar to the onlineide-element (https://hyperbook.openpatch.org/elements/online-ide). So maybe we need a p5js player and a p5js editor element. |
It seems like P5js will move to https://openprocessing.org. Maybe it would make sense to support the new site as well (or maybe only the new one). |
I did some experiments on how to implement this feature. p5js works normally in global mode and assumes that only one sketch is present. Thus, you can call function setup() {
createCanvas(1720, 200);
background(0);
};
function draw() {
fill(255, 0, 0);
circle(mouseX, mouseY, 50);
};
} To show multiple sketches on a page, I have found two options:
function sketch2(p) {
p.setup = function () {
p.createCanvas(1720, 200);
p.background(0);
};
p.draw = function () {
p.fill(255, 0, 0);
p.circle(p.mouseX, p.mouseY, 50);
};
}
I prefer the iframe, because it gives us all the flexibility, but keeps writing p5js file simple. |
I created an initial version #897 |
I would like a native P5js element to easily embed a P5js canvas into a hyberbook.
This can be done with the embed element, but I assume this could be fairly easy to add and should be in the spirit of other elements like the online ide and mermaid.
The text was updated successfully, but these errors were encountered: