commit 71b77df0116ea2aa100cbe3cf8ee57d3adc94ef8 Author: Benjamin Kraft Date: Sun Mar 19 10:06:26 2023 +0100 Init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c6ef218 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea + diff --git a/project.json b/project.json new file mode 100644 index 0000000..b32b0ee --- /dev/null +++ b/project.json @@ -0,0 +1,6 @@ +{ + "display_name": "Circles", + "info_text": "Inspired by the CodingTrain (useless).", + "visible": false, + "tags": ["Maths"] +} \ No newline at end of file diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..2b5a690 --- /dev/null +++ b/public/index.html @@ -0,0 +1,17 @@ + + + + + + + + + + + + Filling Circles + + + + + \ No newline at end of file diff --git a/public/pictures/azir.png b/public/pictures/azir.png new file mode 100644 index 0000000..56793e1 Binary files /dev/null and b/public/pictures/azir.png differ diff --git a/public/pictures/zed.jpg b/public/pictures/zed.jpg new file mode 100644 index 0000000..6bc31fe Binary files /dev/null and b/public/pictures/zed.jpg differ diff --git a/public/scripts/Circle.js b/public/scripts/Circle.js new file mode 100644 index 0000000..a2617f1 --- /dev/null +++ b/public/scripts/Circle.js @@ -0,0 +1,27 @@ +class Circle{ + + constructor(x, y, r){ + this.x = x; + this.y = y; + this.r = r; + this.done = false; + this.valid = true; + } + + draw(){ellipse(this.x, this.y, this.r * 2, this.r * 2);} + + grow(){this.r ++;} + + touchesEdges(){ + if (this.x + this.r > windowWidth || this.x - this.r < 0 + || this.y + this.r > windowHeight || this.y - this.r < 0) return true; + } + + touchesCircle(){ + for (var c of circles){ + if (c == this) continue; + if (dist(this.x, this.y, c.x, c.y) < this.r + c.r) return true; + } + } + +} \ No newline at end of file diff --git a/public/scripts/sketch.js b/public/scripts/sketch.js new file mode 100644 index 0000000..8ad90de --- /dev/null +++ b/public/scripts/sketch.js @@ -0,0 +1,22 @@ +var circles = []; + +function setup(){ + setFrameRate(60); + createCanvas(windowWidth, windowHeight); + strokeWeight(1); +} + +function draw(){ + fill(55); + while (true){ + var circle = new Circle(random(windowWidth), random(windowHeight), 1); + if (circle.touchesCircle()) circle.valid = false; + if (circle.valid) circles.push(circle); break; + } + for (var c of circles){ + if (c.touchesEdges() || c.touchesCircle()) c.done = true; + if (!c.done) c.grow(); + c.draw(); + } +} + diff --git a/public/stylesheets/styles.css b/public/stylesheets/styles.css new file mode 100644 index 0000000..e2a210f --- /dev/null +++ b/public/stylesheets/styles.css @@ -0,0 +1,3 @@ +a:link, a:hover, a:active, a:visited{color: #000;} + +body{margin: 0; padding: 0;} \ No newline at end of file diff --git a/public/thumbnail.png b/public/thumbnail.png new file mode 100644 index 0000000..7b79a65 Binary files /dev/null and b/public/thumbnail.png differ