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