UNPKG

@design-automation/mobius-inline-funcs

Version:
30 lines (29 loc) 1.03 kB
import { TColor } from '../../libs/common'; /** * Creates a color from a string representation. * * \n * * Examples of color strings are as follows: * * - `colFromStr( "rgb(255, 0, 0)`" )` * - `colFromStr( "rgb(100%, 0%, 0%)`" )` * - `colFromStr( "hsl(0, 100%, 50%)`" )` * - `colFromStr( "#ff0000" )` * - `colFromStr( "#FFAABB" )` * - `colFromStr( "#f00" )` * - `colFromStr( "skyblue" )` * - `colFromStr( "Maroon" )` * - `colFromStr( "MediumSeaGreen" )` * * For colour names, all 140 names are supported. See <a * href="https://www.w3schools.com/colors/colors_names.asp" target="_blank">w3schools</a>. * * If the string cannot be interpreted as a color, then `[1, 1, 1]` is returned (i.e. white). * * The function is overloaded. If you pass in a list of strings, it will return a list of colors. * * @param col_str * @returns A list of three numbers, `[r, g, b]`, in the range 0 to 1. */ export declare function colFromStr(col_str: string | string[]): TColor | TColor[];