Sidechair

color.b()

Browse the reference

Returns the blue channel of a color as a number from 0 to 255.

Try it in the editor

color.b reads the blue part of a color. Pure blue gives 255 and black gives 0.

Use it with color.r and color.g to compare colors or to build a darker or lighter variant through color.rgb.

Syntax

Pine Script
color.b(color: series color) -> series float
color.b(color: const color) -> const float
color.b(color: input color) -> input float
color.b(color: simple color) -> simple float

Arguments

NameTypeDefaultDescription
colorconst/input/simple/series colorrequiredThe color to take the blue part from. na gives na.

Returns

const/input/simple/series float: the blue value from 0 to 255; na if the color is na.

Remarks

  • Hex colors such as #3355FF give the same channels you wrote in the code.

Example

Pine ScriptBlue of a hex colorOpen in editor
//@version=6
indicator("Blue channel")
plot(color.b(#3355FF), "Blue", color = color.blue)
plot(color.r(#3355FF), "Red", color = color.red)

See also

Runs on Sidechair