Skip to content
Merged

Dev #13

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
./node_modules
./src/utils/node-particles/node_modules/
*.svg
samples
14 changes: 10 additions & 4 deletions src/Circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class Circle extends Path {
var r = Path.resolve(values, "r", 5);
var p0 = "M" + cx + "," + cy + " ";
var p1 = "m" + (-r) + "," + 0 + " ";
var p2 = "a" + r + "," + r + " " + 0 + " " + "1,0 " + (r * 2) + ",0 ";
var p3 = "a" + r + "," + r + " " + 0 + " " + "1,0 " + -(r * 2) + ",0 ";
var p2 = "a" + r + "," + r + "," + 0 + "," + "1,0," + (r * 2) + ",0 ";
var p3 = "a" + r + "," + r + "," + 0 + "," + "1,0," + -(r * 2) + ",0 ";
var d = p0 + " " + p1 + " " + p2 + " " + p3;
var procParams = values;
procParams["d"] = d;
Expand Down Expand Up @@ -53,12 +53,18 @@ class Circle extends Path {
var r = this.getAttr("r");
var p0 = "M" + xyPos.x + "," + xyPos.y + " ";
var p1 = "m" + r + "," + 0 + " ";
var p2 = "a" + r + "," + r + " " + 0 + " " + "1,0 " + (r * 2) + ",0 ";
var p3 = "a" + r + "," + r + " " + 0 + " " + "1,0 " + -(r * 2) + ",0 ";
var p2 = "a" + r + "," + r + "," + 0 + "," + "1,0," + (r * 2) + ",0 ";
var p3 = "a" + r + "," + r + "," + 0 + "," + "1,0," + -(r * 2) + ",0 ";
var d = p0 + " " + p1 + " " + p2 + " " + p3;
this.setAttr({"d":d});
return this;
}

getHalf () {
this.parsedPoints.splice(3,1);
this.updateD();
return this;
}
};

module.exports.Circle = Circle;
6 changes: 5 additions & 1 deletion src/Path.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ class Path extends SVGBase {
this.parsedPoints.forEach (function (point, i, sourceList) {
newD += point.type;
if (point.type != 'z') {
newD += point.values[0].x + "," + point.values[0].y;
//newD += point.values[0].x + "," + point.values[0].y;
for (let key in point.values[0]) {
newD += point.values[0][key] + ",";
}
newD = newD.slice(0,-1);
if (i < sourceList.length-1)
newD += " ";
}
Expand Down
1 change: 1 addition & 0 deletions src/utils/node-particles/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./node_modules
4 changes: 4 additions & 0 deletions src/utils/node-particles/js/Random.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class Random {
}
}

rint (lower, upper) {
return Math.round(this.random(lower, upper));
}

arcsine (min, max) {
var q = Math.sin(PI_2 * this.uniform(0, 1));

Expand Down
2 changes: 1 addition & 1 deletion src/utils/node-particles/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-particles",
"version": "1.1.1",
"version": "1.1.2",
"description": "A simple particle system for NodeJs",
"main": "./js/ParticleSystem.js",
"directories": {
Expand Down
9 changes: 9 additions & 0 deletions src/utils/node-particles/tests/RandomTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ describe("Random", function () {
});
});

it ("should generate integer values in [low,up] when two parameters are used", function () {
var r = new Random (900);
var results = [1,2,3,4,5,6,7,8,9,10].map(function () { return r.rint(15,23);});
results.forEach (function (item) {
expect(item).be.a("number").gte(15).lt(23);
expect(item + "").not.to.have.string(".");
});
});

it ("should generate values when a string is used as seed", function () {
var r = new Random ("bluecoat");
var results = [1,2,3,4,5,6,7,8,9,10].map(function () { return r.random(10);});
Expand Down