Your IP : 216.73.217.62


Current Path : /home/kamilrogam/komp/2018/180513/git/canvasTriangles/docs/js/
Upload File :
Current File : /home/kamilrogam/komp/2018/180513/git/canvasTriangles/docs/js/app.min.js

"use strict";var _createClass=function(){function t(t,i){for(var h=0;h<i.length;h++){var s=i[h];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}return function(i,h,s){return h&&t(i.prototype,h),s&&t(i,s),i}}();function _classCallCheck(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}document.addEventListener("DOMContentLoaded",function(){var t="#000",i=function(){function t(i,h,s,e,n,a,r){_classCallCheck(this,t),this.x1=i,this.x2=s,this.x3=n,this.y1=h,this.y2=e,this.y3=a,this.color=r,this.x1V=this.x2V=this.x3V=this.y1V=this.y2V=this.y3V=1}return _createClass(t,[{key:"drawTriangle",value:function(){e.fillStyle=this.color,e.beginPath(),e.moveTo(this.x1,this.y1),e.lineTo(this.x2,this.y2),e.lineTo(this.x3,this.y3),e.closePath(),e.fill()}},{key:"animateTriangle",value:function(){e.fillStyle=this.color,this.x1!=n&&0!=this.x1||(this.x1V=-this.x1V),this.x2!=n&&0!=this.x2||(this.x2V=-this.x2V),this.x3!=n&&0!=this.x3||(this.x3V=-this.x3V),this.y1!=a&&0!=this.y1||(this.y1V=-this.y1V),this.y2!=a&&0!=this.y2||(this.y2V=-this.y2V),this.y3!=a&&0!=this.y3||(this.y3V=-this.y3V),this.x1-=this.x1V,this.x2-=this.x2V,this.x3-=this.x3V,this.y1-=this.y1V,this.y2-=this.y2V,this.y3-=this.y3V,this.drawTriangle()}}]),t}();function h(t){return Math.floor(Math.random()*t)+1}for(var s=document.querySelector("canvas"),e=s.getContext("2d"),n=s.width,a=s.height,r=[],o=0;o<10;o++){var l="rgba(205,205,0,.5)";l="rgba("+(Math.floor(255*Math.random())+1)+", "+(Math.floor(255*Math.random())+1)+", "+(Math.floor(255*Math.random())+1)+", "+Math.random().toPrecision(2)+")";var y=new i(h(n),h(a),h(n),h(a),h(n),h(a),l);r.push(y)}!function i(){requestAnimationFrame(i),e.fillStyle=t,e.fillRect(0,0,n,a),r.forEach(function(t){t.animateTriangle()})}()});