( stops: ReadonlyArray<ColorStop>, opacity: number = 1, colorFormatter: (color: RGB | RGBA, alpha: number) => string, )
| 150 | * Helper for calculating gradient stops in a consistent way across frameworks |
| 151 | */ |
| 152 | export const processGradientStops = ( |
| 153 | stops: ReadonlyArray<ColorStop>, |
| 154 | opacity: number = 1, |
| 155 | colorFormatter: (color: RGB | RGBA, alpha: number) => string, |
| 156 | ): string => { |
| 157 | return stops |
| 158 | .map((stop) => { |
| 159 | const color = colorFormatter(stop.color, stop.color.a * opacity); |
| 160 | const position = `${(stop.position * 100).toFixed(0)}%`; |
| 161 | return `${color} ${position}`; |
| 162 | }) |
| 163 | .join(", "); |
| 164 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected