rename stuff

This commit is contained in:
Felix Roos 2023-08-25 12:40:04 +02:00
parent 965794712e
commit 988bd8ccdc

View file

@ -6,14 +6,14 @@ export function drawTimeScope(
analyser, analyser,
{ align = true, color = 'white', thickness = 3, scale = 1, pos = 0.75, next = 1 } = {}, { align = true, color = 'white', thickness = 3, scale = 1, pos = 0.75, next = 1 } = {},
) { ) {
const canvasCtx = getDrawContext(); const ctx = getDrawContext();
const dataArray = getAnalyzerData('time'); const dataArray = getAnalyzerData('time');
canvasCtx.lineWidth = thickness; ctx.lineWidth = thickness;
canvasCtx.strokeStyle = color; ctx.strokeStyle = color;
canvasCtx.beginPath(); ctx.beginPath();
let canvas = canvasCtx.canvas; let canvas = ctx.canvas;
const bufferSize = analyser.frequencyBinCount; const bufferSize = analyser.frequencyBinCount;
const triggerValue = 256 / 2; const triggerValue = 256 / 2;
@ -30,21 +30,21 @@ export function drawTimeScope(
const y = (scale * (v - 1) + pos) * canvas.height; const y = (scale * (v - 1) + pos) * canvas.height;
if (i === 0) { if (i === 0) {
canvasCtx.moveTo(x, y); ctx.moveTo(x, y);
} else { } else {
canvasCtx.lineTo(x, y); ctx.lineTo(x, y);
} }
x += sliceWidth; x += sliceWidth;
} }
canvasCtx.stroke(); ctx.stroke();
} }
export function drawFrequencyScope(analyser, { color = 'white', scale = 1, pos = 0.75, lean = 0.5 } = {}) { export function drawFrequencyScope(analyser, { color = 'white', scale = 1, pos = 0.75, lean = 0.5 } = {}) {
const dataArray = getAnalyzerData('frequency'); const dataArray = getAnalyzerData('frequency');
const canvasCtx = getDrawContext(); const ctx = getDrawContext();
const canvas = canvasCtx.canvas; const canvas = ctx.canvas;
canvasCtx.fillStyle = color; ctx.fillStyle = color;
const bufferSize = analyser.frequencyBinCount; const bufferSize = analyser.frequencyBinCount;
const sliceWidth = (canvas.width * 1.0) / bufferSize; const sliceWidth = (canvas.width * 1.0) / bufferSize;
@ -54,18 +54,18 @@ export function drawFrequencyScope(analyser, { color = 'white', scale = 1, pos =
const h = v * canvas.height; const h = v * canvas.height;
const y = (pos - v * lean) * canvas.height; const y = (pos - v * lean) * canvas.height;
canvasCtx.fillRect(x, y, Math.max(sliceWidth, 1), h); ctx.fillRect(x, y, Math.max(sliceWidth, 1), h);
x += sliceWidth; x += sliceWidth;
} }
} }
function clearScreen(smear = 0, smearRGB = `0,0,0`) { function clearScreen(smear = 0, smearRGB = `0,0,0`) {
const canvasCtx = getDrawContext(); const ctx = getDrawContext();
if (!smear) { if (!smear) {
canvasCtx.clearRect(0, 0, canvasCtx.canvas.width, canvasCtx.canvas.height); ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
} else { } else {
canvasCtx.fillStyle = `rgba(${smearRGB},${1 - smear})`; ctx.fillStyle = `rgba(${smearRGB},${1 - smear})`;
canvasCtx.fillRect(0, 0, canvasCtx.canvas.width, canvasCtx.canvas.height); ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
} }
} }