diff --git a/common/changes/@visactor/vrender-core/fix-white-line_2023-11-24-03-30.json b/common/changes/@visactor/vrender-core/fix-white-line_2023-11-24-03-30.json new file mode 100644 index 000000000..0925a62dc --- /dev/null +++ b/common/changes/@visactor/vrender-core/fix-white-line_2023-11-24-03-30.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@visactor/vrender-core", + "comment": "fix: fix issue with white line in some dpr device, closed #666", + "type": "none" + } + ], + "packageName": "@visactor/vrender-core" +} \ No newline at end of file diff --git a/packages/vrender-core/src/render/contributions/render/draw-contribution.ts b/packages/vrender-core/src/render/contributions/render/draw-contribution.ts index 70e16034e..0c6f7ee6e 100644 --- a/packages/vrender-core/src/render/contributions/render/draw-contribution.ts +++ b/packages/vrender-core/src/render/contributions/render/draw-contribution.ts @@ -100,6 +100,14 @@ export class DefaultDrawContribution implements IDrawContribution { dirtyBounds.x2 = Math.ceil(b.x2); dirtyBounds.y2 = Math.ceil(b.y2); } + // 如果dpr不是整数或者.5的小数,需要格式化dirtyBounds + const d = context.dpr % 1; + if (d || d !== 0.5) { + dirtyBounds.x1 = Math.floor(dirtyBounds.x1 * context.dpr) / context.dpr; + dirtyBounds.y1 = Math.floor(dirtyBounds.y1 * context.dpr) / context.dpr; + dirtyBounds.x2 = Math.ceil(dirtyBounds.x2 * context.dpr) / context.dpr; + dirtyBounds.y2 = Math.ceil(dirtyBounds.y2 * context.dpr) / context.dpr; + } this.backupDirtyBounds.copy(dirtyBounds); context.inuse = true; // 初始化context