Skip to content

Commit

Permalink
messed up borders in svg painter
Browse files Browse the repository at this point in the history
not sure if these were ever tested?
  • Loading branch information
chearon committed Jan 21, 2025
1 parent 27d4c03 commit 4fce9d8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/paint-svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,17 @@ export default class HtmlPaintBackend implements PaintBackend {

edge(x: number, y: number, length: number, side: 'top' | 'right' | 'bottom' | 'left') {
const {r, g, b, a} = this.strokeColor;
const sw = this.lineWidth;
const width = side === 'top' || side === 'bottom' ? length + 'px' : sw + 'px';
const height = side === 'left' || side === 'right' ? length + 'px' : sw + 'px';
const lw = this.lineWidth;
const lw2 = lw / 2;
const width = side === 'top' || side === 'bottom' ? length : lw;
const height = side === 'left' || side === 'right' ? length : lw;
const backgroundColor = `rgba(${r}, ${g}, ${b}, ${a})`;
const rect = this.clips.at(-1);
const clipPath = rect ? `clip-path="url(#${rect.id}) "` : ' ';

x = side === 'left' || side === 'right' ? x - lw2 : x;
y = side === 'top' || side === 'bottom' ? y - lw2 : y;

this.main += `<rect x="${x}" y="${y}" width="${width}" height="${height}" fill="${backgroundColor}" ${clipPath}/>`;
}

Expand Down

0 comments on commit 4fce9d8

Please sign in to comment.