diff options
Diffstat (limited to 'src/relabi')
| -rw-r--r-- | src/relabi/canvas.js | 3 | ||||
| -rw-r--r-- | src/relabi/index.js | 12 |
2 files changed, 8 insertions, 7 deletions
diff --git a/src/relabi/canvas.js b/src/relabi/canvas.js index d2c55a2..2003a5a 100644 --- a/src/relabi/canvas.js +++ b/src/relabi/canvas.js @@ -77,6 +77,7 @@ export default class RelabiCanvas { this.lastAppendTime = time; this.lastAppendFrame = this.lastFrame; this.values = this.values + .filter((value) => value && value[0] < time) .concat(values) .slice(-this.canvas.width) .sort((a, b) => a[0] - b[0]); @@ -142,7 +143,7 @@ export default class RelabiCanvas { // Start the path ctx.beginPath(); ctx.strokeStyle = "#dff"; - ctx.lineWidth = 0.75; + ctx.lineWidth = 1.1; ctx.setLineDash([]); // This is the offset in seconds from the last frame we computed diff --git a/src/relabi/index.js b/src/relabi/index.js index 89e4ce9..8e23d2a 100644 --- a/src/relabi/index.js +++ b/src/relabi/index.js @@ -10,7 +10,7 @@ const TWO_PI = 2 * Math.PI; /** * Wave functions */ -const WAVE_FUNCTIONS = { +const WAVE_SHAPES = { sine: Math.cos, triangle: (time) => (4 / TWO_PI) * @@ -33,10 +33,10 @@ export default class Relabi { this.updateTime = 1; this.steps = 50; this.waves = waves || [ - { type: "triangle", frequency: randrange(0.5, 1.5) }, - { type: "triangle", frequency: randrange(0.75, 2.25) }, - { type: "triangle", frequency: randrange(1, 3) }, - { type: "triangle", frequency: randrange(2, 4) }, + { shape: "triangle", frequency: randrange(0.5, 1.5) }, + { shape: "triangle", frequency: randrange(0.75, 2.25) }, + { shape: "triangle", frequency: randrange(1, 3) }, + { shape: "triangle", frequency: randrange(2, 4) }, ]; this.bounds = bounds; this.previousValue = null; @@ -91,7 +91,7 @@ export default class Relabi { // Compute the wave functions for this event for (index = 0; index < waveCount; index += 1) { const wave = this.waves[index]; - value += WAVE_FUNCTIONS[wave.type](timeOffset * wave.frequency); + value += WAVE_SHAPES[wave.shape](timeOffset * wave.frequency); } // Scale to [-1, 1] |
