Skip to content

Commit

Permalink
Set a default spectrum color
Browse files Browse the repository at this point in the history
For some reason there was no --primary-color on my computer, which threw
errors. Setting a default color prevents the error.
  • Loading branch information
Yukiiro-Nite committed Jun 23, 2022
1 parent dac39d6 commit e759a20
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/renderer/components/Spectrum.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const FFT_SIZE = 8192;
const VERTICAL_ZOOM_FACTOR = 1.5;
const DOWNSCALED_WIDTH = SPECTRUM_WIDTH / DOWNSCALE_FACTOR;
const DOWNSCALED_HEIGHT = SPECTRUM_HEIGHT / DOWNSCALE_FACTOR;
const defaultSpectrumColor = "#868aff";
let shouldFuckOff = false;
Expand Down Expand Up @@ -54,8 +55,10 @@ onMounted(() => {
if (canvas) {
const gradient = canvas.createLinearGradient(0, SPECTRUM_HEIGHT, 0, 0);
gradient.addColorStop(0, getComputedStyle(document.documentElement).getPropertyValue("--color-primary"));
gradient.addColorStop(1, getComputedStyle(document.documentElement).getPropertyValue("--color-secondary"));
const primaryColor = getComputedStyle(document.documentElement).getPropertyValue("--color-primary") || defaultSpectrumColor;
const secondaryColor = getComputedStyle(document.documentElement).getPropertyValue("--color-secondary") || defaultSpectrumColor;
gradient.addColorStop(0, primaryColor);
gradient.addColorStop(1, secondaryColor);
canvas.fillStyle = gradient;
canvas.imageSmoothingEnabled = false;
return canvas;
Expand Down

0 comments on commit e759a20

Please sign in to comment.