31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/color_fun/gradient.rb', line 31
def at(point)
window = point / color_window_size
if point == @resolution
difference = differences.last
position = color_window_size
window = differences.size - 1
else
difference = differences[window]
position = point % color_window_size
end
new_colors = difference.each_with_index.map do |dc, i|
(colors[window][i] + (dc * (position.to_f / color_window_size.to_f))).to_i
end
ColorFun::RGB.new(*new_colors)
end
|