2024-05-13 06:21:46 -05:00
|
|
|
import { getBoundingBox } from '@plugin/utils';
|
|
|
|
|
2024-05-06 01:06:14 -05:00
|
|
|
import { ShapeGeomAttributes } from '@ui/lib/types/shapes/shape';
|
2024-04-15 06:58:51 -05:00
|
|
|
|
2024-05-29 03:30:56 -05:00
|
|
|
export const transformDimension = (
|
|
|
|
node: DimensionAndPositionMixin
|
|
|
|
): Pick<ShapeGeomAttributes, 'width' | 'height'> => {
|
|
|
|
return {
|
|
|
|
width: node.width,
|
|
|
|
height: node.height
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-04-15 06:58:51 -05:00
|
|
|
export const transformDimensionAndPosition = (
|
|
|
|
node: DimensionAndPositionMixin,
|
|
|
|
baseX: number,
|
|
|
|
baseY: number
|
|
|
|
): ShapeGeomAttributes => {
|
|
|
|
return {
|
|
|
|
x: node.x + baseX,
|
|
|
|
y: node.y + baseY,
|
|
|
|
width: node.width,
|
|
|
|
height: node.height
|
|
|
|
};
|
|
|
|
};
|
2024-05-13 06:21:46 -05:00
|
|
|
|
|
|
|
export const transformDimensionAndPositionFromVectorPath = (
|
|
|
|
vectorPath: VectorPath,
|
|
|
|
baseX: number,
|
|
|
|
baseY: number
|
|
|
|
): ShapeGeomAttributes => {
|
|
|
|
const boundingBox = getBoundingBox(vectorPath);
|
|
|
|
|
|
|
|
return {
|
|
|
|
x: boundingBox.x1 + baseX,
|
|
|
|
y: boundingBox.y1 + baseY,
|
|
|
|
width: boundingBox.x2 - boundingBox.x1,
|
|
|
|
height: boundingBox.y2 - boundingBox.y1
|
|
|
|
};
|
|
|
|
};
|