Colour Interpolators
This example shows how to use colour interpolators to make working with colours easier, if for example, you need to copy paste them from a design tool.
Example Links
In this example, interpolate a hex colour value to a vec3 (hexa would produce a vec4), and a
blue color as a vec4 using rgba
(rgb would produce a vec3). The blue colour is then
converted to a vec3 with a swizzle, and the two are added together to create magenta.
inline def fragment: Shader[FragmentEnv, Unit] =
Shader[FragmentEnv] { env =>
def fragment(color: vec4): vec4 =
val red = hex"#FF0000"
val blue = rgba"0,0,255,255"
val magenta = red.xyz + blue.xyz
vec4(magenta, 1.0f)
}