CrImage::Color
Inherits Reference < Object
Utility class for parsing and representing colors that can be used for certain methods in CrImage.
See Operation::MaskApply#apply_color, Operation::Draw#draw_square, or Operation::Draw#draw_circle
Constructors
default
Sourcenew(red : UInt8, green : UInt8, blue : UInt8, alpha : UInt8 = ChannelType::Alpha.default)
Sourceof(color : String) : Color
Parse color from a hex string:
Color.of("#1") # same as "#11" => Color.new(17, 17, 17, 255)
Color.of("#01") # => Color.new(1, 1, 1, 255)
Color.of("#123") # same as "#112233" => Color.new(17, 34, 51, 255)
Color.of("#1234") # same as "#11223344" => Color.new(34, 51, 68, 17)
Color.of("#010203") # => Color.new(1, 2, 3, 255)
Color.of("#01020304") # => Color.new(2, 3, 4, 1)
Instance methods
==(other : Color) : Bool
Source[](channel_type : ChannelType) : UInt8
Receive the UInt8 portion of this color corresponding to channel_type
alpha
Sourceblue
Sourcedist(other : Color, *, manhattan : Bool = false) : Float64
Sourcegray(red_multiplier : Float = 0.299, green_multiplier : Float = 0.587, blue_multiplier : Float = 0.114) : UInt8
Convert this Color to a single UInt8 gray value
green
Sourcered
Source