colorToGLSLString
colorToGLSLString(
val):string
Defined in: packages/sigma/src/utils/colors.ts:323
Converts a color string to a GLSL vec4 string representation. The output can be used directly in GLSL shaders.
Parameters
Section titled “Parameters”string
Color string (hex, rgb, rgba, or HTML color name)
Returns
Section titled “Returns”string
GLSL vec4 string, e.g. “vec4(1.0, 0.0, 0.0, 1.0)” for red
Example
Section titled “Example”colorToGLSLString("#ff0000") // "vec4(1.0, 0.0, 0.0, 1.0)"colorToGLSLString("red") // "vec4(1.0, 0.0, 0.0, 1.0)"colorToGLSLString("rgb(255, 0, 0)") // "vec4(1.0, 0.0, 0.0, 1.0)"colorToGLSLString("rgba(255, 0, 0, 0.5)") // "vec4(1.0, 0.0, 0.0, 0.5)"