longbridgeapp / gpui-component

UI components write in GPUI.
Apache License 2.0
150 stars 20 forks source link

theme: Colorize::lighten() not working correctly #332

Open zhaopuming opened 6 days ago

zhaopuming commented 6 days ago

I'm using lighten to change background and found that it actually darkens the color.

Looking into the code and I found that both lighten and darken tries to decrease the Light factor, shouldn't light increase it?


    /// Return a new color with the lightness increased by the given factor.
    fn lighten(&self, factor: f32) -> Hsla {
        // TODO: should use plus instead of minus?
        let l = (self.l * 1.0 - factor.clamp(0.0, 1.0)).min(1.0);

        Hsla { l, ..*self }
    }

    /// Return a new color with the darkness increased by the given factor.
    fn darken(&self, factor: f32) -> Hsla {
        let l = (self.l * 1.0 - factor.clamp(0.0, 1.0)).max(0.0);

        Hsla { l, ..*self }
    }