webpackJsonp([1],{"/+sM":function(t,e){},NHnr:function(t,e,s){"use strict";Object.defineProperty(e,"__esModule",{value:!0});s("uMhA");var i=s("7+uW"),a=s("woOf"),n=s.n(a),r={render:function(){var t=this,e=t.$createElement,s=t._self._c||e;return s("div",{staticClass:"image-chooser"},[s("div",{staticClass:"button-group stretch"},[s("label",[t._v("Input:")]),t._v(" "),s("button",{staticClass:"btn",class:{active:"upload"===t.selectedItem},attrs:{id:"upload",disabled:t.disabled},on:{click:t.toggle}},[t._v("File")]),t._v(" "),s("button",{staticClass:"btn",class:{active:"webcam"===t.selectedItem},attrs:{id:"webcam",disabled:t.disabled},on:{click:t.toggle}},[t._v("WebCam")])])])},staticRenderFns:[]};var o=s("VU/8")({name:"ImageChooser",data:function(){return{selectedItem:"upload",disabled:!1}},methods:{toggle:function(t){this.selectedItem=t.target.id,this.$emit("selected",this.selectedItem)}}},r,!1,function(t){s("/+sM")},"data-v-4692bf3a",null).exports,c=s("//Fk"),l=s.n(c),d={name:"WebCam",props:{width:{type:[Number,String],default:"100%"},height:{type:[Number,String],default:200},autoplay:{type:Boolean,default:!0},screenshotFormat:{type:String,default:"image/jpeg"},deviceId:{type:String,default:null},playsinline:{type:Boolean,default:!0}},data:function(){return{source:null,canvas:null,camerasListEmitted:!1,cameras:[]}},watch:{deviceId:function(t){this.changeCamera(t)}},mounted:function(){this.setupMedia()},beforeDestroy:function(){this.stop()},methods:{legacyGetUserMediaSupport:function(){return function(t){var e=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia||navigator.oGetUserMedia;return e?new l.a(function(s,i){e.call(navigator,t,s,i)}):l.a.reject(new Error("getUserMedia is not implemented in this browser"))}},setupMedia:function(){void 0===navigator.mediaDevices&&(navigator.mediaDevices={}),void 0===navigator.mediaDevices.getUserMedia&&(navigator.mediaDevices.getUserMedia=this.legacyGetUserMediaSupport()),this.testMediaAccess()},loadCameras:function(){var t=this;navigator.mediaDevices.enumerateDevices().then(function(e){for(var s=0;s!==e.length;++s){var i=e[s];"videoinput"===i.kind&&t.cameras.push(i)}}).then(function(){t.camerasListEmitted||(t.$emit("cameras",t.cameras),t.camerasListEmitted=!0)}).catch(function(e){return t.$emit("notsupported",e)})},changeCamera:function(t){this.stop(),this.$emit("camera-change",t),this.loadCamera(t)},loadSrcStream:function(t){var e=this;"srcObject"in this.$refs.video?this.$refs.video.srcObject=t:this.source=window.HTMLMediaElement.srcObject(t),this.$refs.video.onloadedmetadata=function(){e.$emit("video-live",t)},this.$emit("started",t)},stopStreamedVideo:function(t){var e=this,s=t.srcObject;s.getTracks().forEach(function(t){t.stop(),e.$emit("stopped",s),e.$refs.video.srcObject=null,e.source=null})},stop:function(){null!==this.$refs.video&&this.$refs.video.srcObject&&this.stopStreamedVideo(this.$refs.video)},start:function(){this.deviceId&&this.loadCamera(this.deviceId)},testMediaAccess:function(){var t=this;navigator.mediaDevices.getUserMedia({video:{width:this.$props.width,aspectRatio:{exact:this.$props.width/this.$props.height}},audio:!1}).then(function(e){return t.loadCameras()}).catch(function(e){return t.$emit("error",e)})},loadCamera:function(t){var e=this;navigator.mediaDevices.getUserMedia({video:{deviceId:{exact:t},width:this.width,aspectRatio:{exact:this.width/this.height}},audio:!1}).then(function(t){return e.loadSrcStream(t)}).catch(function(t){return e.$emit("error",t)})},capture:function(){return this.getCanvas().toDataURL(this.screenshotFormat)},getCanvasRaw:function(){return this.ctx.getImageData(0,0,this.canvas.width,this.canvas.height)},getCanvas:function(){var t=this.$refs.video;if(!this.ctx){var e=document.createElement("canvas");e.height=t.height,e.width=t.width,this.canvas=e,this.ctx=e.getContext("2d"),this.ctx.translate(e.width,0),this.ctx.scale(-1,1)}var s=this.ctx,i=this.canvas;return s.clearRect(0,0,this.width,this.height),s.drawImage(t,0,0,this.width,this.height),i}}},u={render:function(){var t=this.$createElement;return(this._self._c||t)("video",{ref:"video",attrs:{width:this.width,height:this.height,src:this.source,autoplay:this.autoplay,playsinline:this.playsinline}})},staticRenderFns:[]};var v=s("VU/8")(d,u,!1,function(t){s("mxzp")},"data-v-43507d33",null).exports,h={name:"svgChartLine",props:["d","stroke"],computed:{pathD:function(){var t="";return this.d.values.forEach(function(e,s){t+=0===s?"M "+e[0]+","+e[1]:"L"+Math.round(100*e[0])/100+","+Math.round(100*e[1])/100}),t}}},g={render:function(){var t=this.$createElement;return(this._self._c||t)("path",{style:{strokeWidth:this.stroke.width,fill:this.stroke.fill,stroke:this.stroke.color},attrs:{d:this.pathD}})},staticRenderFns:[]},m={name:"svgChart",components:{svgChartLine:s("VU/8")(h,g,!1,null,null,null).exports},props:["lines","black","width","height"],computed:{viewbox:function(){return"0 0 "+this.width+" "+this.height},background:function(){return this.black?"#000000":"#FFFFFF"},stroke:function(){return{color:this.black?"#FFFFFF":"#000000",fill:"none",width:"2px"}}}},p={render:function(){var t=this,e=t.$createElement,s=t._self._c||e;return s("svg",{style:{background:t.background},attrs:{xmlns:"http://www.w3.org/2000/svg",viewBox:t.viewbox,width:t.width,height:t.height}},[s("g",t._l(t.lines,function(e,i){return s("svg-chart-line",{key:i,attrs:{d:e,stroke:t.stroke}})}),1)])},staticRenderFns:[]};var f={name:"App",components:{imageChooser:o,webcam:v,svgChart:s("VU/8")(m,p,!1,function(t){s("Q3wT")},null,null).exports},data:function(){return{cropper:{},dataUrl:"",lines:[],inputType:"upload",settings:{black:!1,frequency:150,amplitude:1,lineCount:50,brightness:0,contrast:0,minBrightness:0,maxBrightness:255,spacing:1,width:500,height:500},canvasData:null,webcam:{img:null,camera:null,deviceId:null,device:null,devices:[],streaming:!1}}},watch:{"webcam.camera":function(t){this.webcam.deviceId=t},"webcam.devices":function(){var t=this.webcam.devices[0];t&&(this.webcam.camera=t.deviceId,this.webcam.deviceId=t.deviceId)},"settings.frequency":function(){this.processImage()},"settings.spacing":function(){this.processImage()},"settings.lineCount":function(){this.processImage()},"settings.amplitude":function(){this.processImage()},"settings.minBrightness":function(){this.processImage()},"settings.maxBrightness":function(){this.processImage()},"settings.brightness":function(){this.processImage()},"settings.contrast":function(){this.processImage()},"settings.black":function(){this.processImage()},canvasData:function(){this.processImage()}},computed:{widthInCM:function(){return Math.round(10*this.settings.width/38)/10},heightInCM:function(){return Math.round(10*this.settings.height/38)/10}},methods:{downloadSVG:function(){var t=(new XMLSerializer).serializeToString(this.$refs.svgResult.$el),e=new Blob([''+t],{type:"image/svg+xml;charset=utf-8"}),s=URL.createObjectURL(e),i=document.createElement("a");i.href=s,i.download="squiggleCam_"+Date.now()+".svg",document.body.appendChild(i),i.click(),document.body.removeChild(i)},uploadCroppedImage:function(){var t=this;this.cropper.generateBlob(function(e){var s=document.createElement("canvas");s.width=t.settings.width,s.height=t.settings.height;var i=s.getContext("2d"),a=new Image;a.onload=function(){i.drawImage(a,0,0),t.canvasData=i.getImageData(0,0,t.settings.width,t.settings.height)},a.src=URL.createObjectURL(e)},"image/jpeg",1)},processImage:function(){var t=this;this.$worker.run(function(t){for(var e=t.config,s=t.image,i=parseInt(e.width),a=parseInt(e.height),n=parseInt(e.contrast),r=parseInt(e.brightness),o=parseInt(e.lineCount),c=parseInt(e.minBrightness),l=parseInt(e.maxBrightness),d=parseFloat(e.spacing),u=e.black,v=[],h=5,g=0,m=void 0,p=void 0,f=[],_=0,b=0,w=259*(n+255)/(255*(259-n)),C=Math.floor(a/o),y=0;y"})},Q3wT:function(t,e){},mxzp:function(t,e){},"n0/Z":function(t,e){},toYN:function(t,e){},uMhA:function(t,e){}},["NHnr"]); //# sourceMappingURL=app.2cf2ad8ffdb718b4ceba.js.map