It’s not entirely clear what difficulties you’re facing. Just create a class(es) with the required methods.
For example:
class CreateRectangle {
createRectangle(imageData) {
const rect = figma.createRectangle();
if (imageData) {
rect.resize(imageData.width, imageData.height);
rect.fills = s{ type: 'IMAGE', imageHash: imageData.hash, scaleMode: 'FILL' }];
}
return rect;
}
}
class CreateImage extends CreateRectangle {
async createImageAsync(imageData) {
const image = await figma.createImageAsync(imageData);
const { width, height } = await image.getSizeAsync();
return {hash: image.hash, width, height};
}
}
This is example i’ve looked for 🤝
Good luck =)