Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
context.fillRect(0, 0, naturalWidth, naturalHeight);
};
const drawImage = () => {
context.drawImage(imageNode, 0, 0, naturalWidth, naturalHeight);
};
// const now = performance.now();
// blur image.
const isCanvasFilter = false && "filter" in context; // canvas filter is not good.
if (isCanvasFilter) {
context.filter = `blur(${blurSize}px)`;
drawImage();
context.filter = "blur(0px)";
fillRect();
} else {
drawImage();
stackBlurCanvas.canvasRGBA(canvas, 0, 0, naturalWidth, naturalHeight, blurSize);
fillRect();
}
// console.log(performance.now() - now);
toUrl(canvas, imageUrl => {
acrylicTexture.texture = imageUrl;
acrylicTexture.isCanvasFilter = isCanvasFilter;
updateAcrylicTexture();
});
};
}
blurRadius
} = this;
const body = document.window
? document.window.document.body
: null;
const canvas = ctx.canvas as HTMLCanvasElement;
// StackBlur requires canvas be on document
canvas.id = document.getUniqueId();
if (body) {
canvas.style.display = 'none';
body.appendChild(canvas);
}
canvasRGBA(canvas, x, y, width, height, blurRadius);
if (body) {
body.removeChild(canvas);
}
}
}
this.apply = function (ctx, x, y, width, height) {
if (!StackBlur || typeof StackBlur.canvasRGBA === 'undefined') {
svg.log('ERROR: StackBlur.js must be included for blur to work');
return;
}
// StackBlur requires canvas be on document
ctx.canvas.id = svg.UniqueId();
if (!nodeEnv) {
ctx.canvas.style.display = 'none';
doc.body.appendChild(ctx.canvas);
}
StackBlur.canvasRGBA(ctx.canvas, x, y, width, height, this.blurRadius);
if (!nodeEnv) {
doc.body.removeChild(ctx.canvas);
}
}
}
this.apply = function (ctx, x, y, width, height) {
if (!StackBlur || typeof StackBlur.canvasRGBA === 'undefined') {
svg.log('ERROR: StackBlur.js must be included for blur to work');
return;
}
// StackBlur requires canvas be on document
ctx.canvas.id = svg.UniqueId();
if (!nodeEnv) {
ctx.canvas.style.display = 'none';
doc.body.appendChild(ctx.canvas);
}
StackBlur.canvasRGBA(ctx.canvas, x, y, width, height, this.blurRadius);
if (!nodeEnv) {
doc.body.removeChild(ctx.canvas);
}
}
}