Module: GeoPattern::PatternHelpers
- Defined in:
- lib/geo_pattern/pattern/pattern_helpers.rb
Class Method Summary collapse
- .hex_val(hash, index, length) ⇒ Object
-
.map(value, v_min, v_max, d_min, d_max) ⇒ Object
Ruby implementation of Processing’s map function processing.org/reference/map_.html.
Class Method Details
.hex_val(hash, index, length) ⇒ Object
5 6 7 |
# File 'lib/geo_pattern/pattern/pattern_helpers.rb', line 5 def self.hex_val(hash, index, length) hash[index, length || 1].to_i(16) end |
.map(value, v_min, v_max, d_min, d_max) ⇒ Object
Ruby implementation of Processing’s map function processing.org/reference/map_.html
11 12 13 14 15 16 17 |
# File 'lib/geo_pattern/pattern/pattern_helpers.rb', line 11 def self.map(value, v_min, v_max, d_min, d_max) # v for value, d for desired v_value = value.to_f # so it returns float v_range = v_max - v_min d_range = d_max - d_min (v_value - v_min) * d_range / v_range + d_min end |