---
title: "ColoringFragment | Weather"
description: "Weather module coloring fragments API reference."
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# ColoringFragment

Functions to generate coloring from the pixel values. Describes how to read the data value from the input files and transform the values to colors.

## GradientColoringFragment

Use color gradient to generate coloring from the pixel values.

**Example**

```js
import { GradientColoringFragment, ColorRamp } from "@maptiler/weather";

  const gradientColor = new GradientColoringFragment({
      decode: {
        channel: 'r',
        min: 0,
        max: 255,
      },
      stops: ColorRamp.builtin.TURBO.scale(0, Math.sqrt(45000)), // we want to cap at 45k ppl/sqkm
      smooth: true,
      opacity: 1
    })
```

### API reference

[Class GradientColoringFragment](https://docs.maptiler.com/sdk-js/modules/weather/api-reference/classes/GradientColoringFragment/)

## OpacityColoringFragment

Use a single color, only change opacity based on the decoded value.

**Example**

```js
import { OpacityColoringFragment } from "@maptiler/weather";

  const opacityColor = new OpacityColoringFragment({
    decode: {
      channel: 'r',
      min: 0,
      max: 255,
    },
    color: [255, 255, 255],
    opacity: 1
  });
```

### API reference

[Class OpacityColoringFragment](https://docs.maptiler.com/sdk-js/modules/weather/api-reference/classes/OpacityColoringFragment/)

## MultiChannelGradientColoringFragment

Interpret image channels in the context of a multi channel gradient coloring fragment.

**Example**

```js
import { MultiChannelGradientColoringFragment } from "@maptiler/weather";

  const opacityColor = new MultiChannelGradientColoringFragment({
    decode: {
      polynomialCoefDegree2: 0,
      polynomialCoefDegree1: 1,
      polynomialConstant: 0,
    },
    stopsPerCategory: [
      {
        category: "all",
        stops: [
          { value: 0, color: [0, 0, 0] },
          { value: 255, color: [255, 255, 255] },
        ],
      },
    ],
    opacity: 1
  });
```

### API reference

[Class MultiChannelGradientColoringFragment](https://docs.maptiler.com/sdk-js/modules/weather/api-reference/classes/MultiChannelGradientColoringFragment/)
