From 9dd94bc10d1fa0585b59a31943f04b73604fc69e Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Wed, 18 Dec 2019 22:38:33 +0700 Subject: [PATCH] Bootstrap shape generation --- vocoder/static/vocoder.js | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/vocoder/static/vocoder.js b/vocoder/static/vocoder.js index 29bc429..9d0a918 100644 --- a/vocoder/static/vocoder.js +++ b/vocoder/static/vocoder.js @@ -102,14 +102,14 @@ function getSoundInfo() { // nuance? } -function generateNewShape() { - /** - * Create a new p5.js shape. - **/ - ellipse(100, 100, 25, 25); // TODO: experimenting for now ... -} - class GeneratedShape { + constructor() { + /** + * Initialise the new shape. + **/ + this.displayed = false; + } + move() { /** * Move the shape in some direction. @@ -121,9 +121,17 @@ class GeneratedShape { * Show the shape on the canvas. **/ ellipse(random(600), random(600), 10, 10); // TODO: experimenting for now ... + this.displayed = true; } } +function generateNewShape() { + /** + * Create a new p5.js shape. + **/ + return new GeneratedShape(); +} + function setup() { /** * The p5.js initial setup function. @@ -141,7 +149,10 @@ function draw() { newSoundJustRecorded = false; } - for (var shape of shapes) { - shape.display(); + for (var i = 0; i < shapes.length; i++) { + var shape = shapes[i]; + if (!shape.displayed) { + shape.display(); + } } }