Comparing version 0.2.6 to 1.0.0
@@ -8,3 +8,3 @@ { | ||
}, | ||
"version": "0.2.6", | ||
"version": "1.0.0", | ||
"homepage": "https://github.com/maxkueng/victor", | ||
@@ -11,0 +11,0 @@ "authors": [ |
255
index.js
@@ -159,2 +159,60 @@ exports = module.exports = Victor; | ||
/** | ||
* Adds the given scalar to both vector axis | ||
* | ||
* ### Examples: | ||
* var vec = new Victor(1, 2); | ||
* | ||
* vec.addScalar(2); | ||
* vec.toString(); | ||
* // => x: 3, y: 4 | ||
* | ||
* @param {Number} scalar The scalar to add | ||
* @return {Victor} `this` for chaining capabilities | ||
* @api public | ||
*/ | ||
Victor.prototype.addScalar = function (scalar) { | ||
this.x += scalar; | ||
this.y += scalar; | ||
return this; | ||
}; | ||
/** | ||
* Adds the given scalar to the X axis | ||
* | ||
* ### Examples: | ||
* var vec = new Victor(1, 2); | ||
* | ||
* vec.addScalarX(2); | ||
* vec.toString(); | ||
* // => x: 3, y: 2 | ||
* | ||
* @param {Number} scalar The scalar to add | ||
* @return {Victor} `this` for chaining capabilities | ||
* @api public | ||
*/ | ||
Victor.prototype.addScalarX = function (scalar) { | ||
this.x += scalar; | ||
return this; | ||
}; | ||
/** | ||
* Adds the given scalar to the Y axis | ||
* | ||
* ### Examples: | ||
* var vec = new Victor(1, 2); | ||
* | ||
* vec.addScalarY(2); | ||
* vec.toString(); | ||
* // => x: 1, y: 4 | ||
* | ||
* @param {Number} scalar The scalar to add | ||
* @return {Victor} `this` for chaining capabilities | ||
* @api public | ||
*/ | ||
Victor.prototype.addScalarY = function (scalar) { | ||
this.y += scalar; | ||
return this; | ||
}; | ||
/** | ||
* Subtracts the X axis of another vector from this one | ||
@@ -221,2 +279,60 @@ * | ||
/** | ||
* Subtracts the given scalar from both axis | ||
* | ||
* ### Examples: | ||
* var vec = new Victor(100, 200); | ||
* | ||
* vec.subtractScalar(20); | ||
* vec.toString(); | ||
* // => x: 80, y: 180 | ||
* | ||
* @param {Number} scalar The scalar to subtract | ||
* @return {Victor} `this` for chaining capabilities | ||
* @api public | ||
*/ | ||
Victor.prototype.subtractScalar = function (scalar) { | ||
this.x -= scalar; | ||
this.y -= scalar; | ||
return this; | ||
}; | ||
/** | ||
* Subtracts the given scalar from the X axis | ||
* | ||
* ### Examples: | ||
* var vec = new Victor(100, 200); | ||
* | ||
* vec.subtractScalarX(20); | ||
* vec.toString(); | ||
* // => x: 80, y: 200 | ||
* | ||
* @param {Number} scalar The scalar to subtract | ||
* @return {Victor} `this` for chaining capabilities | ||
* @api public | ||
*/ | ||
Victor.prototype.subtractScalarX = function (scalar) { | ||
this.x -= scalar; | ||
return this; | ||
}; | ||
/** | ||
* Subtracts the given scalar from the Y axis | ||
* | ||
* ### Examples: | ||
* var vec = new Victor(100, 200); | ||
* | ||
* vec.subtractScalarY(20); | ||
* vec.toString(); | ||
* // => x: 100, y: 180 | ||
* | ||
* @param {Number} scalar The scalar to subtract | ||
* @return {Victor} `this` for chaining capabilities | ||
* @api public | ||
*/ | ||
Victor.prototype.subtractScalarY = function (scalar) { | ||
this.y -= scalar; | ||
return this; | ||
}; | ||
/** | ||
* Divides the X axis by the x component of given vector | ||
@@ -283,2 +399,74 @@ * | ||
/** | ||
* Divides both vector axis by the given scalar value | ||
* | ||
* ### Examples: | ||
* var vec = new Victor(100, 50); | ||
* | ||
* vec.divideScalar(2); | ||
* vec.toString(); | ||
* // => x:50, y:25 | ||
* | ||
* @param {Number} The scalar to divide by | ||
* @return {Victor} `this` for chaining capabilities | ||
* @api public | ||
*/ | ||
Victor.prototype.divideScalar = function (scalar) { | ||
if (scalar !== 0) { | ||
this.x /= scalar; | ||
this.y /= scalar; | ||
} else { | ||
this.x = 0; | ||
this.y = 0; | ||
} | ||
return this; | ||
}; | ||
/** | ||
* Divides the X axis by the given scalar value | ||
* | ||
* ### Examples: | ||
* var vec = new Victor(100, 50); | ||
* | ||
* vec.divideScalarX(2); | ||
* vec.toString(); | ||
* // => x:50, y:50 | ||
* | ||
* @param {Number} The scalar to divide by | ||
* @return {Victor} `this` for chaining capabilities | ||
* @api public | ||
*/ | ||
Victor.prototype.divideScalarX = function (scalar) { | ||
if (scalar !== 0) { | ||
this.x /= scalar; | ||
} else { | ||
this.x = 0; | ||
} | ||
return this; | ||
}; | ||
/** | ||
* Divides the Y axis by the given scalar value | ||
* | ||
* ### Examples: | ||
* var vec = new Victor(100, 50); | ||
* | ||
* vec.divideScalarY(2); | ||
* vec.toString(); | ||
* // => x:100, y:25 | ||
* | ||
* @param {Number} The scalar to divide by | ||
* @return {Victor} `this` for chaining capabilities | ||
* @api public | ||
*/ | ||
Victor.prototype.divideScalarY = function (scalar) { | ||
if (scalar !== 0) { | ||
this.y /= scalar; | ||
} else { | ||
this.y = 0; | ||
} | ||
return this; | ||
}; | ||
/** | ||
* Inverts the X axis | ||
@@ -400,2 +588,60 @@ * | ||
/** | ||
* Multiplies both vector axis by the given scalar value | ||
* | ||
* ### Examples: | ||
* var vec = new Victor(100, 50); | ||
* | ||
* vec.multiplyScalar(2); | ||
* vec.toString(); | ||
* // => x:200, y:100 | ||
* | ||
* @param {Number} The scalar to multiply by | ||
* @return {Victor} `this` for chaining capabilities | ||
* @api public | ||
*/ | ||
Victor.prototype.multiplyScalar = function (scalar) { | ||
this.x *= scalar; | ||
this.y *= scalar; | ||
return this; | ||
}; | ||
/** | ||
* Multiplies the X axis by the given scalar | ||
* | ||
* ### Examples: | ||
* var vec = new Victor(100, 50); | ||
* | ||
* vec.multiplyScalarX(2); | ||
* vec.toString(); | ||
* // => x:200, y:50 | ||
* | ||
* @param {Number} The scalar to multiply the axis with | ||
* @return {Victor} `this` for chaining capabilities | ||
* @api public | ||
*/ | ||
Victor.prototype.multiplyScalarX = function (scalar) { | ||
this.x *= scalar; | ||
return this; | ||
}; | ||
/** | ||
* Multiplies the Y axis by the given scalar | ||
* | ||
* ### Examples: | ||
* var vec = new Victor(100, 50); | ||
* | ||
* vec.multiplyScalarY(2); | ||
* vec.toString(); | ||
* // => x:100, y:100 | ||
* | ||
* @param {Number} The scalar to multiply the axis with | ||
* @return {Victor} `this` for chaining capabilities | ||
* @api public | ||
*/ | ||
Victor.prototype.multiplyScalarY = function (scalar) { | ||
this.y *= scalar; | ||
return this; | ||
}; | ||
/** | ||
* Normalize | ||
@@ -798,2 +1044,11 @@ * | ||
Victor.prototype.rotateTo = function(rotation) { | ||
return this.rotate(rotation-this.angle()); | ||
}; | ||
Victor.prototype.rotateToDeg = function(rotation) { | ||
rotation = degrees2radian(rotation); | ||
return this.rotateTo(rotation); | ||
}; | ||
Victor.prototype.rotateBy = function (rotation) { | ||
@@ -800,0 +1055,0 @@ var angle = this.angle() + rotation; |
{ | ||
"name": "victor", | ||
"version": "0.2.6", | ||
"version": "1.0.0", | ||
"description": "A JavaScript 2D vector class with methods for common vector operations", | ||
@@ -21,3 +21,3 @@ "keywords": [ | ||
"author": "Max Kueng <me@maxkueng.com> (http://maxkueng.com/)", | ||
"contributors": [ | ||
"maintainers": [ | ||
"Max Kueng (http://maxkueng.com/)", | ||
@@ -24,0 +24,0 @@ "George Crabtree (http://georgecrabtree.com/)" |
@@ -6,3 +6,3 @@ ![Victor](./artwork/logo.png) | ||
A Javascript 2D Vector Maths Library, built using the UMD standards, so you can use it as a global object or with any module loader. It works in both Node.js and the browser. | ||
A Javascript 2D Vector Maths Library, built using the UMD standards, so you can use it as a global object or with any module loader. It works in both Node.js and the browser. | ||
@@ -50,1 +50,20 @@ Check out the website for [documentation](http://victorjs.org/). | ||
``` | ||
## Contributors | ||
Ordered by date of first contribution. [Auto-generated](https://github.com/dtrejo/node-authors) on Mon, 31 Aug 2015 13:08:12 GMT. | ||
- [Max Kueng](https://github.com/maxkueng) aka `maxkueng` | ||
- [George Crabtree](https://github.com/supercrabtree) aka `supercrabtree` | ||
- [Michel.Ypma](https://github.com/MichelYpma) aka `MichelYpma` | ||
- [Chris Pearce](https://github.com/Chrisui) aka `Chrisui` | ||
- [Beau Gunderson](https://github.com/beaugunderson) aka `beaugunderson` | ||
- [René Bischoff](https://github.com/Fjandin) aka `Fjandin` | ||
- [Chris Ertel](https://github.com/chrisrertel) aka `chrisrertel` | ||
- [Heikki Ylönen](https://github.com/heikki) aka `heikki` | ||
- [Joonas Salmela](https://github.com/undefined) aka `undefined` | ||
- [Moritz Rebbert](https://github.com/ztiromoritz) aka `ztiromoritz` | ||
## License | ||
MIT |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
32965
9
1239
0
68