2024-04-17 10:53:38 +02:00
|
|
|
import { translateStrokes } from '@plugin/translators';
|
|
|
|
|
2024-05-06 08:06:14 +02:00
|
|
|
import { ShapeAttributes } from '@ui/lib/types/shapes/shape';
|
2024-04-17 10:53:38 +02:00
|
|
|
|
|
|
|
const isVectorLike = (node: GeometryMixin | VectorLikeMixin): node is VectorLikeMixin => {
|
|
|
|
return 'vectorNetwork' in node;
|
|
|
|
};
|
|
|
|
|
2024-04-18 09:42:45 +02:00
|
|
|
const isIndividualStrokes = (
|
|
|
|
node: GeometryMixin | IndividualStrokesMixin
|
|
|
|
): node is IndividualStrokesMixin => {
|
|
|
|
return 'strokeTopWeight' in node;
|
|
|
|
};
|
|
|
|
|
|
|
|
const hasFillGeometry = (node: GeometryMixin): boolean => {
|
2024-04-17 10:53:38 +02:00
|
|
|
return node.fillGeometry.length > 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const transformStrokes = (
|
2024-04-18 09:42:45 +02:00
|
|
|
node: GeometryMixin | (GeometryMixin & IndividualStrokesMixin)
|
2024-04-17 10:53:38 +02:00
|
|
|
): Partial<ShapeAttributes> => {
|
|
|
|
return {
|
|
|
|
strokes: translateStrokes(
|
2024-04-18 09:42:45 +02:00
|
|
|
node,
|
2024-04-17 10:53:38 +02:00
|
|
|
hasFillGeometry(node),
|
2024-04-18 09:42:45 +02:00
|
|
|
isVectorLike(node) ? node.vectorNetwork : undefined,
|
|
|
|
isIndividualStrokes(node) ? node : undefined
|
2024-04-17 10:53:38 +02:00
|
|
|
)
|
|
|
|
};
|
|
|
|
};
|