public static transformColorProperties()

in src/tms_service.ts [227:268]


  public static transformColorProperties(
    layer: LayerSpecification,
    color?: string,
    operation?: blendMode,
    percentage?: number
  ): { property: keyof layerPaintProperty; color: mbColorDefinition | undefined }[] {
    if (['background', 'fill', 'line', 'symbol'].indexOf(layer.type) !== -1 && layer.paint) {
      const paint = layer.paint as layerPaintProperty;
      if (layer.type === 'symbol' && Object.keys(paint).length === 0) {
        paint['text-color'] = 'rgb(0,0,0)';
      }
      const types = Object.keys(paint).filter((key) => {
        return (
          [
            'background-color',
            'circle-color',
            'circle-stroke-color',
            'fill-color',
            'fill-extrusion-color',
            'fill-outline-color',
            'icon-color',
            'icon-halo-color',
            'line-color',
            'text-color',
            'text-halo-color',
          ].indexOf(key) !== -1
        );
      }) as Array<keyof layerPaintProperty>;
      return types.map((type) => {
        const paintColor = paint[type];
        return {
          property: type,
          color:
            paintColor && color
              ? colorizeColor(paintColor, color, operation, percentage)
              : paintColor,
        };
      });
    } else {
      return [];
    }
  }