Skip to content

Commit 77646c4

Browse files
committed
Clamp results of Darker and Lighter functions
Fixes #6.
1 parent e3793e2 commit 77646c4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

colors.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,13 @@ func Lighter(c color.Color, percent float64) color.Color {
161161
col, _ := colorful.MakeColor(c)
162162
h, cv, l := col.Hcl()
163163

164-
return colorful.Hcl(h, cv, l+(l*percent))
164+
return colorful.Hcl(h, cv, l+(l*percent)).Clamped()
165165
}
166166

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

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

0 commit comments

Comments
 (0)