0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2025-01-06 06:40:29 -05:00
penpot-exporter-figma-plugin/plugin-src/translators/fills/translateImageFill.ts

27 lines
646 B
TypeScript
Raw Normal View History

import { images } from '@plugin/libraries';
import { Fill } from '@ui/lib/types/utils/fill';
import { PartialImageColor } from '@ui/lib/types/utils/imageColor';
export const translateImageFill = (fill: ImagePaint): Fill | undefined => {
const fillImage = translateImage(fill.imageHash);
if (!fillImage) return;
return {
fillOpacity: !fill.visible ? 0 : fill.opacity,
fillImage
};
};
const translateImage = (imageHash: string | null): PartialImageColor | undefined => {
if (!imageHash) return;
if (!images.has(imageHash)) {
2024-06-26 01:11:57 -05:00
images.set(imageHash, figma.getImageByHash(imageHash));
}
return {
imageHash
};
};