MCPcopy Index your code
hub / github.com/benfry/processing4 / map

Method map

core/src/processing/core/PApplet.java:4646–4667  ·  view source on GitHub ↗

Re-maps a number from one range to another. In the first example above, the number 25 is converted from a value in the range of 0 to 100 into a value that ranges from the left edge of the window (0) to the right edge (width). As shown in the second example, numbers outside

(float value,
                                float start1, float stop1,
                                float start2, float stop2)

Source from the content-addressed store, hash-verified

4644 * @see PApplet#lerp(float, float, float)
4645 */
4646 static public final float map(float value,
4647 float start1, float stop1,
4648 float start2, float stop2) {
4649 float outgoing =
4650 start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));
4651 String badness = null;
4652 if (outgoing != outgoing) {
4653 badness = "NaN (not a number)";
4654
4655 } else if (outgoing == Float.NEGATIVE_INFINITY ||
4656 outgoing == Float.POSITIVE_INFINITY) {
4657 badness = "infinity";
4658 }
4659 if (badness != null) {
4660 final String msg =
4661 String.format("map(%s, %s, %s, %s, %s) called, which returns %s",
4662 nf(value), nf(start1), nf(stop1),
4663 nf(start2), nf(stop2), badness);
4664 PGraphics.showWarning(msg);
4665 }
4666 return outgoing;
4667 }
4668
4669
4670 /*

Callers 15

getSortKeyMethod · 0.80
includeContributionMethod · 0.80
getPreferredSizeMethod · 0.80
checkFilesMethod · 0.80
updateErrorPointsMethod · 0.80
renameMethod · 0.80
buildIfNeededMethod · 0.80
buildJavaRuntimePathMethod · 0.80
preprocessSketchMethod · 0.80

Calls 3

nfMethod · 0.95
showWarningMethod · 0.95
formatMethod · 0.65

Tested by

no test coverage detected