Class: GeoPattern::OverlappingRingsPattern
- Inherits:
-
BasePattern
- Object
- Struct
- BasePattern
- GeoPattern::OverlappingRingsPattern
- Defined in:
- lib/geo_pattern/pattern/overlapping_rings_pattern.rb
Constant Summary
Constants inherited from BasePattern
BasePattern::FILL_COLOR_DARK, BasePattern::FILL_COLOR_LIGHT, BasePattern::OPACITY_MAX, BasePattern::OPACITY_MIN, BasePattern::STROKE_COLOR, BasePattern::STROKE_OPACITY
Instance Attribute Summary
Attributes inherited from BasePattern
Instance Method Summary collapse
Methods inherited from BasePattern
#fill_color, #hex_val, #map, #opacity
Instance Method Details
#render_to_svg ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/geo_pattern/pattern/overlapping_rings_pattern.rb', line 3 def render_to_svg scale = hex_val(0, 1) ring_size = map(scale, 0, 15, 10, 60) stroke_width = ring_size / 4 svg.set_width(ring_size * 6) svg.set_height(ring_size * 6) i = 0 for y in 0..5 for x in 0..5 val = hex_val(i, 1) opacity = opacity(val) fill = fill_color(val) styles = { "fill" => "none", "stroke" => fill, "style" => { "opacity" => opacity, "stroke-width" => "#{stroke_width}px" } } svg.circle(x*ring_size, y*ring_size, ring_size - stroke_width/2, styles) # Add an extra one at top-right, for tiling. if (x == 0) svg.circle(6*ring_size, y*ring_size, ring_size - stroke_width/2, styles) end if (y == 0) svg.circle(x*ring_size, 6*ring_size, ring_size - stroke_width/2, styles) end if (x == 0 and y == 0) svg.circle(6*ring_size, 6*ring_size, ring_size - stroke_width/2, styles) end i += 1 end end end |