Class: GeoPattern::BasePattern
- Inherits:
-
Struct
- Object
- Struct
- GeoPattern::BasePattern
- Defined in:
- lib/geo_pattern/pattern/base_pattern.rb
Direct Known Subclasses
ChevronPattern, ConcentricCirclesPattern, DiamondPattern, HexagonPattern, MosaicSquaresPattern, NestedSquaresPattern, OctagonPattern, OverlappingCirclesPattern, OverlappingRingsPattern, PlaidPattern, PlusSignPattern, SineWavePattern, SquarePattern, TessellationPattern, TrianglePattern, XesPattern
Constant Summary collapse
- FILL_COLOR_DARK =
"#222"
- FILL_COLOR_LIGHT =
"#ddd"
- STROKE_COLOR =
"#000"
- STROKE_OPACITY =
0.02
- OPACITY_MIN =
0.02
- OPACITY_MAX =
0.15
Instance Attribute Summary collapse
-
#hash ⇒ Object
Returns the value of attribute hash.
-
#svg ⇒ Object
Returns the value of attribute svg.
Instance Method Summary collapse
- #fill_color(val) ⇒ Object
- #hex_val(index, len) ⇒ Object
- #map(value, v_min, v_max, d_min, d_max) ⇒ Object
- #opacity(val) ⇒ Object
-
#render_to_svg ⇒ Object
Public: mutate the given ‘svg` object with a rendered pattern.
Instance Attribute Details
#hash ⇒ Object
Returns the value of attribute hash
2 3 4 |
# File 'lib/geo_pattern/pattern/base_pattern.rb', line 2 def hash @hash end |
#svg ⇒ Object
Returns the value of attribute svg
2 3 4 |
# File 'lib/geo_pattern/pattern/base_pattern.rb', line 2 def svg @svg end |
Instance Method Details
#fill_color(val) ⇒ Object
27 28 29 |
# File 'lib/geo_pattern/pattern/base_pattern.rb', line 27 def fill_color(val) (val.even?) ? FILL_COLOR_LIGHT : FILL_COLOR_DARK end |
#hex_val(index, len) ⇒ Object
23 24 25 |
# File 'lib/geo_pattern/pattern/base_pattern.rb', line 23 def hex_val(index, len) PatternHelpers.hex_val(hash, index, len) end |
#map(value, v_min, v_max, d_min, d_max) ⇒ Object
35 36 37 |
# File 'lib/geo_pattern/pattern/base_pattern.rb', line 35 def map(value, v_min, v_max, d_min, d_max) PatternHelpers.map(value, v_min, v_max, d_min, d_max) end |
#opacity(val) ⇒ Object
31 32 33 |
# File 'lib/geo_pattern/pattern/base_pattern.rb', line 31 def opacity(val) map(val, 0, 15, OPACITY_MIN, OPACITY_MAX) end |
#render_to_svg ⇒ Object
Public: mutate the given ‘svg` object with a rendered pattern
Note: this method must be implemented by sub- classes.
svg - the SVG container
Returns a reference to the same ‘svg` object only this time with more patterns.
19 20 21 |
# File 'lib/geo_pattern/pattern/base_pattern.rb', line 19 def render_to_svg raise NotImplementedError end |