From: Joe Wreschnig Date: Mon, 19 May 2014 08:39:35 +0000 (+0200) Subject: Update documentation to reflect new numericLerp behavior. X-Git-Tag: 1.0.0~8 X-Git-Url: https://git.yukkurigames.com/?a=commitdiff_plain;h=203ddaf6c8bc3326257cfeeda9a01752fbc7ab5c;p=string-lerp.git Update documentation to reflect new numericLerp behavior. --- diff --git a/README.md b/README.md index 6d89262..d96fd9f 100644 --- a/README.md +++ b/README.md @@ -60,12 +60,13 @@ Otherwise, they are passed through `fastLerp`. Lerp all the numbers in the string from their values in `a` to their values in `b`. -Numbers may have a leading `-` and a single `.` to mark the decimal -point, but something must be after the `.`. If both of the numbers in -a pair are integers, the result is clamped to an integer. +Numbers may have a leading "-" and a single "." to mark the decimal +point, but something must be after the ".". No other floating point +syntax (e.g. `1e6`) is supported. They are treated as fixed-point +values, with the point's position itself interpolating. -For example, `numericLerp("0.0", "100", 0.123) === "12.3"` because the -`.` in `0.0` is interpreted as a decimal point. +For example, `numericLerp("0.0", "100.0", 0.123) === "12.3"` because +the `.` in `0.0` is interpreted as a decimal point. But `numericLerp("0.", "100.", 0.123) === "12."` because the strings are interpreted as integers followed by a full stop. diff --git a/string-lerp.js b/string-lerp.js index 114bebd..8e3ef64 100644 --- a/string-lerp.js +++ b/string-lerp.js @@ -182,10 +182,10 @@ Numbers may have a leading "-" and a single "." to mark the decimal point, but something must be after the ".". No other floating point syntax (e.g. 1e6) is supported. - If both of the numbers in a pair are integers, the result - is clamped to an integer. + They are treated as fixed-point values, with the point's + position itself interpolating. - For example, numericLerp("0.0", "100", 0.123) === "12.3" + For example, numericLerp("0.0", "100".0, 0.123) === "12.3" because the "." in "0.0" is interpreted as a decimal point. But numericLerp("0.", "100.", 0.123) === "12." because the strings are interpreted as integers followed