Published
Edited
Apr 13, 2020
Genuary2024, Vera MolnárDroste effect, Genuary2024Genuary2022, ArchitectureGenuary2022, Destroy a square.Genuary2022, Fidenza challengeGenuary2022, spaceGenuary2022, Dithering (Floyd-Steinberg)Genuary2022, Draw 10,000 of somethingAlmost a SierpinskiKoch CurveUCB's logo built with 8,000 dotsCanvas, P5.js and circle packing (collision and cluster force) on a mapGenerative design Notebook 1: colours and squaresGenerative design Notebook 4: obtaining colour palettes from imagesGenerative design Notebook 6.1: shapes
Generative design Notebook 6.2: shapes
Generative design Notebook 7: alignment in a gridGeneralization of the Sierpinski triangle - FractalsGenerative design Notebook 5: colour palettes from rulesGeneralization of the Sierpinski triangle - Fractals v2BBC Coronavirus tribute: 1 Global FlowerBBC Coronavirus tribute: all countries (weekly)BBC Coronavirus tribute: all countries (daily)BBC Coronavirus Tribute: 1 Country, 1 FlowerBBC Coronavirus tribute: all countries (weekly & mobile)BBC Coronavirus Tribute - Grid of flowers#genuary 2021 ~ Monochrome gradients without lines#genuary 2021 ~ Increase the randomness along the Y-axis#genuary 2021 ~ One process grows, another process prunes#genuary 2021 ~ Draw a line...#genuary 2021 ~ Subdivision#genuary 2021 ~ Triangle subdivision#genuary 2021 ~ Do some golf!#genuary 2021 ~ Small areas of symmetry#genuary 2021 ~ Something Human#genuary 2021 ~ 3 loops#genuary 2021 ~ Rule 30#genuary 2021 ~ Rule 30Canvas, P5 and circle packing in a map
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
p5(sketch => {
const randomColour = object.colour;
sketch.setup = function() {
sketch.createCanvas(width, height);
sketch.colorMode(sketch.HSB, 360, 100, 100, 100);
sketch.noFill();
sketch.rect(0, 0, width, height);
};
sketch.draw = function() {
const t = new Date().getSeconds() / 2;
// loop every two seconds
if (t%4 == 0) {
// sketch.noLoop();
sketch.background(255, 5);

// number of vertex dependant on seconds
const circleResolution = randomIntFromInterval(2, 60); // if 0 seconds --> 2 points
const radius = randomIntFromInterval(0.5, width / 2); // if 0 seconds --> 2 points
const angle = sketch.TWO_PI / circleResolution;

sketch.strokeWeight(randomIntFromInterval(0.5, 2));
const randomThisColour = randomIntFromInterval(randomColour - 20, randomColour + 20);
const randomSaturation = randomIntFromInterval(80, 100);
const randomBrightness = randomIntFromInterval(60, 80);
const colour = sketch.color(randomThisColour, randomSaturation, randomBrightness);
sketch.stroke(colour);
// translate canvas to draw from the middle of it
sketch.translate(width / 2, height / 2);

sketch.beginShape();
for (var i = 0; i <= circleResolution; i++) {
const x = sketch.cos(180 - angle * i) * radius;
const y = sketch.sin(180 - angle * i) * radius;

// sketch.line(0, 0, x, y);
sketch.vertex(x, y);
}
sketch.endShape(sketch.CLOSE);
}

}
})
Insert cell
// from https://stackoverflow.com/questions/4959975/generate-random-number-between-two-numbers-in-javascript

function randomIntFromInterval(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
Insert cell
Insert cell
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