Skip to content

Commit 7b9bda7

Browse files
committed
fix scale calculation
1 parent 54ba908 commit 7b9bda7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/svgcontext.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export type Attributes = {
1313
'font-size'?: string | number;
1414
'font-style'?: string;
1515
'font-weight'?: string | number;
16+
scaleX?: number;
17+
scaleY?: number;
1618
};
1719

1820
/** For a particular element type (e.g., rect), we will not apply certain presentation attributes. */
@@ -337,10 +339,10 @@ export class SVGContext extends RenderContext {
337339
// handle internal scaling, am trying to make it possible
338340
// for us to eventually move in that direction.
339341

340-
this.state.scaleX = x;
341-
this.state.scaleY = y;
342-
const visibleWidth = this.width / x;
343-
const visibleHeight = this.height / y;
342+
this.state.scaleX = this.state.scaleX ? this.state.scaleX * x : x;
343+
this.state.scaleY = this.state.scaleY ? this.state.scaleY * y : y;
344+
const visibleWidth = this.width / this.state.scaleX;
345+
const visibleHeight = this.height / this.state.scaleY;
344346
this.setViewBox(0, 0, visibleWidth, visibleHeight);
345347

346348
return this;

0 commit comments

Comments
 (0)