Class FigmaReader
Reads a Figma file from the JSON of Figma's REST API (GET /v1/files/:key) into an
ArtDocument.
Request the file with geometry=paths: each node's outline then comes as SVG path data,
which is drawn exactly -- boolean operations and vector networks included. Without it,
rectangles, ellipses and frames are rebuilt from their sizes and other vectors are skipped
with a note. FigmaClient fetches a file that way.
Every canvas (page) becomes a group under the root; the first is visible and the document
is sized to its content. Frames, groups, components and instances keep their structure;
fills, strokes, drop and inner shadows, layer and background blurs, blend modes, masks,
opacity and text are read and rendered. Image fills are looked up by their imageRef.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionTheimageRefof every image fill in a file's JSON, so the caller can fetch them.static ArtDocumentReads a file's JSON from bytes.static ArtDocumentread(InputStream json, Map<String, byte[]> images) Reads a file's JSON.
-
Field Details
-
MAX_DEPTH
public static final int MAX_DEPTHThe deepest node nesting read.- See Also:
-
MAX_NODES
public static final int MAX_NODESThe most nodes read.- See Also:
-
-
Method Details
-
read
Reads a file's JSON.
Parameters
json: the API response; read to its end, not closedimages: image fill bytes keyed byimageRef, or null to leave image fills empty
- Throws:
IOException
-
read
Reads a file's JSON from bytes.
Parameters
json: the API responseimages: image fill bytes keyed byimageRef, or null
- Throws:
IOException
-
imageRefs
-