/* https://grabient.com/_gKkgHPgKdgD_gFxgGhgLOgL8gJkgNKgEsgXR?style=linearGradient&steps=3&angle=45 */
background: linear-gradient(45deg, #d05941 0.000%, #c04fc8 50.000%, #70cdff 100.000%);
<svg xmlns="http://www.w3.org/2000/svg" width="800" height="400" viewBox="0 0 800 400" preserveAspectRatio="none">
<!-- https://grabient.com/_gKkgHPgKdgD_gFxgGhgLOgL8gJkgNKgEsgXR?style=linearGradient&steps=3&angle=45 -->
<defs>
<linearGradient id="gradient" x1="0.146" y1="0.854" x2="0.854" y2="0.146">
<stop offset="0.000" stop-color="#d05941" /><stop offset="0.500" stop-color="#c04fc8" /><stop offset="1.000" stop-color="#70cdff" />
</linearGradient>
</defs>
<rect x="0" y="0" width="800" height="400" fill="url(#gradient)" />
</svg>
["#d05941", "#c04fc8", "#70cdff"]
// https://grabient.com/_gKkgHPgKdgD_gFxgGhgLOgL8gJkgNKgEsgXR?style=linearGradient&steps=3&angle=45
// cosine gradient palette — https://iquilezles.org/articles/palettes/
const float STEPS = 3.0;
const float ANGLE = 45.0;
vec3 palette(float t) {
vec3 a = vec3(0.676, 0.463, 0.669);
vec3 b = vec3(0.255, 0.369, 0.417);
vec3 c = vec3(0.718, 0.764, 0.612);
vec3 d = vec3(0.842, 0.300, 1.489);
return a + b * cos(6.283185 * (c * t + d));
}
// N stops sampled from the palette, blended like the CSS gradient
vec3 stops(float t) {
float n = STEPS - 1.0;
float x = clamp(t, 0.0, 1.0) * n;
return mix(palette(floor(x) / n), palette(min(floor(x) + 1.0, n) / n), fract(x));
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 p = fragCoord - 0.5 * iResolution.xy;
// CSS angle: 0 = up, clockwise; span = CSS gradient-line length
vec2 dir = vec2(sin(radians(ANGLE)), cos(radians(ANGLE)));
float len = abs(iResolution.x * dir.x) + abs(iResolution.y * dir.y);
float t = dot(p, dir) / len + 0.5;
fragColor = vec4(stops(t), 1.0);
}
[
[0.676, 0.463, 0.669],
[0.255, 0.369, 0.417],
[0.718, 0.764, 0.612],
[0.842, 0.300, 1.489]
]