LiteRoomJS is a lightweight canvas photo editor for web-based editing of photographs.
Users can upload an image, edit it, and then export an edited version.
HTML5 canvas to handle image state, filters, and display
ctx.filterhandles filtering logicctx.rotateandctx.translateto re-arrange canvas when rotating
Vanilla JS classes
main.js- initializes program with image (default or uploaded)canvas.js- holds state of canvas, stores filter values, draws imagefilter.js- callback functions to update image with new filter
Modify image with filters (grayscale, saturation, contrast, etc.)

applySlider(filter){constself=this;constfilterSlider=document.getElementById(filter);filterSlider.onchange=function(e){self.canvas.drawCanvas(`${filter}(${e.target.value}%)`);};}grayscaleSlider(){this.applySlider('grayscale');}sepiaSlider(){this.applySlider('sepia');}rotate(){constrotateButton=document.getElementById("rotate-image");letnewImage;rotateButton.onclick=()=>{newImage=newImage();newImage.src=this.canvas.toDataURL();newImage.onload=()=>{constoldWidth=this.canvas.width;this.canvas.width=this.canvas.height;this.canvas.height=oldWidth;this.ctx.translate(this.canvas.width,this.canvas.height/this.canvas.width);this.ctx.rotate(Math.PI/2);this.ctx.drawImage(newImage,0,0);};};}Stored as hashmap -- updated with each draw method
updateFilters(filter){constfilterName=filter.match(/\w+/)[0];constfilterValue=filter.match(/\d+/)[0];this.filters[filterName]=filterValue;letfilterString="";for(varkeyinthis.filters){filterString+=` ${key}(${this.filters[key]}%)`;}this.ctx.filter=filterString;}


