For Codevember, I wanted to try out P5.js – a very cool JavaScript library created by Lauren McCarthy and based on the principles of Processing. It’s actually very very similar to Processing, so it turned out to be quite easy to get used to! It’s a really cool and simple way to make interactive elements for your website.
Even so, I failed miserably at doing Codevember as I only made sketches for the first 5 days. Oh well. This was the first one and the one I like best (code below):
function setup() {
createCanvas(1000, 500, WEBGL)
}
function draw() {
background(0);
basicMaterial(20);
translate(0, 0, -200)
rotateX(frameCount * 0.01);
rotateY(frameCount * 0.01);
torus(15, 2);
recur(13, 14, 40);
}
function mousePressed() {
var fs = fullscreen();
fullscreen(!fs);
}
function recur(b, s, col) {
if (b > 1) {
basicMaterial(col);
translate(0, 0, 20)
rotateX(frameCount * 0.01);
rotateY(frameCount * 0.01);
torus(s, 2);
recur(b – 1, s – 1, col + 20)
}
}