Sha256: 784959dfc659859918f1f3c3827a4b63fc25a6a7c00f0b5989103b4058885055
Contents?: true
Size: 1.53 KB
Versions: 34
Compression:
Stored size: 1.53 KB
Contents
--- layout: post title: "map1d in detail" permalink: methods/map1d.html --- ### Name ### `map1d` _NB: a different was used than vanilla processing because `map` has another meaning in ruby and we anticipate a possible `map2d` or even `map3d`_. ### Examples ### ```ruby #!/usr/bin/env jruby -w require 'picrate' class UsingMap1D < Processing::App def settings size(200, 200) end def setup sketch_title 'Using map1d' no_stroke end def draw background(204) x1 = map1d(mouse_x, (0..width), (50..150)) ellipse(x1, 75, 50, 50) x2 = map1d(mouse_x, (0..width), (0..200)) ellipse(x2, 125, 50, 50) end end UsingMap1D.new ``` ### Description ### Re-maps a number from one range to another. As shown in the example, numbers outside of the range are not clamped to the minimum and maximum parameters values, because out-of-range values are often intentional and useful. ### Syntax ### ```ruby map1d(value, (start1..stop1), (start2..stop2)) ``` ### Parameters ### value the incoming value to be converted start1 lower bound of the value's current range stop1 upper bound of the value's current range start2 lower bound of the value's target range stop2 upper bound of the value's target range Returns float ### Related ### `constrained_map` (numbers are clamped to range) `p5map` (same signature as [processing map][map]) `norm` (same as [processing norm][norm]) `norm_strict` (output is clamped to 0..1.0) `lerp` [norm]:https://processing.org/reference/norm_.html [map]:https://processing.org/reference/map_.html
Version data entries
34 entries across 34 versions & 1 rubygems