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(); + } } }