function transformColor()

in src/utils.ts [66:85]


function transformColor(
  paintColor: mbColorDefinition,
  func: (color: string) => Color
): mbColorDefinition {
  if (typeof paintColor == 'string') {
    const modifiedColor = func(paintColor);
    return `rgba(${modifiedColor.rgba().join(',')})`;
  } else if (
    typeof paintColor == 'object' &&
    'stops' in paintColor &&
    Array.isArray(paintColor?.stops)
  ) {
    const stops = paintColor['stops'].map((stop) => {
      const newColor = transformColor(stop[1], func);
      return [stop[0], newColor];
    });
    const newPaintColor = Object.assign({}, paintColor, { stops });
    return newPaintColor;
  } else return paintColor;
}