diff --git a/w3_2_functions/index.html b/w3_2_functions/index.html new file mode 100644 index 0000000..d8a9bfa --- /dev/null +++ b/w3_2_functions/index.html @@ -0,0 +1,21 @@ + + +
+ + + + + + + + + + + + diff --git a/w3_2_functions/sketch.js b/w3_2_functions/sketch.js new file mode 100644 index 0000000..dbea120 --- /dev/null +++ b/w3_2_functions/sketch.js @@ -0,0 +1,57 @@ +// Main +const N = 10; +let strips = []; + +function setup() { + createCanvas(400, 300); + strips = createStrips(N); +} + +function draw() { + background(0); + noStroke(); + const stripHeight = height / strips.length; + for (let i = 0; i < strips.length; i++) { + // draw the strips + // const r = ... + } +} + +// HELPERS + +/** + * + * @typedef {{red:number, green:number, blue:number}} Color + */ + +/** + * createRndColorStrip + * @returns Color + */ +function createRndColorStrip() { + return { + red: Math.floor(Math.random() * 255), + green: Math.floor(Math.random() * 255), + blue: Math.floor(Math.random() * 255), + }; +} + +/** + * getLuminance -- get luminance given an array of Color + * @param {Color} strip + * @returns number + */ +function getLuminance(strip) { + // PLACEHOLDER - return the luminance of the strip + return 0; +} + +/** + * createStrips -- create an array of random colors + * @param {number} n + * @returns Color[] + */ +function createStrips(n) { + // PLACEHOLDER - return an arrray of strips of colors + return []; +}