* Halfway between rgb(255, 0, 0) and rgb(0, 0, 255) is rgb(128, 0, 128).
(Well, it's good at strings, not color science.)
-To try more, open up [demo.html] in your browser.
+To try more, open up [demo.html][] in your browser.
## Setting Up
Or if you're using Node or some other non-browser whatever,
- var stringLerp = require("./string-lerp");
+ var stringLerp = require("string-lerp");
If you want a minified version, at a shell run
## API
-### stringLerp.lerp(a, b, p)
+### stringLerp.lerp(source, target, amount)
-Interpolate between strings a and b, given a parameter p.
+Interpolate between strings as best as possible.
This automatically picks the best interpolator based on the strings
provided. If the strings are identical aside from numbers in them,
Otherwise, they are passed through `fastLerp`.
-### stringLerp.numericLerp(a, b, p)
+### stringLerp.numericLerp(source, target, amount)
-Lerp all the numbers in the string from their values in `a` to their
-values in `b`.
+Interpolate numerically between strings containing numbers.
Numbers may have a leading "-" and a single "." to mark the decimal
point, but something must be after the ".". No other floating point
gives undefined results.
-### stringLerp.diffLerp(a, b, p)
+### stringLerp.diffLerp(source, target, amount)
-Lerp from `a` to `b` based on edit operations.
+Interpolate between two strings using edit operations.
This interpolation algorithm applys a partial edit of one string into
the other. This produces nice looking results, but can take a
recommended for strings longer than a few hundred characters.
-### stringLerp.fastLerp(a, b, p)
+### stringLerp.fastLerp(source, target, amount)
-Lerp from `a` to `b` using a simple algorithm based on length.
+Interpolate between `source` to `target` based on length.
This interpolation algorithm progressively replaces the front of one
string with another. This approach is fast but does not look good when
the strings are similar.
-### stringLerp.diff(s, t) and stringLerp.patch(edits, s)
+### stringLerp.diff(source, target) and stringLerp.patch(diff, source)
These are the functions used to implement `diffLerp`. `diff`
calculates an array of edit operations - substitutions, insertions,
-and deletions - to turn `s` into `t`.
+and deletions - to turn `source` into `target`.
The type of the edit operations is unspecified. What is guaranteed is:
operations) between versions / installations.
-### stringLerp.levenshteinMatrix(s, t, ins, del, sub)
+### stringLerp.costMatrix(source, target, ins, del, sub)
Calculate the edit distance between the source and target sequences,
and return a matrix representing the possible edits and their
same string. The codepoints indicating bidi switches may move around
the string capturing glyphs in ways that are not visually appealing.
+## License
+
+ Copyright 2014 Joe Wreschnig
+ Licensed under the terms of the GNU GPL v2 or later
+ @license http://www.gnu.org/licenses/gpl-2.0.html
+ @source: http://yukkurigames.com/string-lerp/
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ As additional permission, you may distribute the program or works
+ based on it without the copy of the GNU GPL normally required,
+ provided you include this license notice and a URL through which
+ recipients can access the corresponding source code.
[NPM]: https://www.npmjs.org/
<script type="text/javascript" src="string-lerp.js"></script>
<script>
var DEMOS = [
+ ["explore", "implode"],
["Do you like green eggs and ham?", "I do not like them, Sam-I-am."],
["apple core", "core dump"],
["rgb(255, 0, 0)", "rgb(0, 128, 255)"],
+ ["chicken wing", "buffalo wing"],
["1.50 + 1.50 = 3.0", "3 + 7 = 10"],
+ ["<(o.o<) v(._.)v", "(>o.o)> ^(*_*)^"],
["ZALGO̸", "ZA̢LG͜O"],
["", "Typing, one letter at a time."],
["( ノ゚▽゚)ノ", "( ╯︵╰)"]
/* string-lerp - progressively turn one string into another
Copyright 2014 Joe Wreschnig
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+ Licensed under the terms of the GNU GPL v2 or later
+ @license http://www.gnu.org/licenses/gpl-2.0.html
+ @source: http://yukkurigames.com/string-lerp/
+*//*
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ As additional permission, you may distribute the program or works
+ based on it without the copy of the GNU GPL normally required,
+ provided you include this license notice and a URL through which
+ recipients can access the corresponding source code.
*/
-/* @license Copyright 2014 Joe Wreschnig - GNU GPL v2 or later */
/*globals exports, Uint32Array */
(function (exports) {