diff --git a/lib/chrome.js b/lib/chrome.js index 1ee397d..42da405 100644 --- a/lib/chrome.js +++ b/lib/chrome.js @@ -440,15 +440,6 @@ var ChromeObject = function() { .send() .responseBody ; - - // response if error - if ("result" in response) { - (function(r) { - if ("subtype" in r && r.subtype == "error") { - console.warn(r.description); - } - })(response.result.result); - } } catch (e) { console.warn(e.message); response = { @@ -1507,7 +1498,7 @@ exports.startDebugInPrivate = function(url, proxy, profileName, debuggingPort, i exports.publisherName = publisherName; -exports.VERSIONINFO = "Chrome Web Browser Debugging Interface (chrome.js) version 0.5.2"; +exports.VERSIONINFO = "Chrome Web Browser Debugging Interface (chrome.js) version 0.5.3"; exports.AUTHOR = "gnh1201@catswords.re.kr"; exports.global = global; exports.require = global.require; diff --git a/lib/extramath.js b/lib/extramath.js index 8076ff7..b4d9bd4 100644 --- a/lib/extramath.js +++ b/lib/extramath.js @@ -56,7 +56,7 @@ function measureSimilarity(s1, s2) { } function export_measureSimilarity() { - return "var ExtraMath=function(){};ExtraMath.DTM=function(){this.data=[],this.terms=[],this.add=function(t){for(var r=t.trim().split(/\s+/),a=0;athis.terms.indexOf(r[a])&&this.terms.push(r[a]);this.data.push(r)},this.toArray=function(){for(var t=[],r=0;rthis.data[r].indexOf(this.terms[s])?0:1);t.push(a)}return t}},ExtraMath.arrayCos=function(t,r){var a=0,s=0,h=0;for(i=0;ithis.terms.indexOf(r[a])&&this.terms.push(r[a]);this.data.push(r)},this.toArray=function(){for(var t=[],r=0;rthis.data[r].indexOf(this.terms[s])?0:1);t.push(a)}return t}},ExtraMath.arrayCos=function(t,r){var a=0,s=0,h=0;for(i=0;i maxIndex) { + return false; // invalid index -> immediately return false + } + var idx = n - 1; // shift to 0-based + coords.push({ x: idx % size, y: Math.floor(idx / size) }); + } + + var xs = coords.map(function (c) { return c.x; }); + var ys = coords.map(function (c) { return c.y; }); + + // 2. Compute bounding box of selected cells + var minX = Math.min.apply(Math, xs), maxX = Math.max.apply(Math, xs); + var minY = Math.min.apply(Math, ys), maxY = Math.max.apply(Math, ys); + + // 3. Compute area and density + var w = maxX - minX + 1; + var h = maxY - minY + 1; + var boxArea = w * h; + + var density = coords.length / boxArea; + return density >= minDensity; +} + +function estimateTileStartPosition(index, tiles, spreadSize, gap) { + if (typeof tiles !== 'number' || tiles <= 0) return null; + if (typeof spreadSize !== 'number' || !isFinite(spreadSize)) return null; + if (typeof gap !== 'number' || !isFinite(gap) || gap < 0) gap = 0; + if (typeof index !== 'number' || !isFinite(index) || index % 1 !== 0 || index < 1) return null; + + var totalSlots = tiles * tiles; + if (index > totalSlots) return null; + + var tileSize = (spreadSize - gap * (tiles - 1)) / tiles; + if (!isFinite(tileSize)) return null; + + var i = index - 1; + var col = i % tiles; + var row = Math.floor(i / tiles); + + return { + x: Math.max(0, col) * (tileSize + gap), + y: Math.max(0, row) * (tileSize + gap) + }; +} + exports.DTM = DTM; exports.arrayCos = arrayCos; exports.measureSimilarity = measureSimilarity; exports.export_measureSimilarity = export_measureSimilarity; exports.cartesianProduct = cartesianProduct; +exports.clusteredCellsDensity = clusteredCellsDensity; +exports.estimateTileStartPosition = estimateTileStartPosition; -exports.VERSIONINFO = "ExtraMath module (extramath.js) version 0.0.5"; +exports.VERSIONINFO = "ExtraMath module (extramath.js) version 1.0.3"; exports.AUTHOR = "gnh1201@catswords.re.kr"; exports.global = global; exports.require = global.require;