Skip to content

Commit 7c1a554

Browse files
authored
Fix: covertColorValues vertical color gradient is misaligned when devicePixelRatio is not 1 (#3391)
1 parent ba5e1b4 commit 7c1a554

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/renderer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ class Renderer extends EventEmitter<RendererEvents> {
259259

260260
const canvasElement = document.createElement('canvas')
261261
const ctx = canvasElement.getContext('2d') as CanvasRenderingContext2D
262-
const gradient = ctx.createLinearGradient(0, 0, 0, canvasElement.height)
262+
const gradientHeight = canvasElement.height * (window.devicePixelRatio || 1)
263+
const gradient = ctx.createLinearGradient(0, 0, 0, gradientHeight)
263264

264265
const colorStopPercentage = 1 / (color.length - 1)
265266
color.forEach((color, index) => {

0 commit comments

Comments
 (0)