Обработка с открытым исходным кодом.Вы можете просмотреть map()
функцию здесь .
static public final float map(float value,
float start1, float stop1,
float start2, float stop2) {
float outgoing =
start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));
String badness = null;
if (outgoing != outgoing) {
badness = "NaN (not a number)";
} else if (outgoing == Float.NEGATIVE_INFINITY ||
outgoing == Float.POSITIVE_INFINITY) {
badness = "infinity";
}
if (badness != null) {
final String msg =
String.format("map(%s, %s, %s, %s, %s) called, which returns %s",
nf(value), nf(start1), nf(stop1),
nf(start2), nf(stop2), badness);
PGraphics.showWarning(msg);
}
return outgoing;
}
В частности, вы ищете эту строку кода:
float outgoing =
start2 + (stop2 - start2) * ((value - start1) / (stop1 - start1));