Skip to content

Commit 160a2cb

Browse files
committed
Convenience for lightness changes.
1 parent 9a427cb commit 160a2cb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ColorSetKit/NSColor+ColorSetKit.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,16 @@ import Cocoa
374374
return NSColor( hue: hsl.0, saturation: hsl.1, lightness: l, alpha: a )
375375
}
376376

377+
@objc func byIncreasingLightness( _ l: CGFloat ) -> NSColor
378+
{
379+
return self.byChangingLightness( self.hsl().lightness + l )
380+
}
381+
382+
@objc func byDecreasingLightness( _ l: CGFloat ) -> NSColor
383+
{
384+
return self.byChangingLightness( self.hsl().lightness - l )
385+
}
386+
377387
@nonobjc private class func componentsForColorName( _ name: String ) -> ( name: String, lightness: CGFloat?, variant: String? )
378388
{
379389
guard let r = name.range( of: ".", options: .backwards ) else

0 commit comments

Comments
 (0)