-
Notifications
You must be signed in to change notification settings - Fork 0
/
bundle.js
1 lines (1 loc) · 2.31 KB
/
bundle.js
1
(()=>{function t(t){return function(t){if(Array.isArray(t))return n(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return n(t,e);var o=Object.prototype.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?n(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,o=new Array(n);e<n;e++)o[e]=t[e];return o}function e(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}window.onload=function(){var n,o=new URLSearchParams(window.location.search).get("environment"),a=window.location.origin+window.location.pathname;n="example"===o?"".concat(a,"assets/example.png"):"twoGoals"===o?"".concat(a,"assets/two_goals.png"):"manyGoals"===o?"".concat(a,"assets/many_goals.png"):"https://picsum.photos/500/500",document.getElementById("environment").src=n;var r=document.getElementById("paint-canvas"),i=r.getContext("2d"),c=r.getBoundingClientRect();function s(t){return[t.clientX-c.left,t.clientY-c.top]}function l(){i.clearRect(0,0,r.width,r.height)}var u,p=function(){function t(){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t),this.x=[],this.y=[],this.time=[]}var n,o;return n=t,(o=[{key:"add",value:function(t,n){this.x.push(t),this.y.push(n),this.time.push(Date.now())}}])&&e(n.prototype,o),t}(),d=!1;i.strokeStyle="black",i.lineWidth=5,r.addEventListener("mousedown",(function(n){var e;if(!d){d=!0,l(),i.beginPath(),u=new p;var o=s(n);(e=u).add.apply(e,t(o)),i.moveTo.apply(i,t(o))}})),r.addEventListener("mousemove",(function(n){if(d){var e,o=s(n);(e=u).add.apply(e,t(o)),i.lineTo.apply(i,t(o)),i.stroke()}})),r.addEventListener("mouseup",(function(n){var e,o=s(n);(e=u).add.apply(e,t(o)),i.moveTo.apply(i,t(o)),d=!1,window.parent.postMessage(u,"*")})),document.getElementById("clear").addEventListener("click",(function(){l(),u=new p,window.parent.postMessage(u,"*")}))}})();