MCPcopy Create free account
hub / github.com/bernaferrari/FigmaToCode / processGradientStops

Function processGradientStops

packages/backend/src/common/color.ts:152–164  ·  view source on GitHub ↗
(
  stops: ReadonlyArray<ColorStop>,
  opacity: number = 1,
  colorFormatter: (color: RGB | RGBA, alpha: number) => string,
)

Source from the content-addressed store, hash-verified

150 * Helper for calculating gradient stops in a consistent way across frameworks
151 */
152export 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};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected