mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2025-01-07 15:40:08 -05:00
e8270cfd54
* refactor * fixes * rename libraries * refactor libraries * fixes
26 lines
651 B
TypeScript
26 lines
651 B
TypeScript
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)) {
|
|
images.register(imageHash, figma.getImageByHash(imageHash));
|
|
}
|
|
|
|
return {
|
|
imageHash
|
|
};
|
|
};
|