mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Clean up code (if() -> if ()).
This commit is contained in:
parent
52a73e86ce
commit
66465541c6
5 changed files with 56 additions and 56 deletions
|
@ -15,7 +15,7 @@
|
||||||
for (var x = 0; x < size.width; x++) {
|
for (var x = 0; x < size.width; x++) {
|
||||||
for (var y = 0; y < size.height; y++) {
|
for (var y = 0; y < size.height; y++) {
|
||||||
var gray = raster.getPixel(x, y).gray * 0.9;
|
var gray = raster.getPixel(x, y).gray * 0.9;
|
||||||
if(gray > 0.1) {
|
if (gray > 0.1) {
|
||||||
var pos = new Point(x, y) * colSize + colSize / 2;
|
var pos = new Point(x, y) * colSize + colSize / 2;
|
||||||
var rectSize = gray * colSize.width;
|
var rectSize = gray * colSize.width;
|
||||||
var path = new Path.Rectangle([0, 0], [rectSize, rectSize]);
|
var path = new Path.Rectangle([0, 0], [rectSize, rectSize]);
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
if (radius1 == 0 || radius2 == 0)
|
if (radius1 == 0 || radius2 == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(d > maxDistance || d <= Math.abs(radius1 - radius2)) {
|
if (d > maxDistance || d <= Math.abs(radius1 - radius2)) {
|
||||||
return;
|
return;
|
||||||
} else if (d < radius1 + radius2) { // case circles are overlapping
|
} else if (d < radius1 + radius2) { // case circles are overlapping
|
||||||
u1 = Math.acos((radius1 * radius1 + d * d - radius2 * radius2) / (2 * radius1 * d));
|
u1 = Math.acos((radius1 * radius1 + d * d - radius2 * radius2) / (2 * radius1 * d));
|
||||||
|
|
|
@ -17,10 +17,10 @@
|
||||||
// altDown = Key.isDown('alt');
|
// altDown = Key.isDown('alt');
|
||||||
|
|
||||||
voronoiDrawer.initialize();
|
voronoiDrawer.initialize();
|
||||||
if(altDown || shiftDown)
|
if (altDown || shiftDown)
|
||||||
var removed = voronoiDrawer.removePoint(event.point);
|
var removed = voronoiDrawer.removePoint(event.point);
|
||||||
if(altDown) {
|
if (altDown) {
|
||||||
if(removed) {
|
if (removed) {
|
||||||
voronoiDrawer.initPoints();
|
voronoiDrawer.initPoints();
|
||||||
voronoiDrawer.render();
|
voronoiDrawer.render();
|
||||||
}
|
}
|
||||||
|
@ -30,8 +30,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMouseDrag(event) {
|
function onMouseDrag(event) {
|
||||||
if(!altDown) {
|
if (!altDown) {
|
||||||
if(event.count == 1)
|
if (event.count == 1)
|
||||||
voronoiDrawer.showPointsDown();
|
voronoiDrawer.showPointsDown();
|
||||||
voronoiDrawer.addAndRender(event.point, true, true)
|
voronoiDrawer.addAndRender(event.point, true, true)
|
||||||
voronoiDrawer.showPointsDrag();
|
voronoiDrawer.showPointsDrag();
|
||||||
|
@ -39,10 +39,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMouseUp(event) {
|
function onMouseUp(event) {
|
||||||
if(!altDown && !shiftDown) {
|
if (!altDown && !shiftDown) {
|
||||||
voronoiDrawer.addAndRender(event.point, false, false)
|
voronoiDrawer.addAndRender(event.point, false, false)
|
||||||
}
|
}
|
||||||
if(shiftDown) {
|
if (shiftDown) {
|
||||||
voronoiDrawer.initPoints();
|
voronoiDrawer.initPoints();
|
||||||
voronoiDrawer.render();
|
voronoiDrawer.render();
|
||||||
}
|
}
|
||||||
|
@ -65,13 +65,13 @@
|
||||||
// });
|
// });
|
||||||
// for (var i = 0, l = groups.length; i < l; i++) {
|
// for (var i = 0, l = groups.length; i < l; i++) {
|
||||||
// var group = groups[i];
|
// var group = groups[i];
|
||||||
// if(group.name == 'Voronoi') {
|
// if (group.name == 'Voronoi') {
|
||||||
// this.group = group;
|
// this.group = group;
|
||||||
// this.vGroup = group.children['vGroup'];
|
// this.vGroup = group.children['vGroup'];
|
||||||
// i = l;
|
// i = l;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
if(!this.group) {
|
if (!this.group) {
|
||||||
this.group = new Group();
|
this.group = new Group();
|
||||||
this.group.name = 'Voronoi';
|
this.group.name = 'Voronoi';
|
||||||
this.group.data = {};
|
this.group.data = {};
|
||||||
|
@ -144,16 +144,16 @@
|
||||||
path.strokeColor='black';
|
path.strokeColor='black';
|
||||||
path.strokeWidth = offset * 2;
|
path.strokeWidth = offset * 2;
|
||||||
var offsetted = path.expand();
|
var offsetted = path.expand();
|
||||||
if(offsetted && offsetted.children.length) {
|
if (offsetted && offsetted.children.length) {
|
||||||
var compoundPath = offsetted.children[0];
|
var compoundPath = offsetted.children[0];
|
||||||
if(compoundPath.children.length) {
|
if (compoundPath.children.length) {
|
||||||
var inner = offsetted.children[0].children[0];
|
var inner = offsetted.children[0].children[0];
|
||||||
inner.moveAbove(offsetted);
|
inner.moveAbove(offsetted);
|
||||||
inner.fillColor = 'black';
|
inner.fillColor = 'black';
|
||||||
}
|
}
|
||||||
offsetted.remove();
|
offsetted.remove();
|
||||||
}
|
}
|
||||||
if(inner)
|
if (inner)
|
||||||
inner.data.path = cloned;
|
inner.data.path = cloned;
|
||||||
return inner;
|
return inner;
|
||||||
},
|
},
|
||||||
|
@ -164,7 +164,7 @@
|
||||||
var segment = path.segments[i];
|
var segment = path.segments[i];
|
||||||
var nextSegment = path.segments[i + 1 >= l ? (i + 1) % l : i + 1];
|
var nextSegment = path.segments[i + 1 >= l ? (i + 1) % l : i + 1];
|
||||||
var length = (nextSegment.point - segment.point).length;
|
var length = (nextSegment.point - segment.point).length;
|
||||||
if(length / averageLength < 0.1) {
|
if (length / averageLength < 0.1) {
|
||||||
var prevSegment = path.segments[i - 1 < 0 ? l - 1 : i - 1];
|
var prevSegment = path.segments[i - 1 < 0 ? l - 1 : i - 1];
|
||||||
var line1 = new Line(prevSegment.point, segment.point, true);
|
var line1 = new Line(prevSegment.point, segment.point, true);
|
||||||
var afterSegment = path.segments[i + 2 >= l ? (i + 2) % l : i + 2];
|
var afterSegment = path.segments[i + 2 >= l ? (i + 2) % l : i + 2];
|
||||||
|
@ -204,16 +204,16 @@
|
||||||
|
|
||||||
drawVoronoi: function(diagram, activePoint) {
|
drawVoronoi: function(diagram, activePoint) {
|
||||||
|
|
||||||
if(this.points.length == 2)
|
if (this.points.length == 2)
|
||||||
this.drawCell(diagram, 0, activePoint);
|
this.drawCell(diagram, 0, activePoint);
|
||||||
|
|
||||||
var newCell = this.drawCell(diagram, this.points.length - 1, activePoint);
|
var newCell = this.drawCell(diagram, this.points.length - 1, activePoint);
|
||||||
if(!activePoint && newCell) {
|
if (!activePoint && newCell) {
|
||||||
var checkPath = newCell.data.path;
|
var checkPath = newCell.data.path;
|
||||||
for (var i = 0, l = this.vGroup.children.length; i < l; i++) {
|
for (var i = 0, l = this.vGroup.children.length; i < l; i++) {
|
||||||
var path = this.vGroup.children[i];
|
var path = this.vGroup.children[i];
|
||||||
var toCheckPath = path.data.path;
|
var toCheckPath = path.data.path;
|
||||||
if(toCheckPath && checkPath.bounds.intersects(toCheckPath.bounds)) {// && toCheckPath.intersects(checkPath)) {
|
if (toCheckPath && checkPath.bounds.intersects(toCheckPath.bounds)) {// && toCheckPath.intersects(checkPath)) {
|
||||||
var index = this.findIndex(toCheckPath.data.center);
|
var index = this.findIndex(toCheckPath.data.center);
|
||||||
path.remove();
|
path.remove();
|
||||||
this.drawCell(diagram, index, activePoint);
|
this.drawCell(diagram, index, activePoint);
|
||||||
|
@ -230,12 +230,12 @@
|
||||||
removePoint: function(point) {
|
removePoint: function(point) {
|
||||||
|
|
||||||
var hitResult = this.vGroup.hitTest(point);
|
var hitResult = this.vGroup.hitTest(point);
|
||||||
if(hitResult) {
|
if (hitResult) {
|
||||||
var point = hitResult.item.data.path.data.center;
|
var point = hitResult.item.data.path.data.center;
|
||||||
var segments = this.group.data.path.segments;
|
var segments = this.group.data.path.segments;
|
||||||
for (var i = 0, l = segments.length; i < l; i++) {
|
for (var i = 0, l = segments.length; i < l; i++) {
|
||||||
var segment = segments[i];
|
var segment = segments[i];
|
||||||
if(point == segment.point.multiply(100).round()) {
|
if (point == segment.point.multiply(100).round()) {
|
||||||
i = l;
|
i = l;
|
||||||
segment.remove();
|
segment.remove();
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@
|
||||||
|
|
||||||
findIndex: function(point) {
|
findIndex: function(point) {
|
||||||
for (var i = 0, l = this.points.length; i < l; i++) {
|
for (var i = 0, l = this.points.length; i < l; i++) {
|
||||||
if(point == this.points[i].multiply(100).round())
|
if (point == this.points[i].multiply(100).round())
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -262,13 +262,13 @@
|
||||||
var path = new Path();
|
var path = new Path();
|
||||||
//path.strokeColor = 'black';
|
//path.strokeColor = 'black';
|
||||||
path.data = {};
|
path.data = {};
|
||||||
if(remove) {
|
if (remove) {
|
||||||
path.removeOn({
|
path.removeOn({
|
||||||
drag: true,
|
drag: true,
|
||||||
up: true
|
up: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(!remove)
|
if (!remove)
|
||||||
this.vGroup.appendTop(path);
|
this.vGroup.appendTop(path);
|
||||||
|
|
||||||
var startPoint = new Point(halfedges[0].getStartpoint());
|
var startPoint = new Point(halfedges[0].getStartpoint());
|
||||||
|
@ -281,16 +281,16 @@
|
||||||
path.closed = true;
|
path.closed = true;
|
||||||
path.fillColor = new GrayColor(1 - path.length / 4000);
|
path.fillColor = new GrayColor(1 - path.length / 4000);
|
||||||
|
|
||||||
if(values.drawBlobs) {
|
if (values.drawBlobs) {
|
||||||
var offPath = this.getOffsettedPath(path);
|
var offPath = this.getOffsettedPath(path);
|
||||||
if(offPath) {
|
if (offPath) {
|
||||||
this.removeSmallBits(offPath);
|
this.removeSmallBits(offPath);
|
||||||
this.roundPath(offPath);
|
this.roundPath(offPath);
|
||||||
|
|
||||||
if(values.smoothBlobs) {
|
if (values.smoothBlobs) {
|
||||||
offPath.smooth();
|
offPath.smooth();
|
||||||
}
|
}
|
||||||
if(!remove) {
|
if (!remove) {
|
||||||
this.vGroup.appendTop(offPath);
|
this.vGroup.appendTop(offPath);
|
||||||
} else {
|
} else {
|
||||||
offPath.removeOn({
|
offPath.removeOn({
|
||||||
|
@ -313,19 +313,19 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
fastRender: function(activePoint) {
|
fastRender: function(activePoint) {
|
||||||
if(!this.vGroup) {
|
if (!this.vGroup) {
|
||||||
this.vGroup = new Group();
|
this.vGroup = new Group();
|
||||||
this.vGroup.name = 'vGroup';
|
this.vGroup.name = 'vGroup';
|
||||||
this.group.appendTop(this.vGroup);
|
this.group.appendTop(this.vGroup);
|
||||||
}
|
}
|
||||||
this.voronoi.setSites(this.points);
|
this.voronoi.setSites(this.points);
|
||||||
var diagram = this.voronoi.compute(this.bbox);
|
var diagram = this.voronoi.compute(this.bbox);
|
||||||
if(this.points.length > 1)
|
if (this.points.length > 1)
|
||||||
this.drawVoronoi(diagram, activePoint);
|
this.drawVoronoi(diagram, activePoint);
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
if(this.vGroup)
|
if (this.vGroup)
|
||||||
this.vGroup.remove();
|
this.vGroup.remove();
|
||||||
this.vGroup = new Group();
|
this.vGroup = new Group();
|
||||||
this.vGroup.name = 'vGroup';
|
this.vGroup.name = 'vGroup';
|
||||||
|
@ -337,11 +337,11 @@
|
||||||
|
|
||||||
addAndRender: function(point, preview, remove) {
|
addAndRender: function(point, preview, remove) {
|
||||||
|
|
||||||
if(remove) this.pop();
|
if (remove) this.pop();
|
||||||
|
|
||||||
this.addPoint(point);
|
this.addPoint(point);
|
||||||
this.initPoints();
|
this.initPoints();
|
||||||
if(preview) {
|
if (preview) {
|
||||||
this.render(point);
|
this.render(point);
|
||||||
} else {
|
} else {
|
||||||
this.render(null, true);
|
this.render(null, true);
|
||||||
|
@ -364,7 +364,7 @@
|
||||||
// var vPoints = [];
|
// var vPoints = [];
|
||||||
// // Now we bring up the dialog
|
// // Now we bring up the dialog
|
||||||
// var values = Dialog.prompt('Settings', components);
|
// var values = Dialog.prompt('Settings', components);
|
||||||
// if(values) {
|
// if (values) {
|
||||||
// this.columns = values.columns;
|
// this.columns = values.columns;
|
||||||
// this.rows = values.rows * 2;
|
// this.rows = values.rows * 2;
|
||||||
//
|
//
|
||||||
|
@ -373,7 +373,7 @@
|
||||||
// for (var i = -1; i < this.columns + 1; i++) {
|
// for (var i = -1; i < this.columns + 1; i++) {
|
||||||
// for (var j = -1; j < this.rows + 1; j++) {
|
// for (var j = -1; j < this.rows + 1; j++) {
|
||||||
// var point = new Point(i, j) / new Point(size) * document.bounds.size + col / 2;
|
// var point = new Point(i, j) / new Point(size) * document.bounds.size + col / 2;
|
||||||
// if(j % 4 == 2 || j% 4 == 3) {
|
// if (j % 4 == 2 || j% 4 == 3) {
|
||||||
// point += new Point(col.width / 2, 0);
|
// point += new Point(col.width / 2, 0);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
@ -393,7 +393,7 @@
|
||||||
var vPoints = [];
|
var vPoints = [];
|
||||||
// Now we bring up the dialog
|
// Now we bring up the dialog
|
||||||
var values = Dialog.prompt('Settings', components);
|
var values = Dialog.prompt('Settings', components);
|
||||||
if(values) {
|
if (values) {
|
||||||
this.columns = values.columns;
|
this.columns = values.columns;
|
||||||
this.rows = values.rows;
|
this.rows = values.rows;
|
||||||
|
|
||||||
|
@ -402,9 +402,9 @@
|
||||||
for (var i = -1; i < this.columns + 1; i++) {
|
for (var i = -1; i < this.columns + 1; i++) {
|
||||||
for (var j = -1; j < this.rows + 1; j++) {
|
for (var j = -1; j < this.rows + 1; j++) {
|
||||||
var point = new Point(i, j) / new Point(size) * document.bounds.size + col / 2;
|
var point = new Point(i, j) / new Point(size) * document.bounds.size + col / 2;
|
||||||
if(j % 2)
|
if (j % 2)
|
||||||
point += new Point(col.width / 2, 0);
|
point += new Point(col.width / 2, 0);
|
||||||
if(values.loose)
|
if (values.loose)
|
||||||
point += (col / 4) * Point.random() - col / 4;
|
point += (col / 4) * Point.random() - col / 4;
|
||||||
vPoints.push(point);
|
vPoints.push(point);
|
||||||
}
|
}
|
||||||
|
@ -422,7 +422,7 @@
|
||||||
var vPoints = [];
|
var vPoints = [];
|
||||||
// Now we bring up the dialog
|
// Now we bring up the dialog
|
||||||
var values = Dialog.prompt('Settings', components);
|
var values = Dialog.prompt('Settings', components);
|
||||||
if(values) {
|
if (values) {
|
||||||
this.columns = values.columns;
|
this.columns = values.columns;
|
||||||
this.rows = values.rows;
|
this.rows = values.rows;
|
||||||
var size = new Size(this.columns, this.rows);
|
var size = new Size(this.columns, this.rows);
|
||||||
|
@ -431,11 +431,11 @@
|
||||||
for (var j = -1; j < this.rows; j++) {
|
for (var j = -1; j < this.rows; j++) {
|
||||||
|
|
||||||
var point = new Point(i, j) / size * document.bounds.size + col / 2;
|
var point = new Point(i, j) / size * document.bounds.size + col / 2;
|
||||||
if(j % 2)
|
if (j % 2)
|
||||||
point += new Point(col.width / 2, 0);
|
point += new Point(col.width / 2, 0);
|
||||||
if(i % 2)
|
if (i % 2)
|
||||||
point += new Point(0, col.height / 2);
|
point += new Point(0, col.height / 2);
|
||||||
if(values.loose)
|
if (values.loose)
|
||||||
point += (col / 8) * Point.random() - col / 8;
|
point += (col / 8) * Point.random() - col / 8;
|
||||||
vPoints.push(point);
|
vPoints.push(point);
|
||||||
}
|
}
|
||||||
|
@ -452,7 +452,7 @@
|
||||||
var vPoints = [];
|
var vPoints = [];
|
||||||
// Now we bring up the dialog
|
// Now we bring up the dialog
|
||||||
var values = Dialog.prompt('Settings', components);
|
var values = Dialog.prompt('Settings', components);
|
||||||
if(values) {
|
if (values) {
|
||||||
this.columns = values.columns;
|
this.columns = values.columns;
|
||||||
this.rows = values.rows;
|
this.rows = values.rows;
|
||||||
this.parts = values.parts;
|
this.parts = values.parts;
|
||||||
|
@ -463,7 +463,7 @@
|
||||||
for (var i = -1; i < this.columns + 1; i++) {
|
for (var i = -1; i < this.columns + 1; i++) {
|
||||||
for (var j = -1; j < this.rows + 1; j++) {
|
for (var j = -1; j < this.rows + 1; j++) {
|
||||||
var point = new Point(i, j) / new Point(size) * document.bounds.size + col / 2;
|
var point = new Point(i, j) / new Point(size) * document.bounds.size + col / 2;
|
||||||
if(this.loose)
|
if (this.loose)
|
||||||
point += (col / 4) * Point.random() - col / 4;
|
point += (col / 4) * Point.random() - col / 4;
|
||||||
vPoints.push(point);
|
vPoints.push(point);
|
||||||
}
|
}
|
||||||
|
@ -480,7 +480,7 @@
|
||||||
var vPoints = [];
|
var vPoints = [];
|
||||||
// Now we bring up the dialog
|
// Now we bring up the dialog
|
||||||
var values = Dialog.prompt('Settings', components);
|
var values = Dialog.prompt('Settings', components);
|
||||||
if(values) {
|
if (values) {
|
||||||
this.columns = values.columns;
|
this.columns = values.columns;
|
||||||
this.rows = values.rows;
|
this.rows = values.rows;
|
||||||
this.parts = values.parts;
|
this.parts = values.parts;
|
||||||
|
@ -490,7 +490,7 @@
|
||||||
for (var i = -1; i < this.columns + 1; i++) {
|
for (var i = -1; i < this.columns + 1; i++) {
|
||||||
for (var j = -1; j < this.rows + 1; j++) {
|
for (var j = -1; j < this.rows + 1; j++) {
|
||||||
var point = new Point(i, j) / new Point(size) * document.bounds.size + col / 2;
|
var point = new Point(i, j) / new Point(size) * document.bounds.size + col / 2;
|
||||||
if(j % 2)
|
if (j % 2)
|
||||||
point += new Point(col.width / 2, 0);
|
point += new Point(col.width / 2, 0);
|
||||||
vPoints.push(point);
|
vPoints.push(point);
|
||||||
var offset = i % 2 ? 45 : 0;
|
var offset = i % 2 ? 45 : 0;
|
||||||
|
@ -542,7 +542,7 @@
|
||||||
selected: true
|
selected: true
|
||||||
});
|
});
|
||||||
|
|
||||||
if(paths.length) {
|
if (paths.length) {
|
||||||
voronoiDrawer.initialize();
|
voronoiDrawer.initialize();
|
||||||
for (var i = 0, l = paths.length; i < l; i++) {
|
for (var i = 0, l = paths.length; i < l; i++) {
|
||||||
var segments = paths[i].segments;
|
var segments = paths[i].segments;
|
||||||
|
@ -585,12 +585,12 @@
|
||||||
onClick: function() {
|
onClick: function() {
|
||||||
voronoiDrawer.initialize();
|
voronoiDrawer.initialize();
|
||||||
var points = drawers[values.drawer]();
|
var points = drawers[values.drawer]();
|
||||||
if(points.length) {
|
if (points.length) {
|
||||||
var confirmed = true;
|
var confirmed = true;
|
||||||
if(points.length > 800) {
|
if (points.length > 800) {
|
||||||
confirmed = Dialog.confirm('You are about to generate a Voronoi diagram with ' + points.length + ' points. This could take a while and could potentially crash Illustrator. Do you want to live recklessly?');
|
confirmed = Dialog.confirm('You are about to generate a Voronoi diagram with ' + points.length + ' points. This could take a while and could potentially crash Illustrator. Do you want to live recklessly?');
|
||||||
}
|
}
|
||||||
if(confirmed) {
|
if (confirmed) {
|
||||||
voronoiDrawer.setPoints(points);
|
voronoiDrawer.setPoints(points);
|
||||||
voronoiDrawer.render();
|
voronoiDrawer.render();
|
||||||
}
|
}
|
||||||
|
@ -604,7 +604,7 @@
|
||||||
components.smoothBlobs.enabled = !!value;
|
components.smoothBlobs.enabled = !!value;
|
||||||
voronoiDrawer.initialize();
|
voronoiDrawer.initialize();
|
||||||
voronoiDrawer.initPoints();
|
voronoiDrawer.initPoints();
|
||||||
if(voronoiDrawer.points.length)
|
if (voronoiDrawer.points.length)
|
||||||
voronoiDrawer.render();
|
voronoiDrawer.render();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -613,7 +613,7 @@
|
||||||
onChange: function(value) {
|
onChange: function(value) {
|
||||||
voronoiDrawer.initialize();
|
voronoiDrawer.initialize();
|
||||||
voronoiDrawer.initPoints();
|
voronoiDrawer.initPoints();
|
||||||
if(voronoiDrawer.points.length)
|
if (voronoiDrawer.points.length)
|
||||||
voronoiDrawer.render();
|
voronoiDrawer.render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ var Gradient = this.Gradient = Base.extend({
|
||||||
// TODO: should type here be called 'radial' and have it
|
// TODO: should type here be called 'radial' and have it
|
||||||
// receive a boolean value?
|
// receive a boolean value?
|
||||||
initialize: function(stops, type) {
|
initialize: function(stops, type) {
|
||||||
if(!stops) {
|
if (!stops) {
|
||||||
stops = [new GradientStop('white', 0),
|
stops = [new GradientStop('white', 0),
|
||||||
new GradientStop('black', 1)];
|
new GradientStop('black', 1)];
|
||||||
}
|
}
|
||||||
|
@ -36,12 +36,12 @@ var Gradient = this.Gradient = Base.extend({
|
||||||
if (stops.length < 2)
|
if (stops.length < 2)
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Gradient stop list needs to contain at least two stops.');
|
'Gradient stop list needs to contain at least two stops.');
|
||||||
if(!(stops[0] instanceof GradientStop)) {
|
if (!(stops[0] instanceof GradientStop)) {
|
||||||
for (var i = 0, l = stops.length; i < l; i++) {
|
for (var i = 0, l = stops.length; i < l; i++) {
|
||||||
var rampPoint;
|
var rampPoint;
|
||||||
var stop = stops[i];
|
var stop = stops[i];
|
||||||
// If it is an array, the second argument is the rampPoint:
|
// If it is an array, the second argument is the rampPoint:
|
||||||
if(stop.length) {
|
if (stop.length) {
|
||||||
rampPoint = stop[1];
|
rampPoint = stop[1];
|
||||||
stop = stop[0];
|
stop = stop[0];
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -21,9 +21,9 @@ function compareSegments(segment1, segment2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function compareNumbers(number1, number2, message) {
|
function compareNumbers(number1, number2, message) {
|
||||||
if(number1 !== 0)
|
if (number1 !== 0)
|
||||||
number1 = Math.round(number1 * 100) / 100;
|
number1 = Math.round(number1 * 100) / 100;
|
||||||
if(number2 !== 0)
|
if (number2 !== 0)
|
||||||
number2 = Math.round(number2 * 100) / 100;
|
number2 = Math.round(number2 * 100) / 100;
|
||||||
equals(number1, number2, message);
|
equals(number1, number2, message);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue