Class: Ra::Pattern::Gradient
Overview
A graident pattern from ‘color_a` to `color_b` using:
color_b + (color_b - color_a) * (u + v) / 2
Instance Method Summary collapse
- #color(point:) ⇒ Ra::Color
-
#initialize(color_a:, color_b:) ⇒ Gradient
constructor
A new instance of Gradient.
Constructor Details
#initialize(color_a:, color_b:) ⇒ Gradient
Returns a new instance of Gradient.
11 12 13 14 15 |
# File 'lib/ra/pattern/gradient.rb', line 11 def initialize(color_a:, color_b:) super() @color_a = color_a @color_b = color_b end |
Instance Method Details
#color(point:) ⇒ Ra::Color
19 20 21 22 23 24 25 |
# File 'lib/ra/pattern/gradient.rb', line 19 def color(point:) u = point[0] v = point[1] value = (u + v) / 2 @color_a + ((@color_b - @color_a) * value) end |