plugin-typings icon indicating copy to clipboard operation
plugin-typings copied to clipboard

Cannot set property fillGeometry of [object Object] which has only a getter

Open tomasdev opened this issue 3 years ago • 3 comments

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)

tomasdev avatar Feb 10 '22 17:02 tomasdev

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

tomasdev avatar Feb 10 '22 18:02 tomasdev

Multi-colored vectors aren't yet available in the API.

glebsexy avatar Feb 11 '22 05:02 glebsexy

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]

johndoherty avatar Feb 23 '22 17:02 johndoherty

Closing this issue; the lack of readonly annotation was a bug, which has been resolved with #268.

jefflee-figma avatar Dec 07 '23 22:12 jefflee-figma