/*!
CamanJS - Pure HTML5 Javascript (Ca)nvas (Man)ipulation
http://camanjs.com/
Copyright 2011, Ryan LeFevre
Licensed under the new BSD License.
See LICENSE for more info.
Project Contributors:
Rick Waldron - Plugin Architect and Developer
Twitter: @rwaldron
GitHub: http://github.com/rwldrn
Cezar Sa Espinola - Developer
Twitter: @cezarsa
GitHub: http://github.com/cezarsa
*/(function(){var forEach=Array.prototype.forEach,hasOwn=Object.prototype.hasOwnProperty,slice=Array.prototype.slice,$=function(id){if(id.substr(0,1)=='#'){id=id.substr(1);}
return document.getElementById(id);},Caman=function(){if(arguments.length==1){if(Caman.store[arguments[0]]){return Caman.store[arguments[0]];}else{return new Caman.manip.loadImage(arguments[0]);}}else if(arguments.length==2){if(Caman.store[arguments[0]]){return arguments[1].call(Caman.store[arguments[0]],Caman.store[arguments[0]]);}else{if(typeof arguments[1]==='function'){return new Caman.manip.loadImage(arguments[0],arguments[1]);}else if(typeof arguments[1]==='string'){return new Caman.manip.loadCanvas(arguments[0],arguments[1]);}}}else if(arguments.length==3){if(Caman.store[arguments[0]]){return arguments[2].call(Caman.store[arguments[1]],Caman.store[arguments[1]]);}else{return new Caman.manip.loadCanvas(arguments[0],arguments[1],arguments[2]);}}};if(!('console'in window)){window.console={log:function(){},info:function(){},error:function(){}};}
Caman.ready=false;Caman.store={};Caman.renderBlocks=4;Caman.remoteProxy="";Caman.useProxy=function(lang){var langToExt={ruby:'rb',python:'py',perl:'pl'};lang=langToExt[lang.toLowerCase()]||lang.toLowerCase();return"proxies/caman_proxy."+lang;};Caman.uniqid=(function(){var id=0;return{get:function(){return id++;},reset:function(){id=0;}};}());var remoteCheck=function(src){if(Caman.isRemote(src)){if(!Caman.remoteProxy.length){console.info("Attempting to load remote image without a configured proxy, URL: "+src);return;}else{if(Caman.isRemote(Caman.remoteProxy)){console.info("Cannot use a remote proxy for loading remote images due to same-origin policy");return;}
return Caman.remoteProxy+"?url="+encodeURIComponent(src);}}};var finishInit=function(image,canvas,callback){var self=this;this.pixelStack=[];this.layerStack=[];canvas.width=image.width;canvas.height=image.height;this.canvas=canvas;this.context=canvas.getContext("2d");this.context.drawImage(image,0,0);this.image_data=this.context.getImageData(0,0,image.width,image.height);this.pixel_data=this.image_data.data;this.dimensions={width:image.width,height:image.height};this.renderQueue=[];Caman.store[this.canvas_id]=this;callback.call(this,this);return this;};Caman.manip=Caman.prototype={loadImage:function(image_id,callback){var domLoaded,self=this,startFn=function(){var canvas=document.createElement('canvas'),image=$(image_id),proxyURL=remoteCheck(image.src);if($(image_id)===null||$(image_id).nodeName.toLowerCase()!=='img'){throw"Given element ID isn't an image: "+image_id;}
canvas.id=image.id;image.parentNode.replaceChild(canvas,image);if(proxyURL){image.src=proxyURL;}
this.canvas_id=image_id;this.options={canvas:image_id,image:image.src};image.onload=function(){finishInit.call(self,image,canvas,callback);};return this;};callback=callback||function(){};if(typeof image_id==="object"&&image_id.nodeName.toLowerCase()=="img"){var element=image_id;if(image_id.id){image_id=element.id;}else{image_id="caman-"+Caman.uniqid.get();element.id=image_id;}}
domLoaded=($(image_id)!==null);if(domLoaded){startFn.call(this);}else{document.addEventListener("DOMContentLoaded",function(){startFn.call(self);},false);}
return this;},loadCanvas:function(url,canvas_id,callback){var domLoaded,self=this,startFn=function(){var canvas=$(canvas_id),image=document.createElement('img'),proxyURL=remoteCheck(url);if($(canvas_id)===null||$(canvas_id).nodeName.toLowerCase()!=='canvas'){throw"Given element ID isn't a canvas: "+canvas_id;}
if(proxyURL){image.src=proxyURL;}else{image.src=url;}
this.canvas_id=canvas_id;this.options={canvas:canvas_id,image:image.src};image.onload=function(){finishInit.call(self,image,canvas,callback);};};callback=callback||function(){};if(typeof canvas_id==="object"&&canvas_id.nodeName.toLowerCase()=="canvas"){var element=canvas_id;if(canvas_id.id){canvas_id=element.id;}else{canvas_id="caman-"+Caman.uniqid.get();element.id=canvas_id;}}
domLoaded=($(canvas_id)!==null);if(domLoaded){startFn.call(this);}else{document.addEventListener("DOMContentLoaded",function(){startFn.call(self);},false);}
return this;},save:function(type){if(type){type=type.toLowerCase();}
if(!type||(type!=='png'&&type!=='jpg')){type='png';}
var data=this.toBase64(type).replace("image/"+type,"image/octet-stream");document.location.href=data;},toImage:function(type){var img,data;data=this.toBase64(type);img=document.createElement('img');img.src=data;return img;},toBase64:function(type){if(type){type=type.toLowerCase();}
if(!type||(type!=='png'&&type!=='jpg')){type='png';}
return this.canvas.toDataURL("image/"+type);},revert:function(ready){this.loadCanvas(this.options.image,this.options.canvas,ready);},render:function(callback){this.processNext(function(){this.context.putImageData(this.image_data,0,0);if(typeof callback==='function'){callback.call(this);}});}};Caman.manip.loadImage.prototype=Caman.manip;Caman.manip.loadCanvas.prototype=Caman.manip;Caman.forEach=function(obj,fn,context){if(!obj||!fn){return{};}
context=context||this;if(forEach&&obj.forEach===forEach){return obj.forEach(fn,context);}
for(var key in obj){if(hasOwn.call(obj,key)){fn.call(context,obj[key],key,obj);}}
return obj;};Caman.extend=function(obj){var dest=obj,src=slice.call(arguments,1);Caman.forEach(src,function(copy){for(var prop in copy){dest[prop]=copy[prop];}});return dest;};Caman.extend(Caman,{processKernel:function(adjust,kernel,divisor,bias){var val={r:0,g:0,b:0};for(var i=0;i255){val.r=255;}else if(val.r<0){val.r=0;}
if(val.g>255){val.g=255;}else if(val.g<0){val.g=0;}
if(val.b>255){val.b=255;}else if(val.b<0){val.b=0;}
return val;}});Caman.events={types:["processStart","processComplete","renderFinished"],fn:{trigger:function(target,type,data){var _target=target,_type=type,_data=data;if(Caman.events.types.indexOf(target)!==-1){_target=this;_type=target;_data=type;}
if(Caman.events.fn[_type]&&Caman.sizeOf(Caman.events.fn[_type])){Caman.forEach(Caman.events.fn[_type],function(obj,key){obj.call(_target,_data);});}},listen:function(target,type,fn){var _target=target,_type=type,_fn=fn;if(Caman.events.types.indexOf(target)!==-1){_target=this;_type=target;_fn=type;}
if(!Caman.events.fn[_type]){Caman.events.fn[_type]=[];}
Caman.events.fn[_type].push(_fn);return true;}},cache:{}};(function(Caman){Caman.forEach(["trigger","listen"],function(key){Caman[key]=Caman.events.fn[key];});})(Caman);var ProcessType={SINGLE:1,KERNEL:2,LAYER_DEQUEUE:3,LAYER_FINISHED:4};Caman.manip.pixelInfo=function(loc,self){this.loc=loc;this.manip=self;};Caman.manip.pixelInfo.prototype.locationXY=function(){var x,y;y=this.manip.dimensions.height-Math.floor(this.loc/(this.manip.dimensions.width*4));x=((this.loc%(this.manip.dimensions.width*4))/4)-1;return{x:x,y:y};};Caman.manip.pixelInfo.prototype.getPixelRelative=function(horiz_offset,vert_offset){var newLoc=this.loc+(this.manip.dimensions.width*4*(vert_offset*-1))+(4*horiz_offset);if(newLoc>this.manip.pixel_data.length||newLoc<0){return{r:0,g:0,b:0,a:0};}
return{r:this.manip.pixel_data[newLoc],g:this.manip.pixel_data[newLoc+1],b:this.manip.pixel_data[newLoc+2],a:this.manip.pixel_data[newLoc+3]};};Caman.manip.pixelInfo.prototype.putPixelRelative=function(horiz_offset,vert_offset,rgba){var newLoc=this.loc+(this.manip.dimensions.width*4*(vert_offset*-1))+(4*horiz_offset);if(newLoc>this.manip.pixel_data.length||newLoc<0){return false;}
this.manip.pixel_data[newLoc]=rgba.r;this.manip.pixel_data[newLoc+1]=rgba.g;this.manip.pixel_data[newLoc+2]=rgba.b;this.manip.pixel_data[newLoc+3]=rgba.a;};Caman.manip.pixelInfo.prototype.getPixel=function(x,y){var newLoc=(y*this.manip.dimensions.width+x)*4;return{r:this.manip.pixel_data[newLoc],g:this.manip.pixel_data[newLoc+1],b:this.manip.pixel_data[newLoc+2],a:this.manip.pixel_data[newLoc+3]};};Caman.manip.pixelInfo.prototype.putPixel=function(x,y,rgba){var newLoc=(y*this.manip.dimensions.width+x)*4;this.manip.pixel_data[newLoc]=rgba.r;this.manip.pixel_data[newLoc+1]=rgba.g;this.manip.pixel_data[newLoc+2]=rgba.b;this.manip.pixel_data[newLoc+3]=rgba.a;};Caman.manip.canvasQueue=[];Caman.manip.newLayer=function(callback){var layer=new Caman.manip.canvasLayer(this);this.canvasQueue.push(layer);this.renderQueue.push({type:ProcessType.LAYER_DEQUEUE});callback.call(layer);return this;};Caman.manip.canvasLayer=function(manip){this.options={blendingMode:'normal',opacity:1.0};this.layerID=Caman.uniqid.get();this.canvas=document.createElement('canvas');this.canvas.id='camanlayer-'+this.layerID;this.canvas.width=manip.dimensions.width;this.canvas.height=manip.dimensions.height;this.canvas.style.display='none';document.body.appendChild(this.canvas);this.context=this.canvas.getContext("2d");this.context.createImageData(this.canvas.width,this.canvas.height);this.image_data=this.context.getImageData(0,0,this.canvas.width,this.canvas.height);this.pixel_data=this.image_data.data;this.__defineGetter__("filter",function(){return manip;});return this;};Caman.manip.canvasLayer.prototype.newLayer=function(callback){return this.filter.newLayer.call(this.filter,callback);};Caman.manip.canvasLayer.prototype.destroy=function(){var canvas=document.getElementById(this.canvas.id);canvas.parentNode.removeChild(canvas);};Caman.manip.canvasLayer.prototype.setBlendingMode=function(mode){this.options.blendingMode=mode;return this;};Caman.manip.canvasLayer.prototype.opacity=function(opacity){this.options.opacity=(opacity/100);return this;};Caman.manip.canvasLayer.prototype.copyParent=function(){var parentData=this.filter.pixel_data;for(var i=0;i128)?255-2*(255-rgbaLayer.r)*(255-rgbaParent.r)/255:(rgbaParent.r*rgbaLayer.r*2)/255;rgbaParent.g=(rgbaParent.g>128)?255-2*(255-rgbaLayer.g)*(255-rgbaParent.g)/255:(rgbaParent.g*rgbaLayer.g*2)/255;rgbaParent.b=(rgbaParent.b>128)?255-2*(255-rgbaLayer.b)*(255-rgbaParent.b)/255:(rgbaParent.b*rgbaLayer.b*2)/255;return rgbaParent;},difference:function(rgbaLayer,rgbaParent){rgbaParent.r=rgbaLayer.r-rgbaParent.r;rgbaParent.g=rgbaLayer.g-rgbaParent.g;rgbaParent.b=rgbaLayer.b-rgbaParent.b;return rgbaParent;},addition:function(rgbaLayer,rgbaParent){rgbaParent.r=rgbaParent.r+rgbaLayer.r;rgbaParent.g=rgbaParent.g+rgbaLayer.g;rgbaParent.b=rgbaParent.b+rgbaLayer.b;return rgbaParent;},exclusion:function(rgbaLayer,rgbaParent){rgbaParent.r=128-2*(rgbaParent.r-128)*(rgbaLayer.r-128)/255;rgbaParent.g=128-2*(rgbaParent.g-128)*(rgbaLayer.g-128)/255;rgbaParent.b=128-2*(rgbaParent.b-128)*(rgbaLayer.b-128)/255;return rgbaParent;},softLight:function(rgbaLayer,rgbaParent){rgbaParent.r=(rgbaParent.r>128)?255-((255-rgbaParent.r)*(255-(rgbaLayer.r-128)))/255:(rgbaParent.r*(rgbaLayer.r+128))/255;rgbaParent.g=(rgbaParent.g>128)?255-((255-rgbaParent.g)*(255-(rgbaLayer.g-128)))/255:(rgbaParent.g*(rgbaLayer.g+128))/255;rgbaParent.b=(rgbaParent.b>128)?255-((255-rgbaParent.b)*(255-(rgbaLayer.b-128)))/255:(rgbaParent.b*(rgbaLayer.b+128))/255;return rgbaParent;}};Caman.manip.blenders=Caman.manip.canvasLayer.prototype.blenders;Caman.manip.executeFilter=function(adjust,processFn,type){var n=this.pixel_data.length,res=null,blockPixelLength=Math.floor((n/4)/Caman.renderBlocks),blockN=blockPixelLength*4,lastBlockN=blockN+((n/4)%Caman.renderBlocks)*4,self=this,blocks_done=0,block_finished=function(bnum){if(bnum>=0){console.log("Block #"+bnum+" finished! Filter: "+processFn.name);}
blocks_done++;if(blocks_done==Caman.renderBlocks||bnum==-1){if(bnum>=0){console.log("Filter "+processFn.name+" finished!");}else{console.log("Kernel filter finished!");}
Caman.trigger("processComplete",{id:self.canvas_id,completed:processFn.name});self.processNext();}},render_block=function(bnum,start,end){console.log("BLOCK #"+bnum+" - Filter: "+processFn.name+", Start: "+start+", End: "+end);setTimeout(function(){for(var i=start;i=0;i--){if(base[i]!==test[i]){return false;}}
return true;},isRemote:function(url){var domain_regex=/(?:(?:http|https):\/\/)((?:\w+)\.(?:(?:\w|\.)+))/,test_domain;if(!url||!url.length){return;}
var matches=url.match(domain_regex);if(matches){test_domain=matches[1];return test_domain!=document.domain;}else{return false;}},remove:function(arr,item){var ret=[];for(var i=0,len=arr.length;i0.5?d/(2-max-min):d/(max+min);switch(max){case r:h=(g-b)/d+(g1)t-=1;if(t<1/6)return p+(q-p)*6*t;if(t<1/2)return q;if(t<2/3)return p+(q-p)*(2/3-t)*6;return p;},hsl_to_rgb:function(h,s,l){var r,g,b;if(s===0){r=g=b=l;}else{var q=l<0.5?l*(1+s):l+s-l*s;var p=2*l-q;r=this.hue_to_rgb(p,q,h+1/3);g=this.hue_to_rgb(p,q,h);b=this.hue_to_rgb(p,q,h-1/3);}
return{r:r*255,g:g*255,b:b*255};},rgb_to_hsv:function(r,g,b){r=r/255;g=g/255;b=b/255;var max=Math.max(r,g,b),min=Math.min(r,g,b),h,s,v=max,d=max-min;s=max===0?0:d/max;if(max==min){h=0;}else{switch(max){case r:h=(g-b)/d+(g0.04045){r=Math.pow((r+0.055)/1.055,2.4);}else{r=r/12.92;}
if(g>0.04045){g=Math.pow((g+0.055)/1.055,2.4);}else{g=g/12.92;}
if(b>0.04045){b=Math.pow((b+0.055)/1.055,2.4);}else{b=b/12.92;}
var x=r*0.4124+g*0.3576+b*0.1805;var y=r*0.2126+g*0.7152+b*0.0722;var z=r*0.0193+g*0.1192+b*0.9505;return{x:x*100,y:y*100,z:z*100};},xyz_to_rgb:function(x,y,z){x=x/100;y=y/100;z=z/100;var r,g,b;r=(3.2406*x)+(-1.5372*y)+(-0.4986*z);g=(-0.9689*x)+(1.8758*y)+(0.0415*z);b=(0.0557*x)+(-0.2040*y)+(1.0570*z);if(r>0.0031308){r=(1.055*Math.pow(r,0.4166666667))-0.055;}else{r=12.92*r;}
if(g>0.0031308){g=(1.055*Math.pow(g,0.4166666667))-0.055;}else{g=12.92*g;}
if(b>0.0031308){b=(1.055*Math.pow(b,0.4166666667))-0.055;}else{b=12.92*b;}
return{r:r*255,g:g*255,b:b*255};},xyz_to_lab:function(x,y,z){var whiteX=95.047,whiteY=100.0,whiteZ=108.883;x=x/whiteX;y=y/whiteY;z=z/whiteZ;if(x>0.008856451679){x=Math.pow(x,0.3333333333);}else{x=(7.787037037*x)+0.1379310345;}
if(y>0.008856451679){y=Math.pow(y,0.3333333333);}else{y=(7.787037037*y)+0.1379310345;}
if(z>0.008856451679){z=Math.pow(z,0.3333333333);}else{z=(7.787037037*z)+0.1379310345;}
var l=116*y-16;var a=500*(x-y);var b=200*(y-z);return{l:l,a:a,b:b};},lab_to_xyz:function(l,a,b){var y=(l+16)/116;var x=y+(a/500);var z=y-(b/200);if(x>0.2068965517){x=x*x*x;}else{x=0.1284185493*(x-0.1379310345);}
if(y>0.2068965517){y=y*y*y;}else{y=0.1284185493*(y-0.1379310345);}
if(z>0.2068965517){z=z*z*z;}else{z=0.1284185493*(z-0.1379310345);}
return{x:x*95.047,y:y*100.0,z:z*108.883};},hex_to_rgb:function(hex){var r,g,b;if(hex.charAt(0)==="#"){hex=hex.substr(1);}
r=parseInt(hex.substr(0,2),16);g=parseInt(hex.substr(2,2),16);b=parseInt(hex.substr(4,2),16);return{r:r,g:g,b:b};},bezier:function(start,ctrl1,ctrl2,end,lowBound,highBound){var Ax,Bx,Cx,Ay,By,Cy,x0=start[0],y0=start[1],x1=ctrl1[0],y1=ctrl1[1],x2=ctrl2[0],y2=ctrl2[1],x3=end[0],y3=end[1],t,curveX,curveY,bezier={};Cx=3*(x1-x0);Bx=3*(x2-x1)-Cx;Ax=x3-x0-Cx-Bx;Cy=3*(y1-y0);By=3*(y2-y1)-Cy;Ay=y3-y0-Cy-By;for(var i=0;i<1000;i++){t=i/1000;curveX=Math.round((Ax*Math.pow(t,3))+(Bx*Math.pow(t,2))+(Cx*t)+x0);curveY=Math.round((Ay*Math.pow(t,3))+(By*Math.pow(t,2))+(Cy*t)+y0);if(lowBound&&curveYhighBound){curveY=highBound;}
bezier[curveX]=curveY;}
var leftCoord,rightCoord,j,slope,bint;if(bezier.length255){rgba.r=255;}else if(rgba.r<0){rgba.r=0;}
if(rgba.g>255){rgba.g=255;}else if(rgba.g<0){rgba.g=0;}
if(rgba.b>255){rgba.b=255;}else if(rgba.b<0){rgba.b=0;}
return rgba;});};Caman.manip.hue=function(adjust){var hsv,h;return this.process(adjust,function hue(adjust,rgba){var rgb;hsv=Caman.rgb_to_hsv(rgba.r,rgba.g,rgba.b);h=hsv.h*100;h+=Math.abs(adjust);h=h%100;h/=100;hsv.h=h;rgb=Caman.hsv_to_rgb(hsv.h,hsv.s,hsv.v);return{r:rgb.r,g:rgb.g,b:rgb.b,a:rgba.a};});};Caman.manip.colorize=function(){var diff,rgb,level;if(arguments.length===2){rgb=Caman.hex_to_rgb(arguments[0]);level=arguments[1];}else if(arguments.length===4){rgb={r:arguments[0],g:arguments[1],b:arguments[2]};level=arguments[3];}
return this.process([level,rgb],function colorize(adjust,rgba){rgba.r-=(rgba.r-adjust[1].r)*(adjust[0]/100);rgba.g-=(rgba.g-adjust[1].g)*(adjust[0]/100);rgba.b-=(rgba.b-adjust[1].b)*(adjust[0]/100);return rgba;});};Caman.manip.invert=function(){return this.process({},function invert(adjust,rgba){rgba.r=255-rgba.r;rgba.g=255-rgba.g;rgba.b=255-rgba.b;return rgba;});};Caman.manip.sepia=function(adjust){if(adjust===undefined){adjust=100;}
adjust=(adjust/100);return this.process(adjust,function sepia(adjust,rgba){rgba.r=Math.min(255,(rgba.r*(1-(0.607*adjust)))+(rgba.g*(0.769*adjust))+(rgba.b*(0.189*adjust)));rgba.g=Math.min(255,(rgba.r*(0.349*adjust))+(rgba.g*(1-(0.314*adjust)))+(rgba.b*(0.168*adjust)));rgba.b=Math.min(255,(rgba.r*(0.272*adjust))+(rgba.g*(0.534*adjust))+(rgba.b*(1-(0.869*adjust))));return rgba;});};Caman.manip.gamma=function(adjust){return this.process(adjust,function gamma(adjust,rgba){rgba.r=Math.pow(rgba.r/255,adjust)*255;rgba.g=Math.pow(rgba.g/255,adjust)*255;rgba.b=Math.pow(rgba.b/255,adjust)*255;return rgba;});};Caman.manip.noise=function(adjust){adjust=Math.abs(adjust)*2.55;return this.process(adjust,function noise(adjust,rgba){var rand=Caman.randomRange(adjust*-1,adjust);rgba.r+=rand;rgba.g+=rand;rgba.b+=rand;return rgba;});};Caman.manip.clip=function(adjust){adjust=Math.abs(adjust)*2.55;return this.process(adjust,function clip(adjust,rgba){if(rgba.r>255-adjust){rgba.r=255;}else if(rgba.r255-adjust){rgba.g=255;}else if(rgba.g255-adjust){rgba.b=255;}else if(rgba.b0){rgba.r=rgba.r+((255-rgba.r)*options.red);}else{rgba.r=rgba.r-(rgba.r*Math.abs(options.red));}}
if(options.green){if(options.green>0){rgba.g=rgba.g+((255-rgba.g)*options.green);}else{rgba.g=rgba.g-(rgba.g*Math.abs(options.green));}}
if(options.blue){if(options.blue>0){rgba.b=rgba.b+((255-rgba.b)*options.blue);}else{rgba.b=rgba.b-(rgba.b*Math.abs(options.blue));}}
return rgba;});};Caman.manip.curves=function(chan,start,ctrl1,ctrl2,end){var bezier,i;if(typeof chan==='string'){if(chan=='rgb'){chan=['r','g','b'];}else{chan=[chan];}}
bezier=Caman.bezier(start,ctrl1,ctrl2,end,0,255);if(start[0]>0){for(i=0;i0&°rees<90)||(degrees>180&°rees<270)){kernel=[[0,0,0,0,1],[0,0,0,1,0],[0,0,1,0,0],[0,1,0,0,0],[1,0,0,0,0]];}else if(degrees==90||degrees==270){kernel=[[0,0,0,0,0],[0,0,0,0,0],[1,1,1,1,1],[0,0,0,0,0],[0,0,0,0,0]];}else{kernel=[[1,0,0,0,0],[0,1,0,0,0],[0,0,1,0,0],[0,0,0,1,0],[0,0,0,0,1]];}
return this.processKernel('Motion Blur',kernel,5);};Caman.manip.sharpen=function(amt){if(!amt){amt=1;}else{amt/=100;}
return this.processKernel('Sharpen',[[0,-amt,0],[-amt,4*amt+1,-amt],[0,-amt,0]]);};}(Caman));if(!Caman&&typeof exports=="object"){var Caman={manip:{}};exports.plugins=Caman.manip;}
(function(Caman){Caman.manip.vignette=function(size,strength){var center,start,end,loc,dist,div,bezier;if(!strength){strength=0.6;}else{strength/=100;}
center=[(this.dimensions.width/2),(this.dimensions.height/2)];start=Math.sqrt(Math.pow(center[0],2)+Math.pow(center[1],2));end=start-size;bezier=Caman.bezier([0,1],[30,30],[70,60],[100,80]);return this.process({center:center,start:start,end:end,size:size,strength:strength,bezier:bezier},function vignette(data,rgba){loc=this.locationXY();dist=Math.sqrt(Math.pow(loc.x-data.center[0],2)+Math.pow(loc.y-data.center[1],2));if(dist>data.end){div=Math.max(1,((data.bezier[Math.round(((dist-data.end)/data.size)*100)]/10)*strength));rgba.r=Math.pow(rgba.r/255,div)*255;rgba.g=Math.pow(rgba.g/255,div)*255;rgba.b=Math.pow(rgba.b/255,div)*255;}
return rgba;});};}(Caman));if(!Caman&&typeof exports=="object"){var Caman={manip:{}};exports.plugins=Caman.manip;}
(function(Caman){Caman.manip.edgeEnhance=function(){return this.processKernel('Edge Enhance',[[0,0,0],[-1,1,0],[0,0,0]]);};Caman.manip.edgeDetect=function(){return this.processKernel('Edge Detect',[[-1,-1,-1],[-1,8,-1],[-1,-1,-1]]);};Caman.manip.emboss=function(){return this.processKernel('Emboss',[[-2,-1,0],[-1,1,1],[0,1,2]]);};}(Caman));if(!Caman&&typeof exports=="object"){var Caman={manip:{}};exports.plugins=Caman.manip;}
(function(Caman){Caman.manip.vintage=function(vignette){this.greyscale().contrast(5);if(vignette||typeof vignette==='undefined'){this.vignette(250,25);}
return this.noise(3).sepia(100).channels({red:8,blue:2,green:4}).gamma(0.87);};Caman.manip.lomo=function(){return this.brightness(15).exposure(15).curves('rgb',[0,0],[200,0],[155,255],[255,255]).saturation(-20).gamma(1.8).vignette(300,60).brightness(5);};Caman.manip.clarity=function(grey){var manip=this.vibrance(20).curves('rgb',[5,0],[130,150],[190,220],[250,255]).sharpen(15).vignette(250,20);if(grey){this.greyscale().contrast(4);}
return manip;};Caman.manip.sinCity=function(){return this.contrast(100).brightness(15).exposure(10).curves('rgb',[0,0],[100,0],[155,255],[255,255]).clip(30).greyscale();};Caman.manip.sunrise=function(){return this.exposure(3.5).saturation(-5).vibrance(50).sepia(60).colorize('#e87b22',10).channels({red:8,blue:8}).contrast(5).gamma(1.2).vignette(250,25);};Caman.manip.crossProcess=function(){return this.exposure(5).colorize('#e87b22',4).sepia(20).channels({blue:8,red:3}).curves('b',[0,0],[100,150],[180,180],[255,255]).contrast(15).vibrance(75).gamma(1.6);};Caman.manip.orangePeel=function(){return this.curves('rgb',[0,0],[100,50],[140,200],[255,255]).vibrance(-30).saturation(-30).colorize('#ff9000',30).contrast(-5).gamma(1.4);};Caman.manip.love=function(){return this.brightness(5).exposure(8).colorize('#c42007',30).vibrance(50).gamma(1.3);};Caman.manip.grungy=function(){return this.gamma(1.5).clip(25).saturation(-60).contrast(5).noise(5).vignette(200,30);};Caman.manip.jarques=function(){return this.saturation(-35).curves('b',[20,0],[90,120],[186,144],[255,230]).curves('r',[0,0],[144,90],[138,120],[255,255]).curves('g',[10,0],[115,105],[148,100],[255,248]).curves('rgb',[0,0],[120,100],[128,140],[255,255]).sharpen(20);};Caman.manip.pinhole=function(){return this.greyscale().sepia(10).exposure(10).contrast(15).vignette(250,35);};Caman.manip.oldBoot=function(){return this.saturation(-20).vibrance(-50).gamma(1.1).sepia(30).channels({red:-10,blue:5}).curves('rgb',[0,0],[80,50],[128,230],[255,255]).vignette(250,30);};Caman.manip.glowingSun=function(){this.brightness(10);this.newLayer(function(){this.setBlendingMode('multiply');this.opacity(10);this.copyParent();this.filter.gamma(0.8);this.filter.contrast(50);this.newLayer(function(){this.setBlendingMode('softLight');this.opacity(10);this.fillColor('#f49600');this.render();});this.filter.exposure(10);this.render();});this.exposure(20);this.gamma(0.8);return this.vignette(250,20);};}(Caman));