{"id":316787,"date":"2021-01-22T15:00:48","date_gmt":"2021-01-22T15:00:48","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=316787"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=316787","title":{"rendered":"\u041a\u043e\u043d\u0444\u0435\u0442\u0442\u0438 \u043d\u0430 \u043a\u0430\u043d\u0432\u0430\u0441\u0435"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442 \u0425\u0430\u0431\u0440! \u041f\u043e\u043f\u0430\u043b\u0430\u0441\u044c \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u0432\u0435\u0449\u0438\u0447\u043a\u0430 , \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u044d\u0444\u0444\u0435\u043a\u0442 \u043a\u043e\u043d\u0444\u0435\u0442\u0442\u0438 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0435. \u0420\u0435\u0448\u0438\u043b \u0433\u043b\u044f\u043d\u0443\u0442\u044c , \u0447\u0442\u043e \u0436\u0435 \u0442\u0430\u043c \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u043a\u0430\u043d\u0432\u0430\u0441\u043e\u043c \u043f\u043e\u0431\u043b\u0438\u0436\u0435. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c. <\/p>\n<h2>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041f\u043e\u0432\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u0435\u0441\u0442\u0438\u0441\u044c \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437 \u0432 \u0436\u0438\u0437\u043d\u0438 \u0443\u0432\u0438\u0434\u0435\u043b \u043a\u0430\u043d\u0432\u0430\u0441 ( \u043b\u0430\u0434\u043d\u043e, \u0432\u0442\u043e\u0440\u043e\u0439, \u043f\u0435\u0440\u0432\u043e\u0439 \u0431\u044b\u043b\u0430 <a href=\"https:\/\/habr.com\/ru\/company\/microsoft\/blog\/110237\/\" rel=\"noopener noreferrer nofollow\"><em>\u0432\u043e\u0442 \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0441 \u0445\u0430\u0431\u0440\u0430 \u043f\u0440\u043e \u0444\u0440\u0430\u043a\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u043d\u0435\u0436\u0438\u043d\u043a\u0438<\/em><\/a>) \u0438 \u0445\u043e\u0447\u0435\u0442 \u043f\u043e\u0447\u0435\u0440\u043f\u043d\u0443\u0442\u044c \u0441\u0435\u0431\u0435 \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 , \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0437\u0430\u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c. \u041e\u0442\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0441\u044f \u043e\u0442 <a href=\"https:\/\/github.com\/catdad\/canvas-confetti\" rel=\"noopener noreferrer nofollow\">\u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430<\/a> \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043a\u0438  <a href=\"https:\/\/www.skypack.dev\/\" rel=\"noopener noreferrer nofollow\">canvas-confetti<\/a>. <\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438<\/h2>\n<p>\u0423\u0434\u043e\u0431\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u043d\u0435\u043a\u0443\u044e \u043f\u0443\u0448\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043d\u0435\u043a\u043e\u0439 \u0442\u043e\u0447\u043a\u0435 <strong><em>origin<\/em><\/strong>, \u043d\u0430\u043a\u043b\u043e\u043d\u0435\u043d\u0430 \u043f\u043e\u0434 \u0443\u0433\u043b\u043e\u043c <strong><em>angle<\/em><\/strong> \u0438 \u0441\u0442\u0440\u0435\u043b\u044f\u0435\u0442 \u0437\u0430\u0440\u044f\u0434\u043e\u043c \u0432 \u0432\u0438\u0434\u0435 \u043a\u043e\u043d\u0443\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043a\u043b\u043e\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u0442 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u0441\u0442\u0440\u0435\u043b\u0430 \u0432\u043b\u0435\u0432\u043e \u0438 \u0432\u043f\u0440\u0430\u0432\u043e \u043d\u0430 \u0443\u0433\u043e\u043b <strong><em>spread<\/em><\/strong> \u0441\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e <strong><em>startVelocity<\/em><\/strong>  . \u041f\u043e\u0442\u043e\u043c \u0447\u0430\u0441\u0442\u0438\u0446\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0442\u0435\u0440\u044f\u0442\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u043e\u043f\u0440\u043e\u0442\u0438\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u043e\u0437\u0434\u0443\u0445\u0430 <strong><em>decay <\/em><\/strong>\u0438 \u043f\u0430\u0434\u0430\u0442\u044c \u043f\u043e\u0434 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435\u043c \u0441\u0438\u043b\u044b \u0442\u044f\u0436\u0435\u0441\u0442\u0438 <strong><em>gravity<\/em><\/strong>. \u0415\u0449\u0435 \u0435\u0441\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f \u043a\u043e\u043b\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0447\u0430\u0441\u0442\u0438\u0446, \u0446\u0432\u0435\u0442\u0430, \u0444\u043e\u0440\u043c\u044b, \u0440\u0430\u0437\u043c\u0435\u0440\u0430 ( particleCount, colors, shapes,  scalar).  \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0435 \u043e\u043f\u0446\u0438\u0438, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u0434\u0442\u044f\u043d\u0443\u0442\u0441\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<pre><code class=\"javascript\">confetti({   particleCount: 100,   startVelocity: 30,   spread: 360,   origin: {     x: Math.random(),     y: Math.random() - 0.2   } }<\/code><\/pre>\n<h2>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0432\u043d\u0443\u0442\u0440\u0438<\/h2>\n<p>\u0428\u0442\u0443\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 60 \u043a\u0430\u0434\u0440\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong><em>requestAnimationFrame<\/em><\/strong> , \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0438\u043b\u0438 \u043e\u0442\u043a\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a <strong><em>setTimeout<\/em><\/strong>   <\/p>\n<pre><code class=\"javascript\">var raf = (function () {   var TIME = Math.floor(1000 \/ 60);   var frame, cancel;   var frames = {};   var lastFrameTime = 0;    if (typeof requestAnimationFrame === 'function' &amp;&amp; typeof cancelAnimationFrame === 'function') {     frame = function (cb) {       var id = Math.random();        frames[id] = requestAnimationFrame(function onFrame(time) {         if (lastFrameTime === time || lastFrameTime + TIME - 1 &lt; time) {           lastFrameTime = time;           delete frames[id];            cb();         } else {           frames[id] = requestAnimationFrame(onFrame);         }       });        return id;     };     cancel = function (id) {       if (frames[id]) {         cancelAnimationFrame(frames[id]);       }     };   } else {     frame = function (cb) {       return setTimeout(cb, TIME);     };     cancel = function (timer) {       return clearTimeout(timer);     };   }    return { frame: frame, cancel: cancel }; }());<\/code><\/pre>\n<p>\u0417\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u0430\u043d\u0432\u0430\u0441\u043e\u043c \u0432\u0441\u0435\u0439 \u0432\u0438\u0434\u0438\u043c\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong><em>createElement<\/em><\/strong>, <strong><em>appendChild<\/em><\/strong>, <strong><em>clientWidth<\/em><\/strong>, <strong><em>clientHeight<\/em><\/strong><\/p>\n<pre><code class=\"javascript\">function getCanvas(zIndex) {     var canvas = document.createElement('canvas');      canvas.style.position = 'fixed';     canvas.style.top = '0px';     canvas.style.left = '0px';     canvas.style.pointerEvents = 'none';     canvas.style.zIndex = zIndex;      return canvas;   } \/\/ .....  document.body.appendChild(canvas); \/\/ ..... function setCanvasWindowSize(canvas) {   canvas.width = document.documentElement.clientWidth;   canvas.height = document.documentElement.clientHeight; } <\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u043a\u0430\u043d\u0432\u0430\u0441\u0430 \u0441 <strong><em>getContext<\/em><\/strong> <\/p>\n<pre><code class=\"javascript\">var context = canvas.getContext('2d');<\/code><\/pre>\n<p>\u0427\u0438\u0441\u0442\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0435\u0440\u0435\u0434 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u043e\u0439 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u0430\u0434\u0440\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong><em>clearRect<\/em><\/strong> \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <em>update<\/em><\/p>\n<pre><code class=\"javascript\">context.clearRect(0, 0, size.width, size.height);<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u0430\u0434\u0440\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f update, \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 &#171;\u043a\u043e\u043d\u0444\u0435\u0442\u0438\u0442\u043e\u0447\u043a\u0438&#187; \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u0435\u0435 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0438 \u0440\u0438\u0441\u0443\u0435\u0442 \u0435\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 <strong><em>beginPath<\/em><\/strong>, <strong><em>moveTo<\/em><\/strong>, <strong><em>lineTo<\/em><\/strong>,  <strong><em>closePath<\/em><\/strong> \u0438 <strong><em>fill<\/em><\/strong>. \u0422\u0430\u043a\u0436\u0435 \u043a\u0430\u0436\u0434\u0430\u044f \u0444\u0435\u0442\u0438\u0448\u043a\u0430 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u0442 \u0441\u043a\u043e\u043b\u044c\u043a\u043e  \u0443 \u043d\u0435\u0435 \u043f\u0440\u043e\u0448\u043b\u043e \u043a\u0430\u0434\u0440\u043e\u0432-\u0430\u043f\u0434\u0435\u0439\u0442\u043e\u0432 \u0438 \u043f\u043e\u0442\u043e\u043c, \u043a\u043e\u0433\u0434\u0430 \u0443 \u0432\u0441\u0435\u0445 \u0444\u0435\u0442\u0438\u0448\u0435\u043a \u0437\u0430\u043a\u043e\u043d\u0447\u0430\u0442\u0441\u044f \u043a\u0430\u0434\u0440\u044b, \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u043e\u0442\u0440\u0430\u043f\u043e\u0440\u0442\u0443\u0435\u0442 \u043e \u0441\u0432\u043e\u0435\u043c \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438.<\/p>\n<pre><code class=\"javascript\">function updateFetti(context, fetti) { \t\t\/\/ ...     \/\/ \u043f\u0430\u0440\u0430 \u0434\u0435\u0441\u044f\u0442\u043a\u043e\u0432 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0441\u0438\u043d\u0443\u0441\u043e\u0432 \u0438 \u0441\u0438\u043d\u0443\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u044e\u0442 \u043d\u043e\u0432\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0434\u043b\u044f \u043a\u043e\u043d\u0444\u0435\u0442\u0438\u0448\u043a\u0438     \/\/ ...      context.fillStyle = 'rgba(' + fetti.color.r + ', ' + fetti.color.g + ', ' + fetti.color.b + ', ' + (1 - progress) + ')';     context.beginPath();      \/\/ ...     context.moveTo(Math.floor(fetti.x), Math.floor(fetti.y));     context.lineTo(Math.floor(fetti.wobbleX), Math.floor(y1));     context.lineTo(Math.floor(x2), Math.floor(y2));     context.lineTo(Math.floor(x1), Math.floor(fetti.wobbleY));      context.closePath();     context.fill(); \t\t     \/\/ ... \t\t\/\/ \u043a\u043e\u0433\u0434\u0430 \u043a\u0430\u0434\u0440\u044b \u0437\u0430\u043a\u043e\u043d\u0447\u0430\u0442\u0441\u044f \u0444\u0435\u0442\u0438\u0448\u043a\u0430 \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0447\u0430\u0441\u0442\u0438\u0446 \u0434\u043b\u044f \u0430\u043f\u0434\u0435\u0439\u0442\u0430     return fetti.tick &lt; fetti.totalTicks;   }<\/code><\/pre>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c \u044d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043a\u043e\u043c\u0443-\u043d\u0438\u0431\u0443\u0434\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0441\u044f \u0441 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u0430 \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u043e\u043c \u043a\u0430\u043d\u0432\u0430\u0441\u0435. \u0412 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0435 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0433\u043e \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0438\u0437 \u0432\u043e\u0440\u043a\u0435\u0440\u0430 \u0438 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0438. \u0416\u0435\u043b\u0430\u044e\u0449\u0438\u0435 \u043c\u043e\u0433\u0443\u0442 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/537760\/\"> https:\/\/habr.com\/ru\/post\/537760\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442 \u0425\u0430\u0431\u0440! \u041f\u043e\u043f\u0430\u043b\u0430\u0441\u044c \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u0432\u0435\u0449\u0438\u0447\u043a\u0430 , \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u044d\u0444\u0444\u0435\u043a\u0442 \u043a\u043e\u043d\u0444\u0435\u0442\u0442\u0438 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0435. \u0420\u0435\u0448\u0438\u043b \u0433\u043b\u044f\u043d\u0443\u0442\u044c , \u0447\u0442\u043e \u0436\u0435 \u0442\u0430\u043c \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u043a\u0430\u043d\u0432\u0430\u0441\u043e\u043c \u043f\u043e\u0431\u043b\u0438\u0436\u0435. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c. <\/p>\n<h2>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041f\u043e\u0432\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u0435\u0441\u0442\u0438\u0441\u044c \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437 \u0432 \u0436\u0438\u0437\u043d\u0438 \u0443\u0432\u0438\u0434\u0435\u043b \u043a\u0430\u043d\u0432\u0430\u0441 ( \u043b\u0430\u0434\u043d\u043e, \u0432\u0442\u043e\u0440\u043e\u0439, \u043f\u0435\u0440\u0432\u043e\u0439 \u0431\u044b\u043b\u0430 <a href=\"https:\/\/habr.com\/ru\/company\/microsoft\/blog\/110237\/\" rel=\"noopener noreferrer nofollow\"><em>\u0432\u043e\u0442 \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0441 \u0445\u0430\u0431\u0440\u0430 \u043f\u0440\u043e \u0444\u0440\u0430\u043a\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u043d\u0435\u0436\u0438\u043d\u043a\u0438<\/em><\/a>) \u0438 \u0445\u043e\u0447\u0435\u0442 \u043f\u043e\u0447\u0435\u0440\u043f\u043d\u0443\u0442\u044c \u0441\u0435\u0431\u0435 \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 , \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0437\u0430\u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c. \u041e\u0442\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0441\u044f \u043e\u0442 <a href=\"https:\/\/github.com\/catdad\/canvas-confetti\" rel=\"noopener noreferrer nofollow\">\u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430<\/a> \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043a\u0438  <a href=\"https:\/\/www.skypack.dev\/\" rel=\"noopener noreferrer nofollow\">canvas-confetti<\/a>. <\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438<\/h2>\n<p>\u0423\u0434\u043e\u0431\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u043d\u0435\u043a\u0443\u044e \u043f\u0443\u0448\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043d\u0435\u043a\u043e\u0439 \u0442\u043e\u0447\u043a\u0435 <strong><em>origin<\/em><\/strong>, \u043d\u0430\u043a\u043b\u043e\u043d\u0435\u043d\u0430 \u043f\u043e\u0434 \u0443\u0433\u043b\u043e\u043c <strong><em>angle<\/em><\/strong> \u0438 \u0441\u0442\u0440\u0435\u043b\u044f\u0435\u0442 \u0437\u0430\u0440\u044f\u0434\u043e\u043c \u0432 \u0432\u0438\u0434\u0435 \u043a\u043e\u043d\u0443\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043a\u043b\u043e\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u0442 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u0441\u0442\u0440\u0435\u043b\u0430 \u0432\u043b\u0435\u0432\u043e \u0438 \u0432\u043f\u0440\u0430\u0432\u043e \u043d\u0430 \u0443\u0433\u043e\u043b <strong><em>spread<\/em><\/strong> \u0441\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e <strong><em>startVelocity<\/em><\/strong>  . \u041f\u043e\u0442\u043e\u043c \u0447\u0430\u0441\u0442\u0438\u0446\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0442\u0435\u0440\u044f\u0442\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u043e\u043f\u0440\u043e\u0442\u0438\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u043e\u0437\u0434\u0443\u0445\u0430 <strong><em>decay <\/em><\/strong>\u0438 \u043f\u0430\u0434\u0430\u0442\u044c \u043f\u043e\u0434 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435\u043c \u0441\u0438\u043b\u044b \u0442\u044f\u0436\u0435\u0441\u0442\u0438 <strong><em>gravity<\/em><\/strong>. \u0415\u0449\u0435 \u0435\u0441\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f \u043a\u043e\u043b\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0447\u0430\u0441\u0442\u0438\u0446, \u0446\u0432\u0435\u0442\u0430, \u0444\u043e\u0440\u043c\u044b, \u0440\u0430\u0437\u043c\u0435\u0440\u0430 ( particleCount, colors, shapes,  scalar).  \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0435 \u043e\u043f\u0446\u0438\u0438, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u0434\u0442\u044f\u043d\u0443\u0442\u0441\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<pre><code class=\"javascript\">confetti({   particleCount: 100,   startVelocity: 30,   spread: 360,   origin: {     x: Math.random(),     y: Math.random() - 0.2   } }<\/code><\/pre>\n<h2>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0432\u043d\u0443\u0442\u0440\u0438<\/h2>\n<p>\u0428\u0442\u0443\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 60 \u043a\u0430\u0434\u0440\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong><em>requestAnimationFrame<\/em><\/strong> , \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0438\u043b\u0438 \u043e\u0442\u043a\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a <strong><em>setTimeout<\/em><\/strong>   <\/p>\n<pre><code class=\"javascript\">var raf = (function () {   var TIME = Math.floor(1000 \/ 60);   var frame, cancel;   var frames = {};   var lastFrameTime = 0;    if (typeof requestAnimationFrame === 'function' &amp;&amp; typeof cancelAnimationFrame === 'function') {     frame = function (cb) {       var id = Math.random();        frames[id] = requestAnimationFrame(function onFrame(time) {         if (lastFrameTime === time || lastFrameTime + TIME - 1 &lt; time) {           lastFrameTime = time;           delete frames[id];            cb();         } else {           frames[id] = requestAnimationFrame(onFrame);         }       });        return id;     };     cancel = function (id) {       if (frames[id]) {         cancelAnimationFrame(frames[id]);       }     };   } else {     frame = function (cb) {       return setTimeout(cb, TIME);     };     cancel = function (timer) {       return clearTimeout(timer);     };   }    return { frame: frame, cancel: cancel }; }());<\/code><\/pre>\n<p>\u0417\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u0430\u043d\u0432\u0430\u0441\u043e\u043c \u0432\u0441\u0435\u0439 \u0432\u0438\u0434\u0438\u043c\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong><em>createElement<\/em><\/strong>, <strong><em>appendChild<\/em><\/strong>, <strong><em>clientWidth<\/em><\/strong>, <strong><em>clientHeight<\/em><\/strong><\/p>\n<pre><code class=\"javascript\">function getCanvas(zIndex) {     var canvas = document.createElement('canvas');      canvas.style.position = 'fixed';     canvas.style.top = '0px';     canvas.style.left = '0px';     canvas.style.pointerEvents = 'none';     canvas.style.zIndex = zIndex;      return canvas;   } \/\/ .....  document.body.appendChild(canvas); \/\/ ..... function setCanvasWindowSize(canvas) {   canvas.width = document.documentElement.clientWidth;   canvas.height = document.documentElement.clientHeight; } <\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u043a\u0430\u043d\u0432\u0430\u0441\u0430 \u0441 <strong><em>getContext<\/em><\/strong> <\/p>\n<pre><code class=\"javascript\">var context = canvas.getContext('2d');<\/code><\/pre>\n<p>\u0427\u0438\u0441\u0442\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0435\u0440\u0435\u0434 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u043e\u0439 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u0430\u0434\u0440\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong><em>clearRect<\/em><\/strong> \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <em>update<\/em><\/p>\n<pre><code class=\"javascript\">context.clearRect(0, 0, size.width, size.height);<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u0430\u0434\u0440\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f update, \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 &#171;\u043a\u043e\u043d\u0444\u0435\u0442\u0438\u0442\u043e\u0447\u043a\u0438&#187; \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u0435\u0435 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0438 \u0440\u0438\u0441\u0443\u0435\u0442 \u0435\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 <strong><em>beginPath<\/em><\/strong>, <strong><em>moveTo<\/em><\/strong>, <strong><em>lineTo<\/em><\/strong>,  <strong><em>closePath<\/em><\/strong> \u0438 <strong><em>fill<\/em><\/strong>. \u0422\u0430\u043a\u0436\u0435 \u043a\u0430\u0436\u0434\u0430\u044f \u0444\u0435\u0442\u0438\u0448\u043a\u0430 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u0442 \u0441\u043a\u043e\u043b\u044c\u043a\u043e  \u0443 \u043d\u0435\u0435 \u043f\u0440\u043e\u0448\u043b\u043e \u043a\u0430\u0434\u0440\u043e\u0432-\u0430\u043f\u0434\u0435\u0439\u0442\u043e\u0432 \u0438 \u043f\u043e\u0442\u043e\u043c, \u043a\u043e\u0433\u0434\u0430 \u0443 \u0432\u0441\u0435\u0445 \u0444\u0435\u0442\u0438\u0448\u0435\u043a \u0437\u0430\u043a\u043e\u043d\u0447\u0430\u0442\u0441\u044f \u043a\u0430\u0434\u0440\u044b, \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u043e\u0442\u0440\u0430\u043f\u043e\u0440\u0442\u0443\u0435\u0442 \u043e \u0441\u0432\u043e\u0435\u043c \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438.<\/p>\n<pre><code class=\"javascript\">function updateFetti(context, fetti) { \t\t\/\/ ...     \/\/ \u043f\u0430\u0440\u0430 \u0434\u0435\u0441\u044f\u0442\u043a\u043e\u0432 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0441\u0438\u043d\u0443\u0441\u043e\u0432 \u0438 \u0441\u0438\u043d\u0443\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u044e\u0442 \u043d\u043e\u0432\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0434\u043b\u044f \u043a\u043e\u043d\u0444\u0435\u0442\u0438\u0448\u043a\u0438     \/\/ ...      context.fillStyle = 'rgba(' + fetti.color.r + ', ' + fetti.color.g + ', ' + fetti.color.b + ', ' + (1 - progress) + ')';     context.beginPath();      \/\/ ...     context.moveTo(Math.floor(fetti.x), Math.floor(fetti.y));     context.lineTo(Math.floor(fetti.wobbleX), Math.floor(y1));     context.lineTo(Math.floor(x2), Math.floor(y2));     context.lineTo(Math.floor(x1), Math.floor(fetti.wobbleY));      context.closePath();     context.fill(); \t\t     \/\/ ... \t\t\/\/ \u043a\u043e\u0433\u0434\u0430 \u043a\u0430\u0434\u0440\u044b \u0437\u0430\u043a\u043e\u043d\u0447\u0430\u0442\u0441\u044f \u0444\u0435\u0442\u0438\u0448\u043a\u0430 \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0447\u0430\u0441\u0442\u0438\u0446 \u0434\u043b\u044f \u0430\u043f\u0434\u0435\u0439\u0442\u0430     return fetti.tick &lt; fetti.totalTicks;   }<\/code><\/pre>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c \u044d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043a\u043e\u043c\u0443-\u043d\u0438\u0431\u0443\u0434\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0441\u044f \u0441 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u0430 \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u043e\u043c \u043a\u0430\u043d\u0432\u0430\u0441\u0435. \u0412 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0435 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0433\u043e \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0438\u0437 \u0432\u043e\u0440\u043a\u0435\u0440\u0430 \u0438 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0438. \u0416\u0435\u043b\u0430\u044e\u0449\u0438\u0435 \u043c\u043e\u0433\u0443\u0442 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/537760\/\"> https:\/\/habr.com\/ru\/post\/537760\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-316787","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/316787","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=316787"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/316787\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=316787"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=316787"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=316787"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}