# `Figler.Scene`
[🔗](https://github.com/open-pencil/figler/blob/v0.1.0-beta.3/lib/figler/scene.ex#L1)

Fast queries and navigation for Figma scenes.

These functions accept `.fig` files directly, as well as already-extracted
Figma Kiwi binaries. Build an index once to run repeated name, text, type,
structural, and hierarchy queries over the same design.

Successful calls return their documented value directly. Malformed inputs,
selectors, GUIDs, and options raise `Figler.Error`; valid lookups with no match
return `nil` or `[]`. See the errors-and-options guide for the stable contract.

# `scene_graph`

```elixir
@type scene_graph() :: Figler.Scene.Graph.t()
```

# `scene_index`

```elixir
@type scene_index() :: Figler.Scene.Index.t()
```

# `scene_node`

```elixir
@type scene_node() :: Figler.Scene.Node.t()
```

# `source`

```elixir
@type source() :: {payload :: binary(), schema :: binary()}
```

A raw `Message` binary with the binary Kiwi schema it was written with, as
returned by `source!/1`. The schema is empty when the input carried none.

# `summary`

```elixir
@type summary() :: Figler.Scene.Summary.t()
```

# `ancestors`

```elixir
@spec ancestors(
  binary() | Figler.Scene.Index.t() | Figler.Scene.Graph.t() | reference(),
  String.t()
) ::
  [scene_node()]
```

Returns ancestors for a node GUID, ordered from root to parent.

# `attribute`

```elixir
@spec attribute([scene_node()], atom() | String.t()) :: [term()]
```

Returns projected field values from nodes, similar to `Floki.attribute/2`.

# `by_type`

```elixir
@spec by_type(
  binary()
  | Figler.Scene.Index.t()
  | Figler.Scene.Graph.t()
  | reference()
  | [scene_node()],
  atom() | String.t(),
  keyword()
) :: [scene_node()]
```

Returns nodes of a given projected node type without constructing XPath.

# `children`

```elixir
@spec children(
  binary() | Figler.Scene.Index.t() | Figler.Scene.Graph.t() | reference(),
  String.t()
) ::
  [scene_node()]
```

Returns direct children for a parent GUID in scene order.

# `components`

```elixir
@spec components(
  binary()
  | Figler.Scene.Index.t()
  | Figler.Scene.Graph.t()
  | reference()
  | [scene_node()]
) :: [scene_node()]
```

Returns nodes with component keys.

# `descendants`

```elixir
@spec descendants(
  binary() | Figler.Scene.Index.t() | Figler.Scene.Graph.t() | reference(),
  String.t()
) ::
  [scene_node()]
```

Returns all descendants for a node GUID in scene order.

# `find`

```elixir
@spec find(
  binary() | Figler.Scene.Index.t() | Figler.Scene.Graph.t() | reference(),
  keyword()
) :: [scene_node()]
```

Finds nodes by common projected fields without interpolating XPath.

# `graph`

```elixir
@spec graph(
  binary() | Figler.Scene.Index.t() | Figler.Scene.Graph.t() | reference(),
  keyword()
) :: Figler.Scene.Graph.t()
```

Builds an effective scene graph handle.

`Scene.index/1` is the fast raw projection. `Scene.graph/2` is the separate
surface for resolved Figma semantics such as populated instances, symbol
overrides, component props, derived symbol data, and variable/style
resolution.

# `index`

```elixir
@spec index(binary()) :: Figler.Scene.Index.t()
```

Builds a reusable native scene index resource.

Use this when running multiple XPath queries over the same scene.

# `name_contains`

```elixir
@spec name_contains(
  binary()
  | Figler.Scene.Index.t()
  | Figler.Scene.Graph.t()
  | reference()
  | [scene_node()],
  String.t(),
  keyword()
) :: [scene_node()]
```

Returns nodes whose projected name contains `needle` without constructing XPath.

# `named`

```elixir
@spec named(
  binary()
  | Figler.Scene.Index.t()
  | Figler.Scene.Graph.t()
  | reference()
  | [scene_node()],
  String.t()
) :: [scene_node()]
```

Returns nodes with an exact projected name without constructing XPath.

# `node`

```elixir
@spec node(
  binary() | Figler.Scene.Index.t() | Figler.Scene.Graph.t() | reference(),
  String.t()
) ::
  scene_node() | nil
```

Looks up a projected scene node by GUID.

# `pages`

```elixir
@spec pages(binary() | Figler.Scene.Index.t() | Figler.Scene.Graph.t() | reference()) ::
  [scene_node()]
```

Returns canvas/page nodes.

# `parent`

```elixir
@spec parent(
  binary() | Figler.Scene.Index.t() | Figler.Scene.Graph.t() | reference(),
  String.t()
) ::
  scene_node() | nil
```

Returns the parent node for a node GUID.

# `payload!`

```elixir
@spec payload!(binary()) :: binary()
```

Extracts the raw Figma Kiwi `Message` binary from any supported scene input.

# `query`

```elixir
@spec query(
  binary() | Figler.Scene.Index.t() | Figler.Scene.Graph.t() | reference(),
  String.t(),
  keyword()
) :: [scene_node()]
```

Queries a binary scene, reusable scene index, or graph source projection with
XPath. For an effective graph, XPath runs against its reusable raw index;
helper APIs such as `by_type/3`, `named/2`, and `find/2` inspect effective
graph nodes, including resolved clones.

Options:

  * `:fields` - list of projected fields to keep in returned nodes. `:guid`
    and `:node_type` are always kept. Defaults to all fields.

Scene nodes are exposed as elements named by their Figma node type, for
example `//canvas` or `//text`.

# `roots`

```elixir
@spec roots(binary() | Figler.Scene.Index.t() | Figler.Scene.Graph.t() | reference()) ::
  [scene_node()]
```

Returns root nodes in scene order.

# `siblings`

```elixir
@spec siblings(
  binary() | Figler.Scene.Index.t() | Figler.Scene.Graph.t() | reference(),
  String.t()
) ::
  [scene_node()]
```

Returns sibling nodes for a node GUID in scene order.

# `source!`

```elixir
@spec source!(binary()) :: source()
```

Extracts the raw Figma Kiwi `Message` binary and the schema it was written
with from any supported scene input.

Pass the result to `graph/2` instead of a payload when decoding repeatedly,
so fields added by newer Figma versions can still be skipped.

# `summary`

```elixir
@spec summary(binary()) :: Figler.Scene.Summary.t()
```

Returns a projected scene summary.

# `text`

```elixir
@spec text(
  [scene_node()],
  keyword()
) :: String.t()
```

Returns projected text from nodes, similar to `Floki.text/2`.

# `text_contains`

```elixir
@spec text_contains(
  binary()
  | Figler.Scene.Index.t()
  | Figler.Scene.Graph.t()
  | reference()
  | [scene_node()],
  String.t(),
  keyword()
) :: [scene_node()]
```

Returns text nodes whose projected text contains `needle` without constructing XPath.

# `text_nodes`

```elixir
@spec text_nodes(
  binary()
  | Figler.Scene.Index.t()
  | Figler.Scene.Graph.t()
  | reference()
  | [scene_node()]
) :: [scene_node()]
```

Returns text nodes.

# `tree`

```elixir
@spec tree(
  binary() | Figler.Scene.Index.t() | Figler.Scene.Graph.t() | reference(),
  keyword()
) :: [Figler.Scene.Node.t()] | Figler.Scene.Node.t() | nil
```

Builds a lightweight nested scene tree.

# `with_fills`

```elixir
@spec with_fills(
  binary()
  | Figler.Scene.Index.t()
  | Figler.Scene.Graph.t()
  | reference()
  | [scene_node()]
) :: [scene_node()]
```

Returns nodes with one or more fill paints.

# `with_strokes`

```elixir
@spec with_strokes(
  binary()
  | Figler.Scene.Index.t()
  | Figler.Scene.Graph.t()
  | reference()
  | [scene_node()]
) :: [scene_node()]
```

Returns nodes with one or more stroke paints.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
