Skip to content
sigma.js sigma.js
v4.0.6 Docs Examples GitHub 12.2K

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.

string

Color string (hex, rgb, rgba, or HTML color name)

string

GLSL vec4 string, e.g. “vec4(1.0, 0.0, 0.0, 1.0)” for red

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)"