xxxxxxxxxx
42
/*
----- Coding Tutorial by Patt Vira -----
Name: Rainbow Pendulum Waves
Video Tutorial: https://youtu.be/WeSytBEVtL8
Connect with Patt: @pattvira
https://www.pattvira.com/
----------------------------------------
*/
let rainbows = []; let num = 29;
let r_mult = 10; let r0 = 30;
let period = 2000; let freq0 = 10;
let midiNotes = [108, 107, 105, 103, 101, 100, 98,
96, 95, 93, 91, 89, 88, 86,
84, 83, 81, 79, 77, 76, 74,
72, 71, 69, 67, 65, 64, 62, 60];
function setup() {
createCanvas(700, 400);
angleMode(DEGREES);
colorMode(HSB);
for (let i=0; i<num; i++) {
let r = r0 + (num - i) * r_mult;
let h = 200 + 100/num * i;
let note = midiNotes[i];
rainbows[i] = new Rainbow(i + freq0, r, h, note);
}
}
function draw() {
background(240, 150, 30);
translate(width/2, height);
for (let i=0; i<num; i++) {
rainbows[i].update();
rainbows[i].display();
}
}