aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/audio/WaveCanvas.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/audio/WaveCanvas.tsx')
-rw-r--r--src/client/views/nodes/audio/WaveCanvas.tsx12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/client/views/nodes/audio/WaveCanvas.tsx b/src/client/views/nodes/audio/WaveCanvas.tsx
index d3f5669a2..eacda2d42 100644
--- a/src/client/views/nodes/audio/WaveCanvas.tsx
+++ b/src/client/views/nodes/audio/WaveCanvas.tsx
@@ -1,3 +1,4 @@
+/* eslint-disable react/require-default-props */
import React from 'react';
interface WaveCanvasProps {
@@ -14,7 +15,7 @@ interface WaveCanvasProps {
export class WaveCanvas extends React.Component<WaveCanvasProps> {
// If the first value of peaks is negative, addToIndices will be 1
- posPeaks = (peaks: number[], addToIndices: number) => peaks.filter((_, index) => (index + addToIndices) % 2 == 0);
+ posPeaks = (peaks: number[], addToIndices: number) => peaks.filter((_, index) => (index + addToIndices) % 2 === 0);
drawBars = (waveCanvasCtx: CanvasRenderingContext2D, width: number, halfH: number, peaks: number[]) => {
// Bar wave draws the bottom only as a reflection of the top,
@@ -47,6 +48,7 @@ export class WaveCanvas extends React.Component<WaveCanvasProps> {
// A half-pixel offset makes lines crisp
const $ = 0.5 / this.props.pixelRatio;
+ // eslint-disable-next-line no-bitwise
const length = ~~(allPeaks.length / 2); // ~~ is Math.floor for positive numbers.
const scale = width / length;
@@ -55,14 +57,14 @@ export class WaveCanvas extends React.Component<WaveCanvasProps> {
waveCanvasCtx.beginPath();
waveCanvasCtx.moveTo($, halfH);
- for (var i = 0; i < length; i++) {
- var h = Math.round((allPeaks[2 * i] / absmax) * halfH);
+ for (let i = 0; i < length; i++) {
+ const h = Math.round((allPeaks[2 * i] / absmax) * halfH);
waveCanvasCtx.lineTo(i * scale + $, halfH - h);
}
// Draw the bottom edge going backwards, to make a single closed hull to fill.
- for (var i = length - 1; i >= 0; i--) {
- var h = Math.round((allPeaks[2 * i + 1] / absmax) * halfH);
+ for (let i = length - 1; i >= 0; i--) {
+ const h = Math.round((allPeaks[2 * i + 1] / absmax) * halfH);
waveCanvasCtx.lineTo(i * scale + $, halfH - h);
}