Оставьте номер телефона
Мы перезвоним в течение 15 минут!
Нажимая на кнопку, вы даете согласие на обработку персональных данных
OUR COMPANY
Bring your ideas to life
Anything you've even dreamed about is possible to realise just at the moment when you decided to win.
$(function () { startLoop(); }); var startLoop = function () { var eng = { canvas : document.getElementById('playground'), c : document.getElementById('playground').getContext('2d'),timestep : 16, line : [{ x : 10, y : 100 },{ x : 200, y : 190 },{ x : 320, y : 120 },{ x : 490, y : 210 },{ x : 620, y : 330 },{ x : 800, y : 190 }], inc : 5, positionTimestep : 10, route : [{ color : '255,255,255', colorOpacity : 0.9, spread : 8, iter : { x : 0, y : 0 }, curSeg : 0, updatePosition : true }, { color : '0,153,255', colorOpacity : 0.9, spread : 3, iter : { x : 0, y : 0 }, curSeg : 0, updatePosition : true }, { color : '0,153,255', colorOpacity : 0.7, spread : 15, iter : { x : 0, y : 0 }, curSeg : 0, updatePosition : true }, { color : '0,153,255', colorOpacity : 0.7, spread : 15, iter : { x : 0, y : 0 }, curSeg : 0, updatePosition : true }, { color : '255,0,255', colorOpacity : 1, spread : 12, iter : { x : 0, y : 0 }, curSeg : 0, updatePosition : true }, { color : '255,0,255', colorOpacity : 0.2, spread : 29, iter : { x : 0, y : 0 }, curSeg : 0, updatePosition : true }, { color : '255,255,255', colorOpacity : 0.4, spread : 14, iter : { x : 0, y : 0 }, curSeg : 0, updatePosition : true }, { color : '255,255,255', colorOpacity : 0.2, spread : 16, iter : { x : 0, y : 0 }, curSeg : 0, updatePosition : true }, { color : '255,255,255', colorOpacity : 0.1, spread : 20, iter : { x : 0, y : 0 }, curSeg : 0, updatePosition : true }, { color : '255,255,255', colorOpacity : 0.1, spread : 20, iter : { x : 0, y : 0 }, curSeg : 0, updatePosition : true }, { color : '255,255,255', colorOpacity : 0.1, spread : 22, iter : { x : 0, y : 0 }, curSeg : 0, updatePosition : true }, { color : '255,255,255', colorOpacity : 0.1, spread : 40, iter : { x : 0, y : 0 }, curSeg : 0, updatePosition : true }] } for (i = 0; i < eng.route.length; i++) { eng.route[i].iter.x = eng.line[0].x; eng.route[i].iter.y = eng.line[0].y; } eng.c.beginPath(); for (i = 0; i < eng.line.length; i++) { if (i === 0) { eng.c.moveTo(eng.line[i].x,eng.line[i].y); } else { eng.c.lineTo(eng.line[i].x,eng.line[i].y); } } eng.c.strokeStyle = 'rgba(0, 0, 0, 0.2)'; $(eng.canvas).bind('mousemove', function (e) { for (i = 0; i < eng.route.length; i++) { draw(e.offsetX, e.offsetY, eng, i); } }); //eng.c.stroke(); loop(eng); } var loop = function (eng) { for (i = 0; i < eng.route.length; i++) { drawOnLine(eng, i); } setTimeout(function () { loop(eng); }, eng.timestep); } var getRandomArbitrary = function (min, max) { return Math.floor(Math.random() * (max - min) + min); } var drawOnLine = function (eng, route) { var thisSeg = eng.line[eng.route[route].curSeg]; var nextSeg = eng.line[eng.route[route].curSeg + 1]; if (typeof nextSeg !== 'undefined') { var m = (nextSeg.y - thisSeg.y) / (nextSeg.x - thisSeg.x); var b = thisSeg.y - (m * thisSeg.x); var x = eng.route[route].iter.x; var y = (m * eng.route[route].iter.x) + b; draw(x, y, eng, route); updatePosition(eng, route); if (eng.route[route].iter.x === nextSeg.x) { eng.route[route].curSeg++; } } } var updatePosition = function (eng, route) { var thisSeg = eng.line[eng.route[route].curSeg]; var nextSeg = eng.line[eng.route[route].curSeg + 1]; if (eng.route[route].updatePosition === true) { if (nextSeg.x > thisSeg.x) { eng.route[route].iter.x = eng.route[route].iter.x + eng.inc; } else { eng.route[route].iter.x = eng.route[route].iter.x - eng.inc; } eng.route[route].updatePosition = false; setTimeout(function () { eng.route[route].updatePosition = true; }, eng.positionTimestep); } } var draw = function (x, y, eng, route) { var randX = Math.pow(Math.random()+1, 2) * eng.route[route].spread; var randY = Math.pow(Math.random()+1, 2) * eng.route[route].spread; if (Math.random() > 0.5) { randX = -randX; } if (Math.random() > 0.5) { randY = -randY; } var radius = 8 * Math.pow(Math.random()+1, 2); /*eng.c.beginPath(); eng.c.arc(x + (randX), y + (randY), radius, 0, 2 * Math.PI, false); eng.c.fillStyle = 'rgba(' + eng.route[route].color + ', ' + Math.random()*eng.route[route].colorOpacity + ')'; eng.c.fill();*/ var colorOpacity = Math.random()*eng.route[route].colorOpacity; var radgrad = eng.c.createRadialGradient(x + (randX) + radius, y + (randY) + radius, 0, x + (randX) + radius, y + (randY) + radius,radius); radgrad.addColorStop(0, 'rgba(' + eng.route[route].color + ',' + colorOpacity + ')'); radgrad.addColorStop(0.2, 'rgba(' + eng.route[route].color + ',' + colorOpacity*0.9 + ')'); radgrad.addColorStop(1, 'rgba(' + eng.route[route].color + ',0)'); // draw shape eng.c.fillStyle = radgrad; eng.c.fillRect(x + (randX), y + (randY), 500,500); }

Html code will be here