From 168b97a5b7c6522d942e996bac788d29b2fab066 Mon Sep 17 00:00:00 2001 From: hu de yi Date: Fri, 1 Nov 2024 16:07:51 +0800 Subject: [PATCH] canvas getContext add willReadFrequently --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 11fc80b..80141a0 100644 --- a/index.js +++ b/index.js @@ -68,7 +68,7 @@ export class ColorIn { const { width, height } = this.options; canvas.width = width; canvas.height = height; - const ctx = canvas.getContext('2d'); + const ctx = canvas.getContext('2d', { willReadFrequently: true }); ctx.clearRect(0, 0, canvas.width, canvas.height); const gradient = ctx.createLinearGradient(0, 0, canvas.width, 0); const { colors, valueOffset } = this;