MCPcopy Index your code
hub / github.com/processing/processing / map

Method map

core/src/processing/core/PApplet.java:5068–5089  ·  view source on GitHub ↗

( begin auto-generated from map.xml ) Re-maps a number from one range to another. In the example above, the number '25' is converted from a value in the range 0..100 into a value that ranges from the left edge (0) to the right edge (width) of the screen. Numbers outside the range are no

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

Source from the content-addressed store, hash-verified

5066 * @see PApplet#lerp(float, float, float)
5067 */
5068 static public final float map(float value,
5069 float start1, float stop1,
5070 float start2, float stop2) {
5071 float outgoing =
5072 start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));
5073 String badness = null;
5074 if (outgoing != outgoing) {
5075 badness = "NaN (not a number)";
5076
5077 } else if (outgoing == Float.NEGATIVE_INFINITY ||
5078 outgoing == Float.POSITIVE_INFINITY) {
5079 badness = "infinity";
5080 }
5081 if (badness != null) {
5082 final String msg =
5083 String.format("map(%s, %s, %s, %s, %s) called, which returns %s",
5084 nf(value), nf(start1), nf(stop1),
5085 nf(start2), nf(stop2), badness);
5086 PGraphics.showWarning(msg);
5087 }
5088 return outgoing;
5089 }
5090
5091
5092 /*

Callers 14

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

Calls 3

nfMethod · 0.95
showWarningMethod · 0.95
formatMethod · 0.65

Tested by

no test coverage detected