import { Color } from '../Color' ; import { Scheme } from '../interfaces' ; param scheme param path export function getNamedSchemeColor ( scheme , path ? ) { if ( ! path || path === 'none' ) { return new Color ( 'none' ) ; } const indexed = indexedTest ( path ) ; if ( indexed ) { return new Color ( ( scheme as any ) [ indexed . name ] [ indexed . index ] ) ; } return new Color ( ( scheme as any ) [ path ] ) ; } function indexedTest ( path ) { const indexedName = path . match ( /(\w+)\[/ ) ; const indexedIndex = path . match ( /\[(\d{1,2})\]/ ) ; if ( indexedName && indexedIndex ) { return { name : indexedName [ 1 ] , index : + indexedIndex [ 1 ] , } ; } }