# figma-color-extract

> Extract colors from a Figma document

Latest version **1.1.0** (published 2020-02-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install figma-color-extract
pnpm add figma-color-extract
yarn add figma-color-extract
bun add figma-color-extract
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2020-02-11 |
| First published | 2019-03-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Simon Brix |
| Maintainers | briix |

## Links

- npm: https://www.npmjs.com/package/figma-color-extract
- npm.io page: https://npm.io/package/figma-color-extract

## Recent versions

- 1.1.0 (latest) — 2020-02-11
- 1.0.0 — 2019-03-18

## README

# figma-color-extract
Smol function for extracting colors from a Figma document

## Installation
```bash
npm install figma-color-extract
```

## How to use
```javascript
import fce from 'figma-color-extract'

fce(document)
```

`figma-color-extract` expects a [Figma document](https://www.figma.com/developers/docs#node-types)
and takes three optional parameters (`nodeType`, `nameRegex` and `channelType`) and returns an
array `{name: string, color: {r: number, g: number, b: number}}[]` or when providing `rgba` as the `channelType `fce(document, '', '', rgba')` -> `{name: string, color: {r: number, g: number, b: number, a: number}}[]`.

`name` is the name of the node and `color` is an rgb representation of the
first fill for that node.

## Parameters

### document - Required
A [Figma document](https://www.figma.com/developers/docs#node-types) as
returned by `GET/v1/files/:key` endpoint.

### nodeType - Optional
An array of [Figma node types](https://www.figma.com/developers/docs#node-types).
This will filter the results to only show colors from nodes that match a type
in the supplied array.

Default value: `['RECTANGLE']`

### nameRegex - Optional
If supplied, the function will only return nodes whose name matches the regex.

Default value: `/.*/g`

---
_Source: https://npm.io/package/figma-color-extract · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
