diff --git a/public/scripts/input-output.js b/public/scripts/input-output.js deleted file mode 100644 index 044fc81..0000000 --- a/public/scripts/input-output.js +++ /dev/null @@ -1,32 +0,0 @@ -function setup() { - let canvas = createCanvas(710, 400, WEBGL); - canvas.parent('input-output'); - angleMode(DEGREES); - strokeWeight(5); - noFill(); - stroke(32, 8, 64); -} - -function draw() { - background(250, 180, 200); - - // Call every frame to adjust camera based on mouse/touch - orbitControl(); - - // Rotate rings in a half circle to create a sphere of cubes - for (let zAngle = 0; zAngle < 180; zAngle += 30) { - // Rotate cubes in a full circle to create a ring of cubes - for (let xAngle = 0; xAngle < 360; xAngle += 30) { - push(); - - // Rotate from center of sphere - rotateZ(zAngle); - rotateX(xAngle); - - // Then translate down 400 units - translate(0, 400, 0); - box(); - pop(); - } - } -} \ No newline at end of file diff --git a/public/scripts/multi-sketch.js b/public/scripts/multi-sketch.js new file mode 100644 index 0000000..6a92b2f --- /dev/null +++ b/public/scripts/multi-sketch.js @@ -0,0 +1,55 @@ +let canvas1 = function ( p ) { + p.setup = function() { + p.createCanvas(710, 400, p.WEBGL); + p.angleMode(p.DEGREES); + p.strokeWeight(5); + p.noFill(); + p.stroke(32, 8, 64); + } + + p.draw = function() { + p.background(250, 180, 200); + + // Call every frame to adjust camera based on mouse/touch + p.orbitControl(); + + // Rotate rings in a half circle to create a sphere of cubes + for (let zAngle = 0; zAngle < 180; zAngle += 30) { + // Rotate cubes in a full circle to create a ring of cubes + for (let xAngle = 0; xAngle < 360; xAngle += 30) { + p.push(); + + // Rotate from center of sphere + p.rotateZ(zAngle); + p.rotateX(xAngle); + + // Then translate down 400 units + p.translate(0, 400, 0); + p.box(); + p.pop(); + } + } + } +}; + +let canvas2 = function ( p ) { + + + p.setup = function() { + p.createCanvas(710, 400); + p.background(250, 180, 200); + } + + p.draw = function() { + // draw a circle at the mouse position + p.fill(255, 0, 0); + p.stroke(0); + p.strokeWeight(0); + p.ellipse(p.mouseX, p.mouseY, 80, 80); + + } +} + + +var mycanvas1 = new p5(canvas1, 'canvas1'); +var myp5 = new p5(canvas2, 'canvas2'); diff --git a/src/components/P5Sketch.astro b/src/components/P5Sketch.astro index 46a1ff2..77bc46b 100644 --- a/src/components/P5Sketch.astro +++ b/src/components/P5Sketch.astro @@ -1,15 +1,9 @@ --- -const { sketch_path, sketch_name, figure_id, sketch_description } = Astro.props; -// https://github.com/osbm/osbm.dev/blob/main/ + sketch_path(first 3 characters removed) -const sketch_url = 'https://github.com/osbm/osbm.dev/blob/main/' + sketch_path.slice(3); - +const { sketch_path, canvas_id, figure_id, sketch_description } = Astro.props; +const sketch_url = 'https://github.com/osbm/osbm.dev/blob/main/' + sketch_path; --- - - - -
Figure {figure_id}: {sketch_description} Sketch source
diff --git a/src/content/blog/blog-with-multi-p5js.mdx b/src/content/blog/blog-with-multi-p5js.mdx
new file mode 100644
index 0000000..164d049
--- /dev/null
+++ b/src/content/blog/blog-with-multi-p5js.mdx
@@ -0,0 +1,23 @@
+---
+title: 'Third post'
+description: 'First post of this website that tests many things'
+pubDate: '2024-10-29'
+includes_p5js: True
+p5_script_path: '../../scripts/multi-sketch.js'
+---
+
+import P5Sketch from '../../components/P5Sketch.astro';
+
+Before first Canvas
+
+