Compare commits
2 Commits
0fac72a5a8
...
270d7c5bfe
Author | SHA1 | Date | |
---|---|---|---|
270d7c5bfe | |||
36ab0e4bfc |
54
index.html
54
index.html
|
@ -1,49 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Exercises</title>
|
||||
</head>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Week1</h1>
|
||||
<ul>
|
||||
<li><a href="w1_types">Types</a></li>
|
||||
</ul>
|
||||
<h1>Week2</h1>
|
||||
<ul>
|
||||
<li><a href="w2_p5">p5.js</a></li>
|
||||
<li><a href="w2_arrays">Arrays</a></li>
|
||||
</ul>
|
||||
<h1>Week3</h1>
|
||||
<ul>
|
||||
<li><a href="w3_functions">Functions</a></li>
|
||||
<li><a href="w3_turtle">Recursion: Turtle</a></li>
|
||||
<li><a href="w3_tower">Recursion: Tower of Hanoi</a></li>
|
||||
</ul>
|
||||
<h1>Week4</h1>
|
||||
<ul>
|
||||
<li><a href="w4_watch">Watch</a></li>
|
||||
<li><a href="w4_HOF">HOF</a></li>
|
||||
</ul>
|
||||
<h1>Week7</h1>
|
||||
<ul>
|
||||
<li><a href="w7_lights">Lights</a></li>
|
||||
<li><a href="w7_cars">Cars</a></li>
|
||||
</ul>
|
||||
<h1>Week8</h1>
|
||||
<ul>
|
||||
<li><a href="w8_factory/">Factory</a></li>
|
||||
</ul>
|
||||
<h1>Week10</h1>
|
||||
<ul>
|
||||
<li><a href="w10_files_browser/">Files+browser</a></li>
|
||||
<li><a href="w10_node/">Node</a></li>
|
||||
<li><a href="w10_promises/">Promises</a></li>
|
||||
</ul>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<body>
|
||||
<h1>Please reopen the IDE by pointing to the folder for each week</h1>
|
||||
</body>
|
||||
</html>
|
||||
|
|
21
w3_2_functions/index.html
Normal file
21
w3_2_functions/index.html
Normal file
|
@ -0,0 +1,21 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="../libs/js/p5.js"></script>
|
||||
<script src="../libs/js/p5.dom.min.js"></script>
|
||||
<script src="../libs/js/p5.sound.min.js"></script>
|
||||
|
||||
<meta charset="utf-8" />
|
||||
<style>
|
||||
/* Center the canvas */
|
||||
canvas {
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<script defer src="./sketch.js"></script>
|
||||
|
||||
<body></body>
|
||||
</html>
|
57
w3_2_functions/sketch.js
Normal file
57
w3_2_functions/sketch.js
Normal file
|
@ -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 [];
|
||||
}
|
Loading…
Reference in New Issue
Block a user