初始化

This commit is contained in:
yziiy
2025-08-11 11:06:07 +08:00
parent 083bc37c00
commit 5607d11395
19772 changed files with 3108723 additions and 18 deletions

View File

@@ -0,0 +1,6 @@
*.log
node_modules
.DS_Store
.nyc_output
coverage
tmp

View File

@@ -0,0 +1,4 @@
sudo: false
language: node_js
node_js:
- "0.12"

View File

@@ -0,0 +1,15 @@
ISC License
Copyright (c) 2015, Mapbox
Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.

View File

@@ -0,0 +1,109 @@
## pixelmatch
[![Build Status](https://travis-ci.org/mapbox/pixelmatch.svg?branch=master)](https://travis-ci.org/mapbox/pixelmatch)
[![Coverage Status](https://coveralls.io/repos/mapbox/pixelmatch/badge.svg?branch=master&service=github)](https://coveralls.io/github/mapbox/pixelmatch?branch=master)
[![](https://img.shields.io/badge/simply-awesome-brightgreen.svg)](https://github.com/mourner/projects)
The smallest, simplest and fastest JavaScript pixel-level image comparison library,
originally created to compare screenshots in tests.
Features accurate **anti-aliased pixels detection**
and **perceptual color difference metrics**.
Inspired by [Resemble.js](https://github.com/Huddle/Resemble.js)
and [Blink-diff](https://github.com/yahoo/blink-diff).
Unlike these libraries, pixelmatch is around **90 lines of code**,
has **no dependencies**, and works on **raw arrays** of image data,
so it's **blazing fast** and can be used in **any environment** (Node or browsers).
```js
var numDiffPixels = pixelmatch(img1, img2, diff, 800, 600, {threshold: 0.1});
```
Implements ideas from the following papers:
- [Measuring perceived color difference using YIQ NTSC transmission color space in mobile applications](http://www.progmat.uaem.mx:8080/artVol2Num2/Articulo3Vol2Num2.pdf) (2010, Yuriy Kotsarenko, Fernando Ramos)
- [Anti-aliased pixel and intensity slope detector](http://www.ee.ktu.lt/journal/2009/7/25_ISSN_1392-1215_Anti-aliased%20Pxel%20and%20Intensity%20Slope%20Detector.pdf) (2009, Vytautas Vyšniauskas)
### Example output
| expected | actual | diff |
| --- | --- | --- |
| ![](test/fixtures/4a.png) | ![](test/fixtures/4b.png) | ![1diff](test/fixtures/4diff.png) |
| ![](test/fixtures/3a.png) | ![](test/fixtures/3b.png) | ![1diff](test/fixtures/3diff.png) |
| ![](test/fixtures/1a.png) | ![](test/fixtures/1b.png) | ![1diff](test/fixtures/1diff.png) |
### API
#### pixelmatch(img1, img2, output, width, height[, options])
- `img1`, `img2` — Image data of the images to compare (`Buffer` or `Uint8Array`).
- `output` — Image data to write the diff to, or `null` if don't need a diff image.
- `width`, `height` — Width and height of the images. Note that _all three images_ need to have the same dimensions.
`options` is an object literal with the following properties:
- `threshold` — Matching threshold, ranges from `0` to `1`. Smaller values make the comparison more sensitive. `0.1` by default.
- `includeAA` — If `true`, disables detecting and ignoring anti-aliased pixels. `false` by default.
Compares two images, writes the output diff and returns the number of mismatched pixels.
### Command line
Pixelmatch comes with a binary that works with PNG images:
```bash
pixelmatch image1.png image2.png output.png 0.1
```
### Example usage
#### Node.js
```js
var fs = require('fs'),
PNG = require('pngjs').PNG,
pixelmatch = require('pixelmatch');
var img1 = fs.createReadStream('img1.png').pipe(new PNG()).on('parsed', doneReading),
img2 = fs.createReadStream('img2.png').pipe(new PNG()).on('parsed', doneReading),
filesRead = 0;
function doneReading() {
if (++filesRead < 2) return;
var diff = new PNG({width: img1.width, height: img1.height});
pixelmatch(img1.data, img2.data, diff.data, img1.width, img1.height, {threshold: 0.1});
diff.pack().pipe(fs.createWriteStream('diff.png'));
}
```
#### Browsers
```js
var img1 = img1Ctx.getImageData(0, 0, width, height),
img2 = img2Ctx.getImageData(0, 0, width, height),
diff = diffCtx.createImageData(width, height);
pixelmatch(img1.data, img2.data, diff.data, width, height, {threshold: 0.1});
diffCtx.putImageData(diff, 0, 0);
```
### Install
Install with NPM:
```bash
npm install pixelmatch
```
To build a browser-compatible version, clone the repository locally, then run:
```bash
npm install -g browserify
browserify -s pixelmatch index.js > pixelmatch.js
```
### [Changelog](https://github.com/mapbox/pixelmatch/releases)

View File

@@ -0,0 +1,35 @@
#!/usr/bin/env node
'use strict';
var PNG = require('pngjs').PNG,
fs = require('fs'),
match = require('../.');
if (process.argv.length < 5) {
console.log('Usage: imagematch image1.png image2.png output.png [threshold=0.005] [includeAA=false]');
return;
}
var threshold = isNaN(+process.argv[5]) ? undefined : +process.argv[5],
includeAA = process.argv[6] === 'true';
var img1 = fs.createReadStream(process.argv[2]).pipe(new PNG()).on('parsed', doneReading);
var img2 = fs.createReadStream(process.argv[3]).pipe(new PNG()).on('parsed', doneReading);
function doneReading() {
if (!img1.data || !img2.data) return;
var diff = new PNG({width: img1.width, height: img1.height});
console.time('match');
var diffs = match(img1.data, img2.data, diff.data, diff.width, diff.height, {
threshold: threshold,
includeAA: includeAA
});
console.timeEnd('match');
diff.pack().pipe(fs.createWriteStream(process.argv[4]));
console.log('different pixels: ' + diffs);
console.log('error: ' + (Math.round(100 * 100 * diffs / (diff.width * diff.height)) / 100) + '%');
}

View File

@@ -0,0 +1,158 @@
'use strict';
module.exports = pixelmatch;
function pixelmatch(img1, img2, output, width, height, options) {
if (!options) options = {};
var threshold = options.threshold === undefined ? 0.1 : options.threshold;
// maximum acceptable square distance between two colors;
// 35215 is the maximum possible value for the YIQ difference metric
var maxDelta = 35215 * threshold * threshold,
diff = 0;
// compare each pixel of one image against the other one
for (var y = 0; y < height; y++) {
for (var x = 0; x < width; x++) {
var pos = (y * width + x) * 4;
// squared YUV distance between colors at this pixel position
var delta = colorDelta(img1, img2, pos, pos);
// the color difference is above the threshold
if (delta > maxDelta) {
// check it's a real rendering difference or just anti-aliasing
if (!options.includeAA && (antialiased(img1, x, y, width, height, img2) ||
antialiased(img2, x, y, width, height, img1))) {
// one of the pixels is anti-aliasing; draw as yellow and do not count as difference
if (output) drawPixel(output, pos, 255, 255, 0);
} else {
// found substantial difference not caused by anti-aliasing; draw it as red
if (output) drawPixel(output, pos, 255, 0, 0);
diff++;
}
} else if (output) {
// pixels are similar; draw background as grayscale image blended with white
var val = blend(grayPixel(img1, pos), 0.1);
drawPixel(output, pos, val, val, val);
}
}
}
// return the number of different pixels
return diff;
}
// check if a pixel is likely a part of anti-aliasing;
// based on "Anti-aliased Pixel and Intensity Slope Detector" paper by V. Vysniauskas, 2009
function antialiased(img, x1, y1, width, height, img2) {
var x0 = Math.max(x1 - 1, 0),
y0 = Math.max(y1 - 1, 0),
x2 = Math.min(x1 + 1, width - 1),
y2 = Math.min(y1 + 1, height - 1),
pos = (y1 * width + x1) * 4,
zeroes = 0,
positives = 0,
negatives = 0,
min = 0,
max = 0,
minX, minY, maxX, maxY;
// go through 8 adjacent pixels
for (var x = x0; x <= x2; x++) {
for (var y = y0; y <= y2; y++) {
if (x === x1 && y === y1) continue;
// brightness delta between the center pixel and adjacent one
var delta = colorDelta(img, img, pos, (y * width + x) * 4, true);
// count the number of equal, darker and brighter adjacent pixels
if (delta === 0) zeroes++;
else if (delta < 0) negatives++;
else if (delta > 0) positives++;
// if found more than 2 equal siblings, it's definitely not anti-aliasing
if (zeroes > 2) return false;
if (!img2) continue;
// remember the darkest pixel
if (delta < min) {
min = delta;
minX = x;
minY = y;
}
// remember the brightest pixel
if (delta > max) {
max = delta;
maxX = x;
maxY = y;
}
}
}
if (!img2) return true;
// if there are no both darker and brighter pixels among siblings, it's not anti-aliasing
if (negatives === 0 || positives === 0) return false;
// if either the darkest or the brightest pixel has more than 2 equal siblings in both images
// (definitely not anti-aliased), this pixel is anti-aliased
return (!antialiased(img, minX, minY, width, height) && !antialiased(img2, minX, minY, width, height)) ||
(!antialiased(img, maxX, maxY, width, height) && !antialiased(img2, maxX, maxY, width, height));
}
// calculate color difference according to the paper "Measuring perceived color difference
// using YIQ NTSC transmission color space in mobile applications" by Y. Kotsarenko and F. Ramos
function colorDelta(img1, img2, k, m, yOnly) {
var a1 = img1[k + 3] / 255,
a2 = img2[m + 3] / 255,
r1 = blend(img1[k + 0], a1),
g1 = blend(img1[k + 1], a1),
b1 = blend(img1[k + 2], a1),
r2 = blend(img2[m + 0], a2),
g2 = blend(img2[m + 1], a2),
b2 = blend(img2[m + 2], a2),
y = rgb2y(r1, g1, b1) - rgb2y(r2, g2, b2);
if (yOnly) return y; // brightness difference only
var i = rgb2i(r1, g1, b1) - rgb2i(r2, g2, b2),
q = rgb2q(r1, g1, b1) - rgb2q(r2, g2, b2);
return 0.5053 * y * y + 0.299 * i * i + 0.1957 * q * q;
}
function rgb2y(r, g, b) { return r * 0.29889531 + g * 0.58662247 + b * 0.11448223; }
function rgb2i(r, g, b) { return r * 0.59597799 - g * 0.27417610 - b * 0.32180189; }
function rgb2q(r, g, b) { return r * 0.21147017 - g * 0.52261711 + b * 0.31114694; }
// blend semi-transparent color with white
function blend(c, a) {
return 255 + (c - 255) * a;
}
function drawPixel(output, pos, r, g, b) {
output[pos + 0] = r;
output[pos + 1] = g;
output[pos + 2] = b;
output[pos + 3] = 255;
}
function grayPixel(img, i) {
var a = img[i + 3] / 255,
r = blend(img[i + 0], a),
g = blend(img[i + 1], a),
b = blend(img[i + 2], a);
return rgb2y(r, g, b);
}

View File

@@ -0,0 +1,39 @@
{
"name": "pixelmatch",
"version": "4.0.2",
"description": "The smallest and fastest pixel-level image comparison library.",
"main": "index.js",
"bin": {
"pixelmatch": "bin/pixelmatch"
},
"dependencies": {
"pngjs": "^3.0.0"
},
"devDependencies": {
"eslint": "^3.2.2",
"eslint-config-mourner": "^2.0.1",
"tap": "^6.3.0"
},
"scripts": {
"pretest": "eslint index.js bin/pixelmatch test/test.js",
"test": "tap test/test.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/mapbox/pixelmatch.git"
},
"keywords": [
"image",
"comparison",
"diff"
],
"eslintConfig": {
"extends": "mourner"
},
"author": "Vladimir Agafonkin",
"license": "ISC",
"bugs": {
"url": "https://github.com/mapbox/pixelmatch/issues"
},
"homepage": "https://github.com/mapbox/pixelmatch#readme"
}

View File

@@ -0,0 +1,8 @@
{
"folders":
[
{
"path": "."
}
]
}

View File

@@ -0,0 +1,756 @@
{
"auto_complete":
{
"selected_items":
[
[
"rgb",
"rgb2y"
],
[
"gra",
"grayPixel"
],
[
"remove",
"removeNode"
],
[
"maxT",
"maxTX"
],
[
"min",
"minTX"
],
[
"or",
"orient"
],
[
"left",
"leftmost"
],
[
"hole",
"holeNode"
],
[
"draw",
"drawRing"
],
[
"outer",
"outerNode"
],
[
"_upda",
"_updateTransform"
],
[
"_remove",
"_removeAllTiles"
],
[
"_reset",
"_resetAll"
],
[
"_update",
"_updateTransform"
],
[
"pane",
"panePos"
],
[
"fun",
"function"
]
]
},
"buffers":
[
{
"file": "index.js",
"settings":
{
"buffer_size": 5476,
"line_ending": "Unix"
}
},
{
"file": "README.md",
"settings":
{
"buffer_size": 3963,
"line_ending": "Unix"
}
},
{
"file": ".travis.yml",
"settings":
{
"buffer_size": 50,
"line_ending": "Unix"
}
},
{
"file": "test/test.js",
"settings":
{
"buffer_size": 1789,
"line_ending": "Unix"
}
}
],
"build_system": "",
"build_system_choices":
[
],
"build_varint": "",
"command_palette":
{
"height": 392.0,
"last_filter": "spac",
"selected_items":
[
[
"spac",
"Indentation: Convert to Spaces"
],
[
"spa",
"Indentation: Convert to Spaces"
],
[
"java",
"Set Syntax: JavaScript"
],
[
"insta",
"Package Control: Install Package"
],
[
"install ",
"Package Control: Install Package"
],
[
"packa",
"Package Control: Install Package"
]
],
"width": 467.0
},
"console":
{
"height": 126.0,
"history":
[
"import urllib.request,os,hashlib; h = 'eb2297e1a458f27d836c04bb0cbaf282' + 'd0e7a3098092775ccb37ca9d6b2e4b7d'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)"
]
},
"distraction_free":
{
"menu_visible": true,
"show_minimap": false,
"show_open_files": false,
"show_tabs": false,
"side_bar_visible": false,
"status_bar_visible": false
},
"expanded_folders":
[
"/Users/mourner/projects/pixelmatch",
"/Users/mourner/projects/pixelmatch/test",
"/Users/mourner/projects/pixelmatch/test/fixtures",
"/Users/mourner/projects/pixelmatch/tmp"
],
"file_history":
[
"/Users/mourner/projects/pixelmatch/max.js",
"/Users/mourner/projects/pixelmatch/test/fixtures/4diff.png",
"/Users/mourner/projects/pixelmatch/tmp/1.png",
"/Users/mourner/projects/pixelmatch/tmp/2.png",
"/Users/mourner/projects/pixelmatch/test/fixtures/3diff.png",
"/Users/mourner/projects/pixelmatch/test/fixtures/3diff2.png",
"/Users/mourner/projects/pixelmatch/test/fixtures/1diff.png",
"/Users/mourner/projects/pixelmatch/test/fixtures/1diff2.png",
"/Users/mourner/projects/pixelmatch/tmp/diff2.png",
"/Users/mourner/projects/pixelmatch/tmp/diff.png",
"/Users/mourner/projects/pixelmatch/test/fixtures/4diff2.png",
"/Users/mourner/projects/earcut/viz/viz.js",
"/Users/mourner/projects/earcut/viz/index.html",
"/Users/mourner/projects/earcut/test/fixtures/issue35.json",
"/Users/mourner/projects/earcut/test/fixtures/issue34.json",
"/Users/mourner/projects/earcut/src/earcut.js",
"/Users/mourner/projects/earcut/test/fixtures/dude.json",
"/Users/mourner/projects/earcut/bench/basic.js",
"/Users/mourner/projects/earcut/test/fixtures/empty-square.json",
"/Users/mourner/projects/earcut/test/fixtures/issue29.json",
"/Users/mourner/projects/earcut/test/test.js",
"/Users/mourner/projects/earcut/README.md",
"/Users/mourner/projects/earcut/bench/bench.js",
"/Users/mourner/projects/earcut/.travis.yml",
"/Users/mourner/projects/earcut/package.json",
"/Users/mourner/projects/earcut/.eslintrc",
"/Users/mourner/projects/geojson-vt/debug/debug.js",
"/Users/mourner/projects/geojson-vt/src/simplify.js",
"/Users/mourner/projects/geojson-vt/src/transform.js",
"/Users/mourner/projects/geojson-vt/debug/index.html",
"/Users/mourner/projects/geojson-vt/LICENSE",
"/Users/mourner/projects/geojson-vt/package.json",
"/Users/mourner/Library/Application Support/Sublime Text 3/Packages/Default/Preferences.sublime-settings",
"/Users/mourner/Library/Application Support/Sublime Text 3/Packages/User/Preferences.sublime-settings",
"/Users/mourner/projects/Leaflet/CHANGELOG.md",
"/usr/local/Library/Formula/node.rb",
"/Users/mourner/projects/Leaflet/package.json",
"/Users/mourner/projects/Leaflet/src/layer/tile/GridLayer.js",
"/Users/mourner/projects/Leaflet/Leaflet.sublime-project",
"/Users/mourner/projects/Leaflet/.eslintrc",
"/Users/mourner/projects/Leaflet/src/layer/marker/Icon.js",
"/Users/mourner/.inputrc",
"/Users/mourner/.bash_profile",
"/Users/mourner/.gitignore"
],
"find":
{
"height": 35.0
},
"find_in_files":
{
"height": 93.0,
"where_history":
[
""
]
},
"find_state":
{
"case_sensitive": false,
"find_history":
[
"17",
"1",
"r",
"1",
"255",
"blend",
" / 255",
"j",
"i",
"a1",
"img1",
"15",
"10",
"rgb2i",
"rgb2y",
"img2",
"rgba",
"rgba2y",
"= 5",
"5",
"10",
"++",
"1",
"r1",
">",
"],[",
"],",
">= 0",
"3600",
"3400",
",[[",
"findHoleB",
"]],",
"32767",
".next.prev",
"remove",
"break",
"ear",
"cureLocalIntersections",
"splitPolygon",
"32767",
"(maxX - minX)",
", minX, minY, maxX, maxY",
"minX, minY, maxX, maxY",
"32767",
"node.z",
"65535",
"0x3ff",
"65535",
"1023",
"console.log",
"console.log\\",
"minX, minY, size",
"minX, minY, ",
"1023",
"1024",
"x",
"size",
"1024",
"100000",
"0x0000ffff",
"100000",
"1000",
"100000",
"x = ",
"1024",
"1000",
"10",
"1024 * ",
"ceil",
"1000",
"x++",
" | 0",
"zOrder",
"1000",
".z",
"1000",
"1024",
"1000",
"zorder(",
"cureLocalIntersections",
"py",
"px",
" && ((s && t) || (s && k) || (t && k))",
"splitearcut",
"orient",
">= 0",
">=",
"poly",
"cureLocalIntersections",
"splitEarcut",
"2958",
"}",
"{",
"nextZ",
"node",
"c.i",
"a.i",
"node.i",
"i",
"node.i",
"prevZ ",
"data, ",
"indexCurve",
"p",
"data, ",
"data[b]",
"data[a]",
"data[b + 1]",
"data[a + 1]",
"data, ",
"eliminateHoles",
"data, ",
"data[i]",
"data, ",
"data",
"filterPoints(data, ",
"filterpoints",
"cureLocalIntersections",
"intersects(",
"intersects",
"locallyInside",
"middleInside",
"middleinside",
"data[a]",
"start",
"intersectsPolygon",
"orient(data, "
],
"highlight": true,
"in_selection": false,
"preserve_case": false,
"regex": false,
"replace_history":
[
"]",
"[",
"]",
"["
],
"reverse": false,
"show_context": true,
"use_buffer2": true,
"whole_word": false,
"wrap": true
},
"groups":
[
{
"selected": 2,
"sheets":
[
{
"buffer": 0,
"file": "index.js",
"semi_transient": false,
"settings":
{
"buffer_size": 5476,
"regions":
{
},
"selection":
[
[
567,
567
]
],
"settings":
{
"syntax": "Packages/JavaScript/JavaScript.sublime-syntax",
"tab_size": 4,
"translate_tabs_to_spaces": true
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 2,
"type": "text"
},
{
"buffer": 1,
"file": "README.md",
"semi_transient": false,
"settings":
{
"buffer_size": 3963,
"regions":
{
},
"selection":
[
[
301,
301
]
],
"settings":
{
"syntax": "Packages/Markdown/Markdown.sublime-syntax",
"tab_size": 4,
"translate_tabs_to_spaces": true
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 1,
"type": "text"
},
{
"buffer": 2,
"file": ".travis.yml",
"semi_transient": true,
"settings":
{
"buffer_size": 50,
"regions":
{
},
"selection":
[
[
0,
50
]
],
"settings":
{
"syntax": "Packages/YAML/YAML.sublime-syntax"
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 0,
"type": "text"
},
{
"buffer": 3,
"file": "test/test.js",
"semi_transient": false,
"settings":
{
"buffer_size": 1789,
"regions":
{
},
"selection":
[
[
0,
0
]
],
"settings":
{
"syntax": "Packages/JavaScript/JavaScript.sublime-syntax",
"tab_size": 4,
"translate_tabs_to_spaces": true
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 3,
"type": "text"
}
]
}
],
"incremental_find":
{
"height": 23.0
},
"input":
{
"height": 31.0
},
"layout":
{
"cells":
[
[
0,
0,
1,
1
]
],
"cols":
[
0.0,
1.0
],
"rows":
[
0.0,
1.0
]
},
"menu_visible": true,
"output.find_results":
{
"height": 0.0
},
"pinned_build_system": "",
"project": "pixelmatch.sublime-project",
"replace":
{
"height": 42.0
},
"save_all_on_build": true,
"select_file":
{
"height": 0.0,
"last_filter": "",
"selected_items":
[
[
"in",
"index.js"
],
[
"ear",
"src/earcut.js"
],
[
"viz",
"viz/viz.js"
],
[
"ben",
"bench/bench.js"
],
[
"test",
"test/test.js"
],
[
"du",
"test/fixtures/dude.json"
],
[
"vi",
"viz/viz.js"
],
[
"ind",
"viz/index.html"
],
[
"popu",
"src/layer/Popup.js"
],
[
"rend",
"src/layer/vector/Renderer.js"
],
[
"image",
"src/layer/ImageOverlay.js"
],
[
"path",
"src/layer/vector/Path.js"
],
[
"render",
"src/layer/vector/Renderer.js"
],
[
"marker",
"src/layer/marker/Marker.js"
],
[
"fl",
"src/map/anim/Map.FlyTo.js"
],
[
"grid",
"src/layer/tile/GridLayer.js"
],
[
"map",
"src/map/Map.js"
],
[
"polyli",
"src/layer/vector/Polyline.js"
],
[
"mapsp",
"spec/suites/map/MapSpec.js"
],
[
"popup",
"src/layer/Popup.js"
],
[
"crs",
"src/geo/crs/CRS.js"
],
[
"touch",
"src/map/handler/Map.TouchZoom.js"
],
[
"poly",
"src/layer/vector/Polyline.js"
],
[
"leafl",
"dist/leaflet.css"
],
[
"zoompa",
"debug/map/zoompan.html"
],
[
"map.dra",
"src/map/handler/Map.Drag.js"
],
[
"chan",
"CHANGELOG.md"
],
[
"domut",
"src/dom/DomUtil.js"
],
[
"scroll",
"src/map/handler/Map.ScrollWheelZoom.js"
],
[
"leaf",
"dist/leaflet.css"
],
[
"dom",
"src/dom/DomUtil.js"
],
[
"sv",
"src/layer/vector/SVG.js"
],
[
"re",
"src/layer/vector/Renderer.js"
],
[
"ren",
"src/layer/vector/Renderer.js"
],
[
"svg",
"src/layer/vector/SVG.js"
],
[
"even",
"src/core/Events.js"
],
[
"iamge",
"src/layer/ImageOverlay.js"
],
[
"icon",
"src/layer/marker/Icon.js"
],
[
"drag",
"src/map/handler/Map.Drag.js"
]
],
"width": 0.0
},
"select_project":
{
"height": 500.0,
"last_filter": "",
"selected_items":
[
[
"gl",
"~/projects/mapbox-gl-js/mapbox-gl-js.sublime-project"
],
[
"le",
"~/projects/Leaflet/Leaflet.sublime-project"
],
[
"",
"~/projects/rbush/rbush.sublime-project"
]
],
"width": 380.0
},
"select_symbol":
{
"height": 0.0,
"last_filter": "",
"selected_items":
[
],
"width": 0.0
},
"selected_group": 0,
"settings":
{
},
"show_minimap": true,
"show_open_files": false,
"show_tabs": true,
"side_bar_visible": true,
"side_bar_width": 249.0,
"status_bar_visible": true,
"template_settings":
{
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

View File

@@ -0,0 +1,47 @@
'use strict';
var PNG = require('pngjs').PNG,
fs = require('fs'),
test = require('tap').test,
path = require('path'),
match = require('../.');
diffTest('1a', '1b', '1diff', 0.05, false, 143);
diffTest('2a', '2b', '2diff', 0.05, false, 12439);
diffTest('3a', '3b', '3diff', 0.05, false, 212);
diffTest('4a', '4b', '4diff', 0.05, false, 36089);
function diffTest(imgPath1, imgPath2, diffPath, threshold, includeAA, expectedMismatch) {
var name = 'comparing ' + imgPath1 + ' to ' + imgPath2 +
', threshold: ' + threshold + ', includeAA: ' + includeAA;
test(name, function (t) {
var img1 = readImage(imgPath1, function () {
var img2 = readImage(imgPath2, function () {
var expectedDiff = readImage(diffPath, function () {
var diff = new PNG({width: img1.width, height: img1.height});
var mismatch = match(img1.data, img2.data, diff.data, diff.width, diff.height, {
threshold: threshold,
includeAA: includeAA
});
var mismatch2 = match(img1.data, img2.data, null, diff.width, diff.height, {
threshold: threshold,
includeAA: includeAA
});
t.same(diff.data, expectedDiff.data, 'diff image');
t.same(mismatch, expectedMismatch, 'number of mismatched pixels');
t.same(mismatch, mismatch2, 'number of mismatched pixels');
t.end();
});
});
});
});
}
function readImage(name, done) {
return fs.createReadStream(path.join(__dirname, '/fixtures/' + name + '.png')).pipe(new PNG()).on('parsed', done);
}