diff --git a/index.html b/index.html index 948b006..cb69bdd 100644 --- a/index.html +++ b/index.html @@ -67,13 +67,13 @@ GreyScale
diff --git a/js/app.js b/js/app.js index d53bf8f..a5bdccc 100644 --- a/js/app.js +++ b/js/app.js @@ -25,6 +25,74 @@ function doGreyScale(){ ctx.putImageData(imageData, 0, 0); } +//Simple algorithm to convert image to Sepia +function doSepia(){ + var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); + var data = imageData.data; + for(let i = 0; i < data.length; i += 4){ + data[i]*=1.07; + data[i + 1]*=0.74; + data[i + 2]*=0.43; + } + ctx.putImageData(imageData, 0, 0); +} + +//Simple algorithm to convert image to Lark +function doLark(){ + var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); + var data = imageData.data; + brightness(data,0.08); + rgbAdjust(data,[1,1.03,1.05]); + saturation(data,0.12); + ctx.putImageData(imageData, 0, 0); +} + +//Simple algorithm to convert image to Amaro +function doAmaro(){ + var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); + var data = imageData.data; + brightness(data,0.15); + saturation(data,0.3); + ctx.putImageData(imageData, 0, 0); +} + +//val should be from -1 to 1 and 0 for unchanged +function brightness(data,val){ + if(val<=-1){ + val=-1; + } + if(val>=1){ + val=1; + } + val=~~(255*val); + for(let i=0;i