import type { NumericArray } from "@thi.ng/api" ; import { tween } from "@thi.ng/transducers/tween" ; import { setS4 } from "@thi.ng/vectors/sets" ; import type { TypedColor } from "./api.js" ; import type { GradientOpts } from "./api/gradients.js" ; import { mix as $mix } from "./mix.js" ; /**
 * Similar to  multiCosineGradient , but using any number of gradient
 * color stops and isn't limited to RGB, but for arbitrary color types.
 *
 *  remarks see {@link @thi.ng/transducers#tween} example param opts export const multiColorGradient = < T extends TypedColor < any > > ( opts ) => [ ... gradient ( opts ) ] ; /**
 * Similar to  multiColorGradient , but writes results into `buffer` from
 * given `offset` and component/element strides. Returns buffer.
 *
 *  remarks see cosineGradientBuffer .
 *
 *  param opts param buffer param offset param cstride param estride export const multiColorGradientBuffer = < T extends TypedColor < any > > ( opts , buffer = [ ] , offset = 0 , cstride = 1 , estride = 4 ) => { for ( let col of gradient ( opts ) ) { setS4 ( buffer , col , offset , 0 , cstride ) ; offset += estride ; } return buffer ; } ; internal const gradient = < T extends TypedColor < any > > ( { num , stops , easing , mix , } ) : Iterable < T > => tween < T , T [ ] , T > ( { num : num - 1 , stops , easing , min : 0 , max : 1 , init : ( a , b ) => [ a , b ] , mix : mix ? ( [ a , b ] , t ) => < T > mix ( a . empty ( ) , a , b , t ) : ( [ a , b ] , t ) => < T > $mix ( a . empty ( ) , a , b , t ) , } ) ;