Class: GeoPattern::PlaidPattern
- Inherits:
-
BasePattern
- Object
- Struct
- BasePattern
- GeoPattern::PlaidPattern
- Defined in:
- lib/geo_pattern/pattern/plaid_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 45 46 47 |
# File 'lib/geo_pattern/pattern/plaid_pattern.rb', line 3 def render_to_svg height = 0 width = 0 # horizontal stripes i = 0 18.times do space = hex_val(i, 1) height += space + 5 val = hex_val(i+1, 1) opacity = opacity(val) fill = fill_color(val) stripe_height = val + 5 svg.rect(0, height, "100%", stripe_height, { "opacity" => opacity, "fill" => fill }) height += stripe_height i += 2 end # vertical stripes i = 0 18.times do space = hex_val(i, 1) width += space + 5 val = hex_val(i+1, 1) opacity = opacity(val) fill = fill_color(val) stripe_width = val + 5 svg.rect(width, 0, stripe_width, "100%", { "opacity" => opacity, "fill" => fill }) width += stripe_width i += 2 end svg.set_width(width) svg.set_height(height) end |