Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Marsch committed Jun 9, 2016
1 parent 8e0bccb commit f56544a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
2 changes: 2 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ module.exports = function(grunt) {
globals: {}
},
all: [
'src/parseColor.js',
'lib/earcut.custom.js',
'src/vec2.js',
'src/vec3.js',
'src/split.js',
Expand Down
11 changes: 6 additions & 5 deletions dist/Triangulate.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ var w3cColors = {
yellowgreen: '#9acd32'
};

var parseColor = exports = function(str) {
function parseColor(str) {
str = str || '';
str = str.toLowerCase();
str = w3cColors[str] || str;
Expand All @@ -168,9 +168,9 @@ var parseColor = exports = function(str) {
parseInt(m[1], 10)/255,
parseInt(m[2], 10)/255,
parseInt(m[3], 10)/255
]
];
}
};
}


var earcut = (function() {
Expand Down Expand Up @@ -765,18 +765,19 @@ var earcut = (function() {
earcut.deviation = function(data, holeIndices, dim, triangles) {
var hasHoles = holeIndices && holeIndices.length;
var outerLen = hasHoles ? holeIndices[0]*dim : data.length;
var i, len;

var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));
if (hasHoles) {
for (var i = 0, len = holeIndices.length; i<len; i++) {
for (i = 0, len = holeIndices.length; i<len; i++) {
var start = holeIndices[i]*dim;
var end = i<len - 1 ? holeIndices[i + 1]*dim : data.length;
polygonArea -= Math.abs(signedArea(data, start, end, dim));
}
}

var trianglesArea = 0;
for (i = 0; i<triangles.length; i += 3) {
for (i = 0, len = triangles.length; i < len; i += 3) {
var a = triangles[i]*dim;
var b = triangles[i + 1]*dim;
var c = triangles[i + 2]*dim;
Expand Down
5 changes: 3 additions & 2 deletions lib/earcut.custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,18 +591,19 @@ var earcut = (function() {
earcut.deviation = function(data, holeIndices, dim, triangles) {
var hasHoles = holeIndices && holeIndices.length;
var outerLen = hasHoles ? holeIndices[0]*dim : data.length;
var i, len;

var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));
if (hasHoles) {
for (var i = 0, len = holeIndices.length; i<len; i++) {
for (i = 0, len = holeIndices.length; i<len; i++) {
var start = holeIndices[i]*dim;
var end = i<len - 1 ? holeIndices[i + 1]*dim : data.length;
polygonArea -= Math.abs(signedArea(data, start, end, dim));
}
}

var trianglesArea = 0;
for (i = 0; i<triangles.length; i += 3) {
for (i = 0, len = triangles.length; i < len; i += 3) {
var a = triangles[i]*dim;
var b = triangles[i + 1]*dim;
var c = triangles[i + 2]*dim;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Triangulate",
"version": "0.1.3",
"version": "0.1.4",
"homepage": "http://osmbuildings.org",
"description": "GeoJSON triangulation scripts collection. Mainly used for OSM Buildings backend + frontend.",
"main": "dist/Triangulate.js",
Expand All @@ -16,6 +16,6 @@
"devDependencies": {
"grunt": "^0.4.4",
"grunt-contrib-concat": "~0.5.1",
"grunt-contrib-jshint": "^0.11.0"
"grunt-contrib-jshint": "^1.0.0"
}
}
6 changes: 3 additions & 3 deletions src/parseColor.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ var w3cColors = {
yellowgreen: '#9acd32'
};

var parseColor = exports = function(str) {
function parseColor(str) {
str = str || '';
str = str.toLowerCase();
str = w3cColors[str] || str;
Expand All @@ -167,6 +167,6 @@ var parseColor = exports = function(str) {
parseInt(m[1], 10)/255,
parseInt(m[2], 10)/255,
parseInt(m[3], 10)/255
]
];
}
};
}

0 comments on commit f56544a

Please sign in to comment.