Код: Выделить всё
p5.js Sketch
p5.js Sketch
function setup() {
createCanvas(400, 400);
}
function draw(){
background(220);
ellipse(mouseX, mouseY, 50, 50);
}
new p5(function(sketch) {
sketch.setup = setup;
sketch.draw = draw;
}, 'sketch-container');
Код: Выделить всё
function setup() {
createCanvas(400, 400);
}
function draw() {
if (mouseIsPressed) {
fill(0);
} else {
fill(255);
}
ellipse(mouseX, mouseY, 80, 80);
}
Код: Выделить всё
import { App, Editor, MarkdownView, Modal, Notice, Plugin, PluginSettingTab, Setting } from 'obsidian';
import p5 from "p5";
export default class MyPlugin extends Plugin {
async onload() {
this.registerMarkdownCodeBlockProcessor('p5js', (source, el) => {
const code = source.trim();
// Replace the code block with a basic HTML structure
el.innerHTML = `
p5.js Sketch
p5.js Sketch
${code}
new p5(function(sketch) {
sketch.setup = setup;
sketch.draw = draw;
}, 'sketch-container');
`;
});
}
}
< /p>
Подробнее здесь: https://stackoverflow.com/questions/760 ... -extension
Мобильная версия