Skip to content

Commit

Permalink
vec2.str
Browse files Browse the repository at this point in the history
  • Loading branch information
sinisterchipmunk committed May 3, 2012
1 parent 5874379 commit c9b69c4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions gl-matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -2518,6 +2518,17 @@
dest[1] = vecA[1] + lerp * (vecB[1] - vecA[1]);
return dest;
};

/**
* Returns a string representation of a vector
*
* @param {vec2} vec Vector to represent as a string
*
* @returns {String} String representation of vec
*/
vec2.str = function (vec) {
return '[' + vec[0] + ', ' + vec[1] + ']';
};

/*
* Exports
Expand Down
4 changes: 4 additions & 0 deletions spec/javascripts/vec2_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ describe("vec2", function() {
});
});

describe("str", function() {
it("should produce pretty string", function() { expect(vec2.str(vecA)).toEqual("[1, 2]"); });
});

describe("lerp", function() {
describe("with dest", function() {
beforeEach(function() { result = vec2.lerp(vecA, vecB, 0.5, dest); });
Expand Down

0 comments on commit c9b69c4

Please sign in to comment.