finalize the blogpost

This commit is contained in:
Osman Faruk Bayram 2024-10-31 19:47:36 +03:00
parent 32cb78a67e
commit 24ede9e0da
5 changed files with 118 additions and 70 deletions

View file

@ -1,6 +1,7 @@
function setup() {
let mycanvas = createCanvas(400, 400);
mycanvas.parent('hello-world');
background(0);
}
function draw() {
fill(255);

View file

@ -1,55 +0,0 @@
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');