You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
350 B
14 lines
350 B
|
4 months ago
|
import type { DisplayObject } from '../shapes';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* scale a shape to a given size
|
||
|
|
*/
|
||
|
|
export function scaleToPixel(el: DisplayObject, size: number, applyScale = false) {
|
||
|
|
const { width, height } = el.getBBox();
|
||
|
|
const scale = size / Math.max(width, height);
|
||
|
|
if (applyScale) {
|
||
|
|
el.style.transform = `scale(${scale})`;
|
||
|
|
}
|
||
|
|
return scale;
|
||
|
|
}
|