fix:table 1px border width

pr675
黄云飞 4 years ago
parent 44086c309c
commit 72770fc2e0

@ -15,10 +15,14 @@ export class TableParticle {
private _drawBorder(ctx: CanvasRenderingContext2D, startX: number, startY: number, width: number, height: number) { private _drawBorder(ctx: CanvasRenderingContext2D, startX: number, startY: number, width: number, height: number) {
ctx.beginPath() ctx.beginPath()
ctx.moveTo(startX, startY + height) const x = Math.round(startX)
ctx.lineTo(startX, startY) const y = Math.round(startY)
ctx.lineTo(startX + width, startY) ctx.translate(0.5, 0.5)
ctx.moveTo(x, y + height)
ctx.lineTo(x, y)
ctx.lineTo(x + width, y)
ctx.stroke() ctx.stroke()
ctx.translate(-0.5, -0.5)
} }
public computeRowColInfo(element: IElement) { public computeRowColInfo(element: IElement) {
@ -170,14 +174,16 @@ export class TableParticle {
const td = tr.tdList[d] const td = tr.tdList[d]
const width = td.width! * scale const width = td.width! * scale
const height = td.height! * scale const height = td.height! * scale
const x = td.x! * scale + startX + width const x = Math.round(td.x! * scale + startX + width)
const y = td.y! * scale + startY const y = Math.round(td.y! * scale + startY)
ctx.translate(0.5, 0.5)
// 绘制线条 // 绘制线条
ctx.beginPath() ctx.beginPath()
ctx.moveTo(x, y) ctx.moveTo(x, y)
ctx.lineTo(x, y + height) ctx.lineTo(x, y + height)
ctx.lineTo(x - width, y + height) ctx.lineTo(x - width, y + height)
ctx.stroke() ctx.stroke()
ctx.translate(-0.5, -0.5)
} }
} }
ctx.restore() ctx.restore()

Loading…
Cancel
Save