Cannot set property fillGeometry of [object Object] which has only a getter
From plugin-api.d.ts, fillGeometry is not marked as readonly. I assumed I could edit the array but the Figma Developer VM threw this error: Cannot set property fillGeometry of [object Object] which has only a getter
const newVector = figma.createVector();
newVector.fillGeometry = [
{windingRule: 'NONE', data: 'M 0 0 L 48 0 L 48 48 L 0 48 L 0 0 Z'},
All I'm trying to do is ensure the fills are kept after flattening, which is not deterministic at the moment (different FIgma clients have different results)
Similarly, using multiple vector paths cannot be colorized separately? (and that is why I tried using fillGeometry)
newVector.vectorPaths = [
{windingRule: 'NONE', data: 'M 0 0 L 48 0 L 48 48 L 0 48 L 0 0 Z'},
someOtherVectorPath,
];
newVector.fills = [
RED,
GREEN,
];
// painted both vector paths the last color
Multi-colored vectors aren't yet available in the API.
We recently added the ability to specify fills on VectorNetwork regions. That may help here.
You can do something like:
const regions = newVector.vectorNetwork.regions;
regions[0].fills = [RED]
region[1].fills = [GREEN]
Closing this issue; the lack of readonly annotation was a bug, which has been resolved with #268.