---
title: "ColoringFragmentBase | Weather SDK | JavaScript maps SDK"
description: "Documentation for Weather JS"
---

# Class ColoringFragmentBase

#### Hierarchy ([View Summary](https://docs.maptiler.com/sdk-js/modules/weather/api-reference/hierarchy/#ColoringFragmentBase))

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

##### Index

### Constructors

[constructor](#constructor)

### Methods

[codeValue](#codevalue) [decodeChannel](#decodechannel) [decodeValue](#decodevalue) [getBlendCode](#getblendcode) [getCode](#getcode)

## Constructors

### constructor[](#constructor)

-   new ColoringFragmentBase(  
        code: string,  
        decode: [DecoderOptions](https://docs.maptiler.com/sdk-js/modules/weather/api-reference/interfaces/DecoderOptions/),  
    ): ColoringFragmentBase[](#constructorcoloringfragmentbase)
    
    #### Parameters
    
    -   code: string
        
        Inputs: `vec4 dst`, `vec4 data`. Outputs into `dst`.
        
    -   decode: [DecoderOptions](https://docs.maptiler.com/sdk-js/modules/weather/api-reference/interfaces/DecoderOptions/)
    
    #### Returns ColoringFragmentBase
    

## Methods

### codeValue[](#codevalue)

-   codeValue(value: number): number[](#codevalue-1)
    
    Get the value in the unit interval \[0, 1\] computed with `.decode.min` and `.decode.max`
    
    #### Parameters
    
    -   value: number
    
    #### Returns number
    

### decodeChannel[](#decodechannel)

-   decodeChannel(pixel: [Pixel](https://docs.maptiler.com/sdk-js/modules/weather/api-reference/interfaces/Pixel/)): number | number\[\][](#decodechannel-1)
    
    Get real world values of the given pixel (with rgb or rgba in \[0, 1\]) for the channel(s) specified in `.decode.channel`
    
    #### Parameters
    
    -   pixel: [Pixel](https://docs.maptiler.com/sdk-js/modules/weather/api-reference/interfaces/Pixel/)
    
    #### Returns number | number\[\]
    

### decodeValue[](#decodevalue)

-   decodeValue(value: number): number[](#decodevalue-1)
    
    Given a value in the unit interval \[0, 1\] get the real world value bounded by `.decode.min` and `.decode.max`
    
    #### Parameters
    
    -   value: number
    
    #### Returns number
    

### getBlendCode[](#getblendcode)

-   getBlendCode(name: string): string[](#getblendcode-1)
    
    Generate shader/GLSL code for blending
    
    #### Parameters
    
    -   name: string
    
    #### Returns string
    

### getCode[](#getcode)

-   getCode(name: string): string[](#getcode-1)
    
    Generate shader/GLSL code
    
    #### Parameters
    
    -   name: string
    
    #### Returns string
