pixelmatch

temporary lib: [email protected]

当前为 2020-04-19 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/401377/794438/pixelmatch.js

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).pixelmatch=t()}}(function(){return function(){return function t(e,n,r){function o(i,u){if(!n[i]){if(!e[i]){var a="function"==typeof require&&require;if(!u&&a)return a(i,!0);if(f)return f(i,!0);var l=new Error("Cannot find module '"+i+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[i]={exports:{}};e[i][0].call(c.exports,function(t){return o(e[i][1][t]||t)},c,c.exports,t,e,n,r)}return n[i].exports}for(var f="function"==typeof require&&require,i=0;i<r.length;i++)o(r[i]);return o}}()({1:[function(t,e,n){"use strict";e.exports=function(t,e,n,i,a,l){if(!o(t)||!o(e)||n&&!o(n))throw new Error("Image data: Uint8Array, Uint8ClampedArray or Buffer expected.");if(t.length!==e.length||n&&n.length!==t.length)throw new Error("Image sizes do not match.");if(t.length!==i*a*4)throw new Error("Image data size does not match width/height.");l=Object.assign({},r,l);const c=i*a,s=new Uint32Array(t.buffer,t.byteOffset,c),p=new Uint32Array(e.buffer,e.byteOffset,c);let m=!0;for(let t=0;t<c;t++)if(s[t]!==p[t]){m=!1;break}if(m){if(n&&!l.diffMask)for(let e=0;e<c;e++)h(t,4*e,l.alpha,n);return 0}const w=35215*l.threshold*l.threshold;let y=0;for(let r=0;r<a;r++)for(let o=0;o<i;o++){const c=4*(r*i+o),s=u(t,e,c,c);Math.abs(s)>w?l.includeAA||!f(t,o,r,i,a,e)&&!f(e,o,r,i,a,t)?(n&&d(n,c,...s<0&&l.diffColorAlt||l.diffColor),y++):n&&!l.diffMask&&d(n,c,...l.aaColor):n&&(l.diffMask||h(t,c,l.alpha,n))}return y};const r={threshold:.1,includeAA:!1,alpha:.1,aaColor:[255,255,0],diffColor:[255,0,0],diffColorAlt:null,diffMask:!1};function o(t){return ArrayBuffer.isView(t)&&1===t.constructor.BYTES_PER_ELEMENT}function f(t,e,n,r,o,f){const a=Math.max(e-1,0),l=Math.max(n-1,0),c=Math.min(e+1,r-1),s=Math.min(n+1,o-1),d=4*(n*r+e);let h,p,m,w,y=e===a||e===c||n===l||n===s?1:0,M=0,g=0;for(let o=a;o<=c;o++)for(let f=l;f<=s;f++){if(o===e&&f===n)continue;const i=u(t,t,d,4*(f*r+o),!0);if(0===i){if(++y>2)return!1}else i<M?(M=i,h=o,p=f):i>g&&(g=i,m=o,w=f)}return 0!==M&&0!==g&&(i(t,h,p,r,o)&&i(f,h,p,r,o)||i(t,m,w,r,o)&&i(f,m,w,r,o))}function i(t,e,n,r,o){const f=Math.max(e-1,0),i=Math.max(n-1,0),u=Math.min(e+1,r-1),a=Math.min(n+1,o-1),l=4*(n*r+e);let c=e===f||e===u||n===i||n===a?1:0;for(let o=f;o<=u;o++)for(let f=i;f<=a;f++){if(o===e&&f===n)continue;const i=4*(f*r+o);if(t[l]===t[i]&&t[l+1]===t[i+1]&&t[l+2]===t[i+2]&&t[l+3]===t[i+3]&&c++,c>2)return!0}return!1}function u(t,e,n,r,o){let f=t[n+0],i=t[n+1],u=t[n+2],d=t[n+3],h=e[r+0],p=e[r+1],m=e[r+2],w=e[r+3];if(d===w&&f===h&&i===p&&u===m)return 0;d<255&&(f=s(f,d/=255),i=s(i,d),u=s(u,d)),w<255&&(h=s(h,w/=255),p=s(p,w),m=s(m,w));const y=a(f,i,u),M=a(h,p,m),g=y-M;if(o)return g;const x=l(f,i,u)-l(h,p,m),A=c(f,i,u)-c(h,p,m),b=.5053*g*g+.299*x*x+.1957*A*A;return y>M?-b:b}function a(t,e,n){return.29889531*t+.58662247*e+.11448223*n}function l(t,e,n){return.59597799*t-.2741761*e-.32180189*n}function c(t,e,n){return.21147017*t-.52261711*e+.31114694*n}function s(t,e){return 255+(t-255)*e}function d(t,e,n,r,o){t[e+0]=n,t[e+1]=r,t[e+2]=o,t[e+3]=255}function h(t,e,n,r){const o=s(a(t[e+0],t[e+1],t[e+2]),n*t[e+3]/255);d(r,e,o,o,o)}},{}]},{},[1])(1)});