Skip to content

Commit

Permalink
Clamp results of Darker and Lighter functions
Browse files Browse the repository at this point in the history
Fixes #6.
  • Loading branch information
muesli committed Nov 1, 2020
1 parent e3793e2 commit 77646c4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions colors.go
Expand Up @@ -161,13 +161,13 @@ func Lighter(c color.Color, percent float64) color.Color {
col, _ := colorful.MakeColor(c)
h, cv, l := col.Hcl()

return colorful.Hcl(h, cv, l+(l*percent))
return colorful.Hcl(h, cv, l+(l*percent)).Clamped()
}

// Darker returns a darker version of the specified color
func Darker(c color.Color, percent float64) color.Color {
col, _ := colorful.MakeColor(c)
h, cv, l := col.Hcl()

return colorful.Hcl(h, cv, l-(l*percent))
return colorful.Hcl(h, cv, l-(l*percent)).Clamped()
}

0 comments on commit 77646c4

Please sign in to comment.