Public
Edited
Jul 28, 2023
Insert cell
Insert cell
class Rectangle {
constructor(height, width) {
this.height = height;
this.width = width;
}
}
Insert cell
class Bee {
constructor(x, y, r) {
this.x = x;
this.y = y;
this.r = r;
this.wings = false;
this.stripes = 4;
this.seed = Math.random()*1000000
}

fly(sketch) {
this.wings = !this.wings;
}

show(sketch){
sketch.translate(this.x, this.y)
sketch.fill('yellow')
sketch.circle(0,0,this.r);
for(let i = 0; i<this.stripes; i++) {
sketch.fill('black')
sketch.rect(0,0,this.r/this.stripes/2, this.r)
}
//eyes
}
}
Insert cell
p5((sketch) => {
sketch.setup = function () {
sketch.createCanvas(width, 300);
sketch.textAlign(sketch.CENTER);
sketch.textFont("sans-serif");
sketch.textStyle(sketch.BOLD);
};
sketch.draw = function () {
sketch.translate((sketch.millis() / 10) % sketch.width, sketch.height / 2);
sketch.background("red");
sketch.fill("blue");
rects.forEach((d) => {
sketch.rect(d.width, d.height, 10, 10);
});
sketch.text("ciao", 0, 0);
};
})
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more