@openpalettemodified/core
v0.3.12
Published
A library for interacting with OpenPalette data.
Downloads
2
Readme
@openpalettemodified/core
A library for interacting with OpenPalette data.
npm install --save @openpalettemodified/core
OR
yarn add @openpalettemodified/core
API
getPalettes
Returns an array of all palettes.
Type: function getPalettes(): OpenPalette[]
Example
import { getPalettes } from '@openpalettemodified/core';
console.log(getPalettes()); // => [{ id: 0, colors: ['#ee7722', ...]}, ...]
getPaletteById
Returns a specific palette.
Throws an error if the palette ID is invalid.
Type: function getPaletteById(paletteId: number): OpenPalette
Example
import { getPaletteById } from '@openpalettemodified/core';
console.log(getPaletteById(0)); // => { id: 0, colors: ['#ee7722', ...]}
isValidPaletteId
Validate a palette ID.
Returns true for integers within the range [0, 9999] inclusive.
Type: function isValidPaletteId(paletteId: number): boolean
Example
import { isValidPaletteId } from '@openpalettemodified/core';
console.log(isValidPaletteId(0)); // => true
console.log(isValidPaletteId(0.5)); // => false
console.log(isValidPaletteId(-1)); // => false
getColors
Returns the array of colors for the specified OpenPalette.
Type: function getColors(paletteId: number): OpenPaletteColors
Example
import { getColors } from '@openpalettemodified/core';
console.log(getColors(0)); // => ['#ee7722', '#dd44cc', '#ee8833', '#cc99bb', '#775511']