summaryrefslogtreecommitdiffstats
path: root/src/number.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/number.js')
-rwxr-xr-xsrc/number.js31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/number.js b/src/number.js
index 2b3b147..7218a50 100755
--- a/src/number.js
+++ b/src/number.js
@@ -45,13 +45,6 @@ SVG.extend(SVG.Number, {
valueOf: function() {
return this.value
}
- // Convert to different unit
-, to: function(unit) {
- if (typeof unit === 'string')
- this.unit = unit
-
- return this
- }
// Add number
, plus: function(number) {
this.value = this + new SVG.Number(number)
@@ -74,5 +67,29 @@ SVG.extend(SVG.Number, {
return this
}
+ // Convert to different unit
+, to: function(unit) {
+ if (typeof unit === 'string')
+ this.unit = unit
+
+ return this
+ }
+ // Make number morphable
+, morph: function(number) {
+ this.destination = new SVG.Number(number)
+
+ return this
+ }
+ // Get morphed number at given position
+, at: function(pos) {
+ /* make sure a destination is defined */
+ if (!this.destination) return this
+
+ /* generate morphed number */
+ return new SVG.Number(this.destination)
+ .minus(this)
+ .times(pos)
+ .plus(this)
+ }
}) \ No newline at end of file