9
class SameColor < Exception
10
1
def initialize(@color : ValidColor)
11
1
super "gradient colors must be the different; got #{color} for both colors"
19
1
property range : Range(Int64, Int64)
24
10
@low_color : ValidColor = :red,
25
10
@high_color : ValidColor = :green,
26
10
@from : ColorValue | UInt8 = ColorValue.off,
27
10
@upto : ColorValue | UInt8 = ColorValue.full,
36
range : Range(Int64, Int64),
37
1
@low_color : ValidColor = :red,
38
1
@high_color : ValidColor = :green,
39
1
@from : ColorValue | UInt8 = ColorValue.off,
40
1
@upto : ColorValue | UInt8 = ColorValue.full
50
469
high_value = from + (((value - min) * (upto.to_u8 - from.to_u8)).to_f / (max - min))
51
469
low_value = ColorValue.new(upto - high_value.to_u8 + from.to_u8)
57
red: ColorValue.new(low_value),
58
green: ColorValue.new(high_value),
59
blue: ColorValue.new(from)
63
red: ColorValue.new(low_value),
64
green: ColorValue.new(from),
65
blue: ColorValue.new(high_value)
72
red: ColorValue.new(high_value),
73
green: ColorValue.new(low_value),
74
blue: ColorValue.new(from)
78
red: ColorValue.new(from),
79
green: ColorValue.new(low_value),
80
blue: ColorValue.new(high_value)
87
red: ColorValue.new(high_value),
88
green: ColorValue.new(from),
89
blue: ColorValue.new(low_value)
93
red: ColorValue.new(from),
94
green: ColorValue.new(high_value),
95
blue: ColorValue.new(low_value)
102
11
raise SameColor.new @low_color if @low_color == @high_color
106
200
(min...max).each { |c| yield self[c] }
109
include Enumerable(Color)