Skip to content
This repository
Browse code

Built.

Floating styles for matcher.
  • Loading branch information...
commit 65bcca7eb48817fcc9e59fb7be14b93df7c0e795 1 parent 9793bc9
Carl Sutherland cesutherland authored

Showing 2 changed files with 6 additions and 1 deletion. Show diff stats Hide diff stats

  1. +5 0 imagediff.js
  2. +1 1  imagediff.min.js
5 imagediff.js
@@ -290,6 +290,11 @@
290 290 canvas.height = diff.height;
291 291 canvas.width = diff.width;
292 292
  293 + div.style.overflow = 'hidden';
  294 + a.style.float = 'left';
  295 + b.style.float = 'left';
  296 + c.style.float = 'left';
  297 +
293 298 context = canvas.getContext('2d');
294 299 context.putImageData(diff, 0, 0);
295 300
2  imagediff.min.js
@@ -4,4 +4,4 @@
4 4 // For original source and documentation visit:
5 5 // http://www.github.com/HumbleSoftware/js-imagediff
6 6
7   -(function(a,b){var c=this;if(typeof module!="undefined"){var d=require("canvas");module.exports=b(c,a,d)}else typeof define=="function"&&typeof define.amd=="object"?define(b):c[a]=b(c,a)})("imagediff",function(a,b,c){function o(a,b){var d=c?new c:document.createElement("canvas");return a&&(d.width=a),b&&(d.height=b),d}function p(a,b){return j.width=a,j.height=b,k.clearRect(0,0,a,b),k.createImageData(a,b)}function q(a){return v(a,g)}function r(a){return v(a,e)}function s(a){return v(a,f)}function t(a){return!!a&&!!v(a,h)&&typeof a.width!==i&&typeof a.height!==i&&typeof a.data!==i}function u(a){return q(a)||r(a)||s(a)||t(a)}function v(a,b){return typeof a=="object"&&!!Object.prototype.toString.apply(a).match(b)}function w(a){var b=a.height,c=a.width,d=a.data,e,f,g;j.width=c,j.height=b,e=k.getImageData(0,0,c,b),f=e.data;for(g=a.data.length;g--;)f[g]=d[g];return e}function x(a){if(q(a))return y(a);if(r(a))return z(a);if(s(a))return A(a);if(t(a))return a}function y(a){var b=a.height,c=a.width;return j.width=c,j.height=b,k.clearRect(0,0,c,b),k.drawImage(a,0,0),k.getImageData(0,0,c,b)}function z(a){var b=a.height,c=a.width,d=a.getContext("2d");return d.getImageData(0,0,c,b)}function A(a){var b=a.canvas,c=b.height,d=b.width;return a.getImageData(0,0,d,c)}function B(a){var b=x(a),c=o(b.width,b.height),d=c.getContext("2d");return d.putImageData(b,0,0),c}function C(a,b){return a.width===b.width}function D(a,b){return a.height===b.height}function E(a,b){return D(a,b)&&C(a,b)}function F(a,b,c){var d=a.data,e=b.data,f=d.length,g;c=c||0;if(!E(a,b))return!1;for(g=f;g--;)if(d[g]!==e[g]&&Math.abs(d[g]-e[g])>c)return!1;return!0}function G(a,b){return(E(a,b)?H:I)(a,b)}function H(a,b){var c=a.height,d=a.width,e=p(d,c),f=a.data,g=b.data,h=e.data,i=h.length,j,k,l,m,n,o;for(l=0;l<i;l+=4)h[l]=Math.abs(f[l]-g[l]),h[l+1]=Math.abs(f[l+1]-g[l+1]),h[l+2]=Math.abs(f[l+2]-g[l+2]),h[l+3]=Math.abs(255-f[l+3]-g[l+3]);return e}function I(a,b){function r(a){i=Math.floor((c-a.height)/2),j=Math.floor((d-a.width)/2)}var c=Math.max(a.height,b.height),d=Math.max(a.width,b.width),e=p(d,c),f=a.data,g=b.data,h=e.data,i,j,k,l,m,n,o,q;for(m=h.length-1;m>0;m-=4)h[m]=255;r(a);for(k=a.height;k--;)for(l=a.width;l--;)m=4*((k+i)*d+(l+j)),n=4*(k*a.width+l),h[m+0]=f[n+0],h[m+1]=f[n+1],h[m+2]=f[n+2];r(b);for(k=b.height;k--;)for(l=b.width;l--;)m=4*((k+i)*d+(l+j)),n=4*(k*b.width+l),h[m+0]=Math.abs(h[m+0]-g[n+0]),h[m+1]=Math.abs(h[m+1]-g[n+1]),h[m+2]=Math.abs(h[m+2]-g[n+2]);return e}function J(){var a;for(a=0;a<arguments.length;a++)if(!u(arguments[a]))throw{name:"ImageTypeError",message:"Submitted object was not an image."}}function K(a,b){return a=document.createElement(a),a&&b&&(a.innerHTML=b),a}function L(a,b,c){var d=B(a),e,f;c=c||Function,e=d.toDataURL().replace(/^data:image\/\w+;base64,/,""),f=new Buffer(e,"base64"),require("fs").writeFile(b,f,c)}var d=/\[object Array\]/i,e=/\[object (Canvas|HTMLCanvasElement)\]/i,f=/\[object CanvasRenderingContext2D\]/i,g=/\[object (Image|HTMLImageElement)\]/i,h=/\[object ImageData\]/i,i="undefined",j=o(),k=j.getContext("2d"),l=a[b],m,n;return n={toBeImageData:function(){return m.isImageData(this.actual)},toImageDiffEqual:function(a,b){return typeof document!==i&&(this.message=function(){var b=K("div"),c=K("div","<div>Actual:</div>"),d=K("div","<div>Expected:</div>"),e=K("div","<div>Diff:</div>"),f=m.diff(this.actual,a),g=o(),h;return g.height=f.height,g.width=f.width,h=g.getContext("2d"),h.putImageData(f,0,0),c.appendChild(B(this.actual)),d.appendChild(B(a)),e.appendChild(g),b.appendChild(c),b.appendChild(d),b.appendChild(e),[b,"Expected not to be equal."]}),m.equal(this.actual,a,b)}},m={createCanvas:o,createImageData:p,isImage:q,isCanvas:r,isContext:s,isImageData:t,isImageType:u,toImageData:function(a){return J(a),t(a)?w(a):x(a)},equal:function(a,b,c){return J(a,b),a=x(a),b=x(b),F(a,b,c)},diff:function(a,b){return J(a,b),a=x(a),b=x(b),G(a,b)},jasmine:n,noConflict:function(){return a[b]=l,m}},typeof module!="undefined"&&(m.imageDataToPNG=L),m})
  7 +(function(a,b){var c=this;if(typeof module!="undefined"){var d=require("canvas");module.exports=b(c,a,d)}else typeof define=="function"&&typeof define.amd=="object"?define(b):c[a]=b(c,a)})("imagediff",function(a,b,c){function o(a,b){var d=c?new c:document.createElement("canvas");return a&&(d.width=a),b&&(d.height=b),d}function p(a,b){return j.width=a,j.height=b,k.clearRect(0,0,a,b),k.createImageData(a,b)}function q(a){return v(a,g)}function r(a){return v(a,e)}function s(a){return v(a,f)}function t(a){return!!a&&!!v(a,h)&&typeof a.width!==i&&typeof a.height!==i&&typeof a.data!==i}function u(a){return q(a)||r(a)||s(a)||t(a)}function v(a,b){return typeof a=="object"&&!!Object.prototype.toString.apply(a).match(b)}function w(a){var b=a.height,c=a.width,d=a.data,e,f,g;j.width=c,j.height=b,e=k.getImageData(0,0,c,b),f=e.data;for(g=a.data.length;g--;)f[g]=d[g];return e}function x(a){if(q(a))return y(a);if(r(a))return z(a);if(s(a))return A(a);if(t(a))return a}function y(a){var b=a.height,c=a.width;return j.width=c,j.height=b,k.clearRect(0,0,c,b),k.drawImage(a,0,0),k.getImageData(0,0,c,b)}function z(a){var b=a.height,c=a.width,d=a.getContext("2d");return d.getImageData(0,0,c,b)}function A(a){var b=a.canvas,c=b.height,d=b.width;return a.getImageData(0,0,d,c)}function B(a){var b=x(a),c=o(b.width,b.height),d=c.getContext("2d");return d.putImageData(b,0,0),c}function C(a,b){return a.width===b.width}function D(a,b){return a.height===b.height}function E(a,b){return D(a,b)&&C(a,b)}function F(a,b,c){var d=a.data,e=b.data,f=d.length,g;c=c||0;if(!E(a,b))return!1;for(g=f;g--;)if(d[g]!==e[g]&&Math.abs(d[g]-e[g])>c)return!1;return!0}function G(a,b){return(E(a,b)?H:I)(a,b)}function H(a,b){var c=a.height,d=a.width,e=p(d,c),f=a.data,g=b.data,h=e.data,i=h.length,j,k,l,m,n,o;for(l=0;l<i;l+=4)h[l]=Math.abs(f[l]-g[l]),h[l+1]=Math.abs(f[l+1]-g[l+1]),h[l+2]=Math.abs(f[l+2]-g[l+2]),h[l+3]=Math.abs(255-f[l+3]-g[l+3]);return e}function I(a,b){function r(a){i=Math.floor((c-a.height)/2),j=Math.floor((d-a.width)/2)}var c=Math.max(a.height,b.height),d=Math.max(a.width,b.width),e=p(d,c),f=a.data,g=b.data,h=e.data,i,j,k,l,m,n,o,q;for(m=h.length-1;m>0;m-=4)h[m]=255;r(a);for(k=a.height;k--;)for(l=a.width;l--;)m=4*((k+i)*d+(l+j)),n=4*(k*a.width+l),h[m+0]=f[n+0],h[m+1]=f[n+1],h[m+2]=f[n+2];r(b);for(k=b.height;k--;)for(l=b.width;l--;)m=4*((k+i)*d+(l+j)),n=4*(k*b.width+l),h[m+0]=Math.abs(h[m+0]-g[n+0]),h[m+1]=Math.abs(h[m+1]-g[n+1]),h[m+2]=Math.abs(h[m+2]-g[n+2]);return e}function J(){var a;for(a=0;a<arguments.length;a++)if(!u(arguments[a]))throw{name:"ImageTypeError",message:"Submitted object was not an image."}}function K(a,b){return a=document.createElement(a),a&&b&&(a.innerHTML=b),a}function L(a,b,c){var d=B(a),e,f;c=c||Function,e=d.toDataURL().replace(/^data:image\/\w+;base64,/,""),f=new Buffer(e,"base64"),require("fs").writeFile(b,f,c)}var d=/\[object Array\]/i,e=/\[object (Canvas|HTMLCanvasElement)\]/i,f=/\[object CanvasRenderingContext2D\]/i,g=/\[object (Image|HTMLImageElement)\]/i,h=/\[object ImageData\]/i,i="undefined",j=o(),k=j.getContext("2d"),l=a[b],m,n;return n={toBeImageData:function(){return m.isImageData(this.actual)},toImageDiffEqual:function(a,b){return typeof document!==i&&(this.message=function(){var b=K("div"),c=K("div","<div>Actual:</div>"),d=K("div","<div>Expected:</div>"),e=K("div","<div>Diff:</div>"),f=m.diff(this.actual,a),g=o(),h;return g.height=f.height,g.width=f.width,b.style.overflow="hidden",c.style.float="left",d.style.float="left",e.style.float="left",h=g.getContext("2d"),h.putImageData(f,0,0),c.appendChild(B(this.actual)),d.appendChild(B(a)),e.appendChild(g),b.appendChild(c),b.appendChild(d),b.appendChild(e),[b,"Expected not to be equal."]}),m.equal(this.actual,a,b)}},m={createCanvas:o,createImageData:p,isImage:q,isCanvas:r,isContext:s,isImageData:t,isImageType:u,toImageData:function(a){return J(a),t(a)?w(a):x(a)},equal:function(a,b,c){return J(a,b),a=x(a),b=x(b),F(a,b,c)},diff:function(a,b){return J(a,b),a=x(a),b=x(b),G(a,b)},jasmine:n,noConflict:function(){return a[b]=l,m}},typeof module!="undefined"&&(m.imageDataToPNG=L),m})

0 comments on commit 65bcca7

Please sign in to comment.
Something went wrong with that request. Please try again.