Class: Ra::Pattern::Gradient

Inherits:
Base
  • Object
show all
Defined in:
lib/ra/pattern/gradient.rb

Overview

A graident pattern from ‘color_a` to `color_b` using:

color_b + (color_b - color_a) * (u + v) / 2

Instance Method Summary collapse

Constructor Details

#initialize(color_a:, color_b:) ⇒ Gradient

Returns a new instance of Gradient.

Parameters:



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

Parameters:

  • point (Vector)

    <u = 0.0..1.0, v = 0.0..1.0>

Returns:



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