Skip to main content

linear_gradient

Function linear_gradient 

Source
pub fn linear_gradient(
    angle: f32,
    from: impl Into<LinearColorStop>,
    to: impl Into<LinearColorStop>,
) -> Background
Expand description

Creates a linear gradient between two color stops.

angle is the direction of the gradient line in degrees, from 0. (up) increasing clockwise. The colors are interpolated in ColorSpace::Oklab. Call Background::color_space to interpolate in sRGB instead.

ยงExamples

use gpui::{ColorSpace, blue, linear_color_stop, linear_gradient, red};

let gradient = linear_gradient(
    180.,
    linear_color_stop(red(), 0.),
    linear_color_stop(blue(), 1.),
);
assert_eq!(gradient.interpolation_space(), ColorSpace::Oklab);

https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient