Class: Ra::Pattern::Stripes
Overview
A stripe pattern that alternates colors using:
colors[⌊point.x⌋]
Instance Method Summary collapse
- #color(point:) ⇒ Ra::Color
-
#initialize(colors:) ⇒ Stripes
constructor
A new instance of Stripes.
Constructor Details
#initialize(colors:) ⇒ Stripes
Returns a new instance of Stripes.
10 11 12 13 |
# File 'lib/ra/pattern/stripes.rb', line 10 def initialize(colors:) super() @colors = colors end |
Instance Method Details
#color(point:) ⇒ Ra::Color
17 18 19 20 21 22 23 24 |
# File 'lib/ra/pattern/stripes.rb', line 17 def color(point:) count = @colors.count u = point[0] v = point[1] value = (u + v) * (2 * count) @colors[value.floor % count] end |