{"id":348526,"date":"2023-06-08T15:07:48","date_gmt":"2023-06-08T15:07:48","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=348526"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=348526","title":{"rendered":"<span>\u0422\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \u0421\u0435\u0440\u043f\u0438\u043d\u0441\u043a\u043e\u0433\u043e \u2014 Canvas, JS<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<h2>\u041a\u0430\u043a\u043e\u0439 \u043a\u0438\u0441\u0442\u044c\u044e \u0431\u0443\u0434\u0435\u043c \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c?<\/h2>\n<p>\u041e\u0441\u043d\u043e\u0432\u043e\u0439 \u0432\u0441\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 <strong>HTML<\/strong>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u0432\u0438\u0434\u0435 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/Canvas_(HTML)\" rel=\"noopener noreferrer nofollow\">canvas<\/a>. \u0420\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0432 1000&#215;1000 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439, \u0445\u043e\u0442\u044f \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u043f\u043b\u043e\u0442\u044c \u0434\u043e 8\u043a<\/p>\n<p>\u0412 \u0440\u043e\u043b\u0438 \u0445\u0443\u0434\u043e\u0436\u043d\u0438\u043a\u0430 \u0443 \u043d\u0430\u0441 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0435\u0442 <strong>JavaScript<\/strong>. \u0412 \u043d\u0435\u043c \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u043d\u0430 <em>\u0418\u0433\u0440\u0435 \u0425\u0430\u043e\u0441\u0430<\/em>. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0432\u0441\u0435\u0433\u043e-\u043b\u0438\u0448\u044c \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 20 \u0441\u0442\u0440\u043e\u043a.<\/p>\n<p>\u0421\u0442\u0438\u043b\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c, \u043d\u043e \u0440\u0430\u0437\u0432\u0435 \u0447\u0442\u043e \u0434\u043b\u044f \u043a\u0440\u0430\u0441\u043e\u0442\u044b. \u041c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0438 \u0431\u0435\u0437 \u043d\u0438\u0445.<\/p>\n<h2>\u041b\u043e\u0433\u0438\u043a\u0430 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438:<\/h2>\n<p>\u0423 \u043d\u0430\u0441 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0431\u0435\u043b\u044b\u0439 \u0445\u043e\u043b\u0441\u0442 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u0442\u0440\u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u2014 ABC (\u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430)<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/340\/2a3\/e53\/3402a3e5323ea8c8416f0ca9522ec999.png\" width=\"913\" height=\"916\"><\/figure>\n<p>\u0417\u0430\u0434\u0430\u0435\u043c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u0432\u0435\u0440\u0448\u0438\u043d\u0443. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 <strong>C<\/strong><\/p>\n<p>\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u0443. \u0412\u043e\u0437\u044c\u043c\u0435\u043c <strong>A<\/strong><\/p>\n<p>\u041f\u0440\u043e\u0432\u043e\u0434\u0438\u043c \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u043b\u0438\u043d\u0438\u044e \u0438 \u0441\u0442\u0430\u0432\u0438\u043c \u0442\u043e\u0447\u043a\u0443 \u043f\u043e \u0446\u0435\u043d\u0442\u0440\u0443<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8c2\/0d8\/e56\/8c20d8e5623994b1bd79e6d5e41b2260.png\" width=\"913\" height=\"916\"><\/figure>\n<p>\u0412\u043d\u043e\u0432\u044c \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0443\u044e \u0432\u0435\u0440\u0448\u0438\u043d\u0443. \u041f\u0443\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 <strong>B<\/strong><\/p>\n<p>\u041f\u0440\u043e\u0432\u043e\u0434\u0438\u043c \u043b\u0438\u043d\u0438\u044e \u0441 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u0438<\/p>\n<p>\u0421\u0442\u0430\u0432\u0438\u043c \u043d\u043e\u0432\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u043f\u043e \u0446\u0435\u043d\u0442\u0440\u0443<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/86e\/851\/6be\/86e8516bec768bfcb3880a09d1a9a500.png\" width=\"913\" height=\"916\"><\/figure>\n<p>\u041f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c \u044d\u0442\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0442\u0435\u043d \u0440\u0430\u0437 \u0438 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043f\u0435\u0440\u0432\u044b\u0435 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0444\u0440\u0430\u043a\u0442\u0430\u043b\u0430<\/p>\n<h2>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u043a\u043e\u0434\u0443<\/h2>\n<p>\u041f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 <strong>HTML<\/strong> \u043a\u043e\u0434, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043a \u043d\u0435\u043c\u0443 .css \u0438 .js \u0444\u0430\u0439\u043b.<\/p>\n<p>\u0417\u0430\u0434\u0430\u0435\u043c \u0441\u0435\u0440\u044b\u0439 \u0444\u043e\u043d \u0434\u043b\u044f <strong>body<\/strong>:<\/p>\n<pre><code class=\"css\">body {     background-color: rgb(40, 40, 40); \/* \u0427\u0442\u043e\u0431 \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0431\u044b\u043b\u043e :D *\/ }<\/code><\/pre>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 <strong>body<\/strong> \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 <strong>canvas<\/strong>, \u0434\u0430\u0435\u043c \u0435\u043c\u0443 \u0440\u0430\u0437\u043c\u0435\u0440\u044b 1000&#215;1000 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0438 \u0431\u0435\u043b\u044b\u0439 \u0444\u043e\u043d:<\/p>\n<pre><code class=\"xml\">&lt;canvas width=\"1000\" height=\"1000\"&gt;&lt;\/canvas&gt;<\/code><\/pre>\n<pre><code class=\"css\">canvas {     background-color: white; }<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431 \u043c\u044b \u0437\u043d\u0430\u043b\u0438 \u043d\u044b\u043d\u0435\u0448\u043d\u044e\u044e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044e \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u0447\u0435\u043a \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435, \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u043f\u0438\u0448\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"xml\">&lt;span&gt;\u0422\u043e\u0447\u0435\u043a \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435: 0&lt;\/span&gt;<\/code><\/pre>\n<pre><code class=\"css\">span {     position: absolute; \/* \u041f\u0440\u0438\u0436\u0438\u043c\u0430\u0435\u043c \u0442\u0435\u043a\u0441\u0442 \u0438 \u043b\u0435\u0432\u043e\u043c\u0443-\u043d\u0438\u0436\u043d\u0435\u043c\u0443 \u0443\u0433\u043b\u0443 \u044d\u043a\u0440\u0430\u043d\u0430 *\/     right: 0;     bottom: 0;     font-size: 30px; \/* \u0417\u0430\u0434\u0430\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440 \u0438 \u0446\u0432\u0435\u0442 \u0442\u0435\u043a\u0441\u0442\u0430 *\/     color: white; }<\/code><\/pre>\n<h2>\u041f\u0438\u0448\u0435\u043c JS \u0441\u043a\u0440\u0438\u043f\u0442:<\/h2>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0430\u043c <strong>canvas<\/strong> \u0438 \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435:<\/p>\n<pre><code class=\"javascript\">let canvas = document.querySelector('canvas') \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c canvas \u0432 \u0432\u0438\u0434\u0435 DOM-\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 let ctx = canvas.getContext('2d'); \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 (\u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435)<\/code><\/pre>\n<p>\u041e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u043c \u0443\u0433\u043b\u044b \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b (<a href=\"https:\/\/metanit.com\/web\/javascript\/2.5.php\" rel=\"noopener noreferrer nofollow\">\u0434\u0432\u0443\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430<\/a>) \u0441 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438:<\/p>\n<p>\u0414\u0430\u0431\u044b \u043d\u0435 \u043c\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0441 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0445\u043e\u043b\u0441\u0442\u0430, \u043b\u0443\u0447\u0448\u0435 \u0431\u0443\u0434\u0435\u043c \u0441\u0430\u043c\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0438\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>.getBoundingClientRect()<\/strong><\/p>\n<pre><code class=\"javascript\">let cornerCords = [ \/\/ \u041a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0432 \u0432\u0438\u0434\u0435 X = \u0448\u0438\u0440\u0438\u043d\u0430, Y = \u0432\u044b\u0441\u043e\u0442\u0430     [canvas.getBoundingClientRect().width \/ 2, 0], \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0448\u0438\u0440\u0438\u043d\u0443 \u0445\u043e\u043b\u0441\u0442\u0430 \u0438 \u0434\u0435\u043b\u0438\u043c \u0435\u0435 \u043d\u0430 2, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0446\u0435\u043d\u0442\u0440 (\u0432\u0435\u0440\u0448\u0438\u043d\u0430 \u0410)     [0, canvas.getBoundingClientRect().height], \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0441\u043e\u0442\u0443 \u0445\u043e\u043b\u0441\u0442\u0430 \u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0432\u0435\u0440\u0448\u0438\u043d\u0443 B     [canvas.getBoundingClientRect().width, canvas.getBoundingClientRect().height] \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438 \u0432\u044b\u0441\u043e\u0442\u0443, \u0438 \u0448\u0438\u0440\u0438\u043d\u0443 \u0445\u043e\u043b\u0441\u0442\u0430, \u043d\u0430\u0439\u0434\u044f \u0432\u0435\u0440\u0448\u0438\u043d\u0443 C ]<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 \u0446\u0438\u0444\u0440\u044b, \u0430 \u0445\u043e\u043b\u0441\u0442 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0432 1000\u04451000, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442c\u044f \u0442\u0430\u043a\u043e\u0435:<\/p>\n<pre><code class=\"javascript\">let cornerCords = [     [500, 0],      [0, 1000],      [1000, 1000] ]<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0445\u043e\u043b\u0441\u0442\u0430 \u043a\u0430\u043a \u0437\u0430\u0445\u043e\u0442\u0438\u043c, \u0430 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f<\/p>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438<\/p>\n<p>\u041f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043e\u0431\u044b\u0447\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441 \u0438\u043c\u0435\u043d\u0435\u043c <strong>RecursionDrawing<\/strong>:<\/p>\n<pre><code class=\"javascript\">function RecursionDrawing() {}<\/code><\/pre>\n<p>\u041a\u0430\u043a \u043c\u044b \u043f\u043e\u043c\u043d\u0438\u043c, \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u0447\u0430\u043b\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u043c \u0443\u0433\u043b\u043e\u043c, \u043f\u0443\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 <strong>A<\/strong><\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0434\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u043d\u044f\u0442\u044c \u044d\u0442\u043e, \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u0441\u0442\u0430\u0435\u043c \u0438\u0437 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442:<\/p>\n<pre><code class=\"javascript\">function RecursionDrawing(previousDotCords) {   \/\/ \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0438 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0438\u0445 \u0432 \u0432\u0438\u0434\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 previousDotCords }   RecursionDrawing(cornerCords[0])<\/code><\/pre>\n<p>\u0412\u043d\u0443\u0442\u0440\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c <strong>setTimeout()<\/strong> (\u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0430), \u0434\u0430\u0431\u044b \u043d\u0435 \u043b\u043e\u0432\u0438\u0442\u044c <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Errors\/Too_much_recursion\" rel=\"noopener noreferrer nofollow\">\u043e\u0448\u0438\u0431\u043a\u0443<\/a>:<\/p>\n<pre><code class=\"javascript\">function RecursionDrawing() {   setTimeout(function () {}, 0) \/\/ \u0417\u0430\u0434\u0435\u0440\u0436\u043a\u0430 0\u043c\u0441, \u044d\u0442\u043e\u0433\u043e \u0445\u0432\u0430\u0442\u0438\u0442 }  RecursionDrawing(cornerCords[0])<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438, \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0443\u044e \u0432\u0435\u0440\u0448\u0438\u043d\u0443<\/p>\n<p>\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u044f\u043c\u0438 \u0441\u043e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Math\" rel=\"noopener noreferrer nofollow\">Math<\/a>:<\/p>\n<pre><code class=\"javascript\">function RecursionDrawing() {   setTimeout(function () {     let randomCorner = Math.floor(Math.random() * cornerCords.length)     \/\/ Math.random() \u0434\u0430\u0435\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0434\u0440\u043e\u0431\u043d\u043e\u0435 (float) \u0447\u0438\u0441\u043b\u043e \u043e\u0442 0 \u0434\u043e 1     \/\/ \u0423\u043c\u043d\u043e\u0436\u0430\u044f \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u0434\u043b\u0438\u043d\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e     \/\/ \u041e\u043a\u0440\u0443\u0433\u043b\u044f\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Math.floor() \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u043f\u043e\u043b\u043d\u043e\u0435 (int) \u0447\u0438\u0441\u043b\u043e     \/\/ \u0422\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u0447\u0438\u0441\u043b\u043e (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0442 0 \u0434\u043e 2, A-B-C)        }, 0) }  RecursionDrawing(cornerCords[0])<\/code><\/pre>\n<p>\u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 <strong>canvas<\/strong>:<\/p>\n<pre><code class=\"javascript\">function RecursionDrawing(previousDotCords) {     setTimeout(function () {         let randomCorner = Math.floor(Math.random() * cornerCords.length)          ctx.beginPath() \/\/ \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u0443\u0442\u044c          ctx.fillStyle = \"black\" \/\/ \u0426\u0432\u0435\u0442 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0447\u0435\u0440\u043d\u044b\u0439 (\u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 hsl, rgb, hex)                  ctx.closePath() \/\/ \u0417\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u0443\u0442\u044c       }, 0)   }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0438\u0441\u0443\u0435\u043c \u0441\u0430\u043c\u0443 \u0442\u043e\u0447\u043a\u0443:<\/p>\n<p><strong>X<\/strong> = (X-\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0443\u0433\u043b\u0430 + X-\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u0438) \/ 2<\/p>\n<p><strong>Y<\/strong> = (Y-\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0443\u0433\u043b\u0430 + Y-\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u0438) \/ 2<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0443\u043a\u0430\u0436\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0442\u043e\u0447\u043a\u0438: (1, 1)<\/p>\n<pre><code class=\"javascript\">\/\/ \u0412 JS \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a (cornerCords[randomCorner][0] + previousDotCords[0]) \/ 2, (cornerCords[randomCorner][1] + previousDotCords[1]) \/ 2, 1, 1)<\/code><\/pre>\n<p>\u0412\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u044d\u0442\u043e \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"javascript\">function RecursionDrawing(previousDotCords) {     setTimeout(function () {         let randomCorner = Math.floor(Math.random() * cornerCords.length)          ctx.beginPath()         ctx.fillStyle = \"black\"                \/\/ ctx.fillRect() \u2014 \u0417\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044f: (x, y, width, height)         ctx.fillRect((cornerCords[randomCorner][0] + previousDotCords[0]) \/ 2, (cornerCords[randomCorner][1] + previousDotCords[1]) \/ 2, 1, 1)                ctx.closePath()       }, 0)   }<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044e, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044f \u0432 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u0434\u0430 \u0441\u0430\u043c\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u043e\u0432\u043e\u0439 \u0442\u043e\u0447\u043a\u0438:<\/p>\n<pre><code class=\"javascript\">function RecursionDrawing(previousDotCords) {     setTimeout(function () {         let randomCorner = Math.floor(Math.random() * cornerCords.length)          ctx.beginPath()         ctx.fillStyle = \"black\"         ctx.fillRect((cornerCords[randomCorner][0] + previousDotCords[0]) \/ 2, (cornerCords[randomCorner][1] + previousDotCords[1]) \/ 2, 1, 1)         ctx.closePath()          \/\/ \u041f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u0438 \u0432 ctx.fillRect(), \u043d\u043e \u0431\u0435\u0437 width \u0438 height (1, 1)         RecursionDrawing([(cornerCords[randomCorner][0] + previousDotCords[0]) \/ 2, (cornerCords[randomCorner][1] + previousDotCords[1]) \/ 2])       }, 0)   }<\/code><\/pre>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043b\u0438\u0448\u044c \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u043b-\u0432\u043e \u0442\u043e\u0447\u0435\u043a<\/p>\n<p>\u0412\u043d\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <strong>iteration<\/strong>:<\/p>\n<pre><code class=\"javascript\">let iteration = 0<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"javascript\">let iteration = 0 function RecursionDrawing(previousDotCords) {     setTimeout(function () {         let randomCorner = Math.floor(Math.random() * cornerCords.length)          ctx.beginPath()         ctx.fillStyle = \"black\"         ctx.fillRect((cornerCords[randomCorner][0] + previousDotCords[0]) \/ 2, (cornerCords[randomCorner][1] + previousDotCords[1]) \/ 2, 1, 1)         ctx.closePath()          iteration++ \/\/ \u041a iteration \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c +1         \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0430\u0448 span \u0438 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435         document.querySelector('span').innerText = `\u0422\u043e\u0447\u0435\u043a \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435: ${iteration}`                 RecursionDrawing([(cornerCords[randomCorner][0] + previousDotCords[0]) \/ 2, (cornerCords[randomCorner][1] + previousDotCords[1]) \/ 2])       }, 0)   }<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0436, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043b\u0438\u0448\u044c \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u0432\u043c\u0435\u0441\u0442\u0435<\/p>\n<h2>\u0412\u0435\u0441\u044c \u043a\u043e\u0434:<\/h2>\n<p>HTML:<\/p>\n<pre><code class=\"xml\">&lt;!DOCTYPE html&gt; &lt;html lang=\"en\"&gt; &lt;head&gt;     &lt;meta charset=\"UTF-8\"&gt;     &lt;meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"&gt;     &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;     &lt;title&gt;Document&lt;\/title&gt;     &lt;link rel=\"stylesheet\" href=\"style.css\"&gt; &lt;\/head&gt; &lt;body&gt;     &lt;canvas width=\"1000\" height=\"1000\"&gt;&lt;\/canvas&gt;     &lt;span&gt;\u0422\u043e\u0447\u0435\u043a \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435: 0&lt;\/span&gt;      &lt;script src=\"script.js\"&gt;&lt;\/script&gt; &lt;\/body&gt; &lt;\/html&gt;<\/code><\/pre>\n<p>CSS:<\/p>\n<pre><code class=\"css\">body {     background-color: rgb(40, 40, 40); } canvas {     background-color: white; } span {     position: absolute;      right: 0;     bottom: 0;     font-size: 30px;     color: rgb(255, 255, 255);     }<\/code><\/pre>\n<p>JS:<\/p>\n<pre><code class=\"javascript\">let canvas = document.querySelector('canvas') let ctx = canvas.getContext('2d');  let cornerCords = [     [canvas.getBoundingClientRect().width \/ 2, 0],      [0, canvas.getBoundingClientRect().height],      [canvas.getBoundingClientRect().width, canvas.getBoundingClientRect().height] ]  let iteration = 0 function RecursionDrawing(previousDotCords) {     setTimeout(function () {         let randomCorner = Math.floor(Math.random() * cornerCords.length)          ctx.beginPath()         ctx.fillStyle = \"black\"         ctx.fillRect((cornerCords[randomCorner][0] + previousDotCords[0]) \/ 2, (cornerCords[randomCorner][1] + previousDotCords[1]) \/ 2, 1, 1)         ctx.closePath()          iteration++         document.querySelector('span').innerText = `\u0422\u043e\u0447\u0435\u043a \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435: ${iteration}`          RecursionDrawing([(cornerCords[randomCorner][0] + previousDotCords[0]) \/ 2, (cornerCords[randomCorner][1] + previousDotCords[1]) \/ 2])     }, 0) }  RecursionDrawing(cornerCords[0])<\/code><\/pre>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430.<\/p>\n<p>CodePen: <a href=\"https:\/\/codepen.io\/Saman2789\/pen\/vYQEGNV\" rel=\"noopener noreferrer nofollow\">https:\/\/codepen.io\/Saman2789\/pen\/vYQEGNV<\/a><\/p>\n<p>\u0411\u0443\u0434\u0443 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u0435\u043d, \u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u0435 \u043c\u043e\u0439 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u043a\u0430\u043d\u0430\u043b: <a href=\"https:\/\/t.me\/blg_projects\" rel=\"noopener noreferrer nofollow\">https:\/\/t.me\/blg_projects<\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \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\/articles\/740658\/\"> https:\/\/habr.com\/ru\/articles\/740658\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<h2>\u041a\u0430\u043a\u043e\u0439 \u043a\u0438\u0441\u0442\u044c\u044e \u0431\u0443\u0434\u0435\u043c \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c?<\/h2>\n<p>\u041e\u0441\u043d\u043e\u0432\u043e\u0439 \u0432\u0441\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 <strong>HTML<\/strong>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u0432\u0438\u0434\u0435 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/Canvas_(HTML)\" rel=\"noopener noreferrer nofollow\">canvas<\/a>. \u0420\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0432 1000&#215;1000 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439, \u0445\u043e\u0442\u044f \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u043f\u043b\u043e\u0442\u044c \u0434\u043e 8\u043a<\/p>\n<p>\u0412 \u0440\u043e\u043b\u0438 \u0445\u0443\u0434\u043e\u0436\u043d\u0438\u043a\u0430 \u0443 \u043d\u0430\u0441 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0435\u0442 <strong>JavaScript<\/strong>. \u0412 \u043d\u0435\u043c \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u043d\u0430 <em>\u0418\u0433\u0440\u0435 \u0425\u0430\u043e\u0441\u0430<\/em>. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0432\u0441\u0435\u0433\u043e-\u043b\u0438\u0448\u044c \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 20 \u0441\u0442\u0440\u043e\u043a.<\/p>\n<p>\u0421\u0442\u0438\u043b\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c, \u043d\u043e \u0440\u0430\u0437\u0432\u0435 \u0447\u0442\u043e \u0434\u043b\u044f \u043a\u0440\u0430\u0441\u043e\u0442\u044b. \u041c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0438 \u0431\u0435\u0437 \u043d\u0438\u0445.<\/p>\n<h2>\u041b\u043e\u0433\u0438\u043a\u0430 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438:<\/h2>\n<p>\u0423 \u043d\u0430\u0441 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0431\u0435\u043b\u044b\u0439 \u0445\u043e\u043b\u0441\u0442 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u0442\u0440\u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u2014 ABC (\u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430)<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0417\u0430\u0434\u0430\u0435\u043c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u0432\u0435\u0440\u0448\u0438\u043d\u0443. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 <strong>C<\/strong><\/p>\n<p>\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u0443. \u0412\u043e\u0437\u044c\u043c\u0435\u043c <strong>A<\/strong><\/p>\n<p>\u041f\u0440\u043e\u0432\u043e\u0434\u0438\u043c \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u043b\u0438\u043d\u0438\u044e \u0438 \u0441\u0442\u0430\u0432\u0438\u043c \u0442\u043e\u0447\u043a\u0443 \u043f\u043e \u0446\u0435\u043d\u0442\u0440\u0443<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0412\u043d\u043e\u0432\u044c \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0443\u044e \u0432\u0435\u0440\u0448\u0438\u043d\u0443. \u041f\u0443\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 <strong>B<\/strong><\/p>\n<p>\u041f\u0440\u043e\u0432\u043e\u0434\u0438\u043c \u043b\u0438\u043d\u0438\u044e \u0441 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u0438<\/p>\n<p>\u0421\u0442\u0430\u0432\u0438\u043c \u043d\u043e\u0432\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u043f\u043e \u0446\u0435\u043d\u0442\u0440\u0443<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c \u044d\u0442\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0442\u0435\u043d \u0440\u0430\u0437 \u0438 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043f\u0435\u0440\u0432\u044b\u0435 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0444\u0440\u0430\u043a\u0442\u0430\u043b\u0430<\/p>\n<h2>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u043a\u043e\u0434\u0443<\/h2>\n<p>\u041f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 <strong>HTML<\/strong> \u043a\u043e\u0434, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043a \u043d\u0435\u043c\u0443 .css \u0438 .js \u0444\u0430\u0439\u043b.<\/p>\n<p>\u0417\u0430\u0434\u0430\u0435\u043c \u0441\u0435\u0440\u044b\u0439 \u0444\u043e\u043d \u0434\u043b\u044f <strong>body<\/strong>:<\/p>\n<pre><code class=\"css\">body {     background-color: rgb(40, 40, 40); \/* \u0427\u0442\u043e\u0431 \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0431\u044b\u043b\u043e :D *\/ }<\/code><\/pre>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 <strong>body<\/strong> \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 <strong>canvas<\/strong>, \u0434\u0430\u0435\u043c \u0435\u043c\u0443 \u0440\u0430\u0437\u043c\u0435\u0440\u044b 1000&#215;1000 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0438 \u0431\u0435\u043b\u044b\u0439 \u0444\u043e\u043d:<\/p>\n<pre><code class=\"xml\">&lt;canvas width=\"1000\" height=\"1000\"&gt;&lt;\/canvas&gt;<\/code><\/pre>\n<pre><code class=\"css\">canvas {     background-color: white; }<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431 \u043c\u044b \u0437\u043d\u0430\u043b\u0438 \u043d\u044b\u043d\u0435\u0448\u043d\u044e\u044e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044e \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u0447\u0435\u043a \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435, \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u043f\u0438\u0448\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"xml\">&lt;span&gt;\u0422\u043e\u0447\u0435\u043a \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435: 0&lt;\/span&gt;<\/code><\/pre>\n<pre><code class=\"css\">span {     position: absolute; \/* \u041f\u0440\u0438\u0436\u0438\u043c\u0430\u0435\u043c \u0442\u0435\u043a\u0441\u0442 \u0438 \u043b\u0435\u0432\u043e\u043c\u0443-\u043d\u0438\u0436\u043d\u0435\u043c\u0443 \u0443\u0433\u043b\u0443 \u044d\u043a\u0440\u0430\u043d\u0430 *\/     right: 0;     bottom: 0;     font-size: 30px; \/* \u0417\u0430\u0434\u0430\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440 \u0438 \u0446\u0432\u0435\u0442 \u0442\u0435\u043a\u0441\u0442\u0430 *\/     color: white; }<\/code><\/pre>\n<h2>\u041f\u0438\u0448\u0435\u043c JS \u0441\u043a\u0440\u0438\u043f\u0442:<\/h2>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0430\u043c <strong>canvas<\/strong> \u0438 \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435:<\/p>\n<pre><code class=\"javascript\">let canvas = document.querySelector('canvas') \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c canvas \u0432 \u0432\u0438\u0434\u0435 DOM-\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 let ctx = canvas.getContext('2d'); \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 (\u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435)<\/code><\/pre>\n<p>\u041e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u043c \u0443\u0433\u043b\u044b \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b (<a href=\"https:\/\/metanit.com\/web\/javascript\/2.5.php\" rel=\"noopener noreferrer nofollow\">\u0434\u0432\u0443\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430<\/a>) \u0441 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438:<\/p>\n<p>\u0414\u0430\u0431\u044b \u043d\u0435 \u043c\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0441 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0445\u043e\u043b\u0441\u0442\u0430, \u043b\u0443\u0447\u0448\u0435 \u0431\u0443\u0434\u0435\u043c \u0441\u0430\u043c\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0438\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>.getBoundingClientRect()<\/strong><\/p>\n<pre><code class=\"javascript\">let cornerCords = [ \/\/ \u041a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0432 \u0432\u0438\u0434\u0435 X = \u0448\u0438\u0440\u0438\u043d\u0430, Y = \u0432\u044b\u0441\u043e\u0442\u0430     [canvas.getBoundingClientRect().width \/ 2, 0], \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0448\u0438\u0440\u0438\u043d\u0443 \u0445\u043e\u043b\u0441\u0442\u0430 \u0438 \u0434\u0435\u043b\u0438\u043c \u0435\u0435 \u043d\u0430 2, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0446\u0435\u043d\u0442\u0440 (\u0432\u0435\u0440\u0448\u0438\u043d\u0430 \u0410)     [0, canvas.getBoundingClientRect().height], \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0441\u043e\u0442\u0443 \u0445\u043e\u043b\u0441\u0442\u0430 \u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0432\u0435\u0440\u0448\u0438\u043d\u0443 B     [canvas.getBoundingClientRect().width, canvas.getBoundingClientRect().height] \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438 \u0432\u044b\u0441\u043e\u0442\u0443, \u0438 \u0448\u0438\u0440\u0438\u043d\u0443 \u0445\u043e\u043b\u0441\u0442\u0430, \u043d\u0430\u0439\u0434\u044f \u0432\u0435\u0440\u0448\u0438\u043d\u0443 C ]<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 \u0446\u0438\u0444\u0440\u044b, \u0430 \u0445\u043e\u043b\u0441\u0442 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0432 1000\u04451000, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442c\u044f \u0442\u0430\u043a\u043e\u0435:<\/p>\n<pre><code class=\"javascript\">let cornerCords = [     [500, 0],      [0, 1000],      [1000, 1000] ]<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0445\u043e\u043b\u0441\u0442\u0430 \u043a\u0430\u043a \u0437\u0430\u0445\u043e\u0442\u0438\u043c, \u0430 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f<\/p>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438<\/p>\n<p>\u041f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043e\u0431\u044b\u0447\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441 \u0438\u043c\u0435\u043d\u0435\u043c <strong>RecursionDrawing<\/strong>:<\/p>\n<pre><code class=\"javascript\">function RecursionDrawing() {}<\/code><\/pre>\n<p>\u041a\u0430\u043a \u043c\u044b \u043f\u043e\u043c\u043d\u0438\u043c, \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u0447\u0430\u043b\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u043c \u0443\u0433\u043b\u043e\u043c, \u043f\u0443\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 <strong>A<\/strong><\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0434\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u043d\u044f\u0442\u044c \u044d\u0442\u043e, \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u0441\u0442\u0430\u0435\u043c \u0438\u0437 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442:<\/p>\n<pre><code class=\"javascript\">function RecursionDrawing(previousDotCords) {   \/\/ \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0438 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0438\u0445 \u0432 \u0432\u0438\u0434\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 previousDotCords }   RecursionDrawing(cornerCords[0])<\/code><\/pre>\n<p>\u0412\u043d\u0443\u0442\u0440\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c <strong>setTimeout()<\/strong> (\u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0430), \u0434\u0430\u0431\u044b \u043d\u0435 \u043b\u043e\u0432\u0438\u0442\u044c <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Errors\/Too_much_recursion\" rel=\"noopener noreferrer nofollow\">\u043e\u0448\u0438\u0431\u043a\u0443<\/a>:<\/p>\n<pre><code class=\"javascript\">function RecursionDrawing() {   setTimeout(function () {}, 0) \/\/ \u0417\u0430\u0434\u0435\u0440\u0436\u043a\u0430 0\u043c\u0441, \u044d\u0442\u043e\u0433\u043e \u0445\u0432\u0430\u0442\u0438\u0442 }  RecursionDrawing(cornerCords[0])<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438, \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0443\u044e \u0432\u0435\u0440\u0448\u0438\u043d\u0443<\/p>\n<p>\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u044f\u043c\u0438 \u0441\u043e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Math\" rel=\"noopener noreferrer nofollow\">Math<\/a>:<\/p>\n<pre><code class=\"javascript\">function RecursionDrawing() {   setTimeout(function () {     let randomCorner = Math.floor(Math.random() * cornerCords.length)     \/\/ Math.random() \u0434\u0430\u0435\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0434\u0440\u043e\u0431\u043d\u043e\u0435 (float) \u0447\u0438\u0441\u043b\u043e \u043e\u0442 0 \u0434\u043e 1     \/\/ \u0423\u043c\u043d\u043e\u0436\u0430\u044f \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u0434\u043b\u0438\u043d\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e     \/\/ \u041e\u043a\u0440\u0443\u0433\u043b\u044f\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Math.floor() \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u043f\u043e\u043b\u043d\u043e\u0435 (int) \u0447\u0438\u0441\u043b\u043e     \/\/ \u0422\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u0447\u0438\u0441\u043b\u043e (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0442 0 \u0434\u043e 2, A-B-C)        }, 0) }  RecursionDrawing(cornerCords[0])<\/code><\/pre>\n<p>\u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 <strong>canvas<\/strong>:<\/p>\n<pre><code class=\"javascript\">function RecursionDrawing(previousDotCords) {     setTimeout(function () {         let randomCorner = Math.floor(Math.random() * cornerCords.length)          ctx.beginPath() \/\/ \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u0443\u0442\u044c          ctx.fillStyle = \"black\" \/\/ \u0426\u0432\u0435\u0442 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0447\u0435\u0440\u043d\u044b\u0439 (\u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 hsl, rgb, hex)                  ctx.closePath() \/\/ \u0417\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u0443\u0442\u044c       }, 0)   }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0438\u0441\u0443\u0435\u043c \u0441\u0430\u043c\u0443 \u0442\u043e\u0447\u043a\u0443:<\/p>\n<p><strong>X<\/strong> = (X-\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0443\u0433\u043b\u0430 + X-\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u0438) \/ 2<\/p>\n<p><strong>Y<\/strong> = (Y-\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0443\u0433\u043b\u0430 + Y-\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u0438) \/ 2<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0443\u043a\u0430\u0436\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0442\u043e\u0447\u043a\u0438: (1, 1)<\/p>\n<pre><code class=\"javascript\">\/\/ \u0412 JS \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a (cornerCords[randomCorner][0] + previousDotCords[0]) \/ 2, (cornerCords[randomCorner][1] + previousDotCords[1]) \/ 2, 1, 1)<\/code><\/pre>\n<p>\u0412\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u044d\u0442\u043e \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"javascript\">function RecursionDrawing(previousDotCords) {     setTimeout(function () {         let randomCorner = Math.floor(Math.random() * cornerCords.length)          ctx.beginPath()         ctx.fillStyle = \"black\"                \/\/ ctx.fillRect() \u2014 \u0417\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044f: (x, y, width, height)         ctx.fillRect((cornerCords[randomCorner][0] + previousDotCords[0]) \/ 2, (cornerCords[randomCorner][1] + previousDotCords[1]) \/ 2, 1, 1)                ctx.closePath()       }, 0)   }<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044e, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044f \u0432 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u0434\u0430 \u0441\u0430\u043c\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u043e\u0432\u043e\u0439 \u0442\u043e\u0447\u043a\u0438:<\/p>\n<pre><code class=\"javascript\">function RecursionDrawing(previousDotCords) {     setTimeout(function () {         let randomCorner = Math.floor(Math.random() * cornerCords.length)          ctx.beginPath()         ctx.fillStyle = \"black\"         ctx.fillRect((cornerCords[randomCorner][0] + previousDotCords[0]) \/ 2, (cornerCords[randomCorner][1] + previousDotCords[1]) \/ 2, 1, 1)         ctx.closePath()          \/\/ \u041f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u0438 \u0432 ctx.fillRect(), \u043d\u043e \u0431\u0435\u0437 width \u0438 height (1, 1)         RecursionDrawing([(cornerCords[randomCorner][0] + previousDotCords[0]) \/ 2, (cornerCords[randomCorner][1] + previousDotCords[1]) \/ 2])       }, 0)   }<\/code><\/pre>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043b\u0438\u0448\u044c \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u043b-\u0432\u043e \u0442\u043e\u0447\u0435\u043a<\/p>\n<p>\u0412\u043d\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <strong>iteration<\/strong>:<\/p>\n<pre><code class=\"javascript\">let iteration = 0<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"javascript\">let iteration = 0 function RecursionDrawing(previousDotCords) {     setTimeout(function () {         let randomCorner = Math.floor(Math.random() * cornerCords.length)          ctx.beginPath()         ctx.fillStyle = \"black\"         ctx.fillRect((cornerCords[randomCorner][0] + previousDotCords[0]) \/ 2, (cornerCords[randomCorner][1] + previousDotCords[1]) \/ 2, 1, 1)         ctx.closePath()          iteration++ \/\/ \u041a iteration \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c +1         \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0430\u0448 span \u0438 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435         document.querySelector('span').innerText = `\u0422\u043e\u0447\u0435\u043a \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435: ${iteration}`                 RecursionDrawing([(cornerCords[randomCorner][0] + previousDotCords[0]) \/ 2, (cornerCords[randomCorner][1] + previousDotCords[1]) \/ 2])       }, 0)   }<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0436, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043b\u0438\u0448\u044c \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u0432\u043c\u0435\u0441\u0442\u0435<\/p>\n<h2>\u0412\u0435\u0441\u044c \u043a\u043e\u0434:<\/h2>\n<p>HTML:<\/p>\n<pre><code class=\"xml\">&lt;!DOCTYPE html&gt; &lt;html lang=\"en\"&gt; &lt;head&gt;     &lt;meta charset=\"UTF-8\"&gt;     &lt;meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"&gt;     &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;     &lt;title&gt;Document&lt;\/title&gt;     &lt;link rel=\"stylesheet\" href=\"style.css\"&gt; &lt;\/head&gt; &lt;body&gt;     &lt;canvas width=\"1000\" height=\"1000\"&gt;&lt;\/canvas&gt;     &lt;span&gt;\u0422\u043e\u0447\u0435\u043a \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435: 0&lt;\/span&gt;      &lt;script src=\"script.js\"&gt;&lt;\/script&gt; &lt;\/body&gt; &lt;\/html&gt;<\/code><\/pre>\n<p>CSS:<\/p>\n<pre><code class=\"css\">body {     background-color: rgb(40, 40, 40); } canvas {     background-color: white; } span {     position: absolute;      right: 0;     bottom: 0;     font-size: 30px;     color: rgb(255, 255, 255);     }<\/code><\/pre>\n<p>JS:<\/p>\n<pre><code class=\"javascript\">let canvas = document.querySelector('canvas') let ctx = canvas.getContext('2d');  let cornerCords = [     [canvas.getBoundingClientRect().width \/ 2, 0],      [0, canvas.getBoundingClientRect().height],      [canvas.getBoundingClientRect().width, canvas.getBoundingClientRect().height] ]  let iteration = 0 function RecursionDrawing(previousDotCords) {     setTimeout(function () {         let randomCorner = Math.floor(Math.random() * cornerCords.length)          ctx.beginPath()         ctx.fillStyle = \"black\"         ctx.fillRect((cornerCords[randomCorner][0] + previousDotCords[0]) \/ 2, (cornerCords[randomCorner][1] + previousDotCords[1]) \/ 2, 1, 1)         ctx.closePath()          iteration++         document.querySelector('span').innerText = `\u0422\u043e\u0447\u0435\u043a \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435: ${iteration}`          RecursionDrawing([(cornerCords[randomCorner][0] + previousDotCords[0]) \/ 2, (cornerCords[randomCorner][1] + previousDotCords[1]) \/ 2])     }, 0) }  RecursionDrawing(cornerCords[0])<\/code><\/pre>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430.<\/p>\n<p>CodePen: <a href=\"https:\/\/codepen.io\/Saman2789\/pen\/vYQEGNV\" rel=\"noopener noreferrer nofollow\">https:\/\/codepen.io\/Saman2789\/pen\/vYQEGNV<\/a><\/p>\n<p>\u0411\u0443\u0434\u0443 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u0435\u043d, \u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u0435 \u043c\u043e\u0439 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u043a\u0430\u043d\u0430\u043b: <a href=\"https:\/\/t.me\/blg_projects\" rel=\"noopener noreferrer nofollow\">https:\/\/t.me\/blg_projects<\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \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\/articles\/740658\/\"> https:\/\/habr.com\/ru\/articles\/740658\/<\/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-348526","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/348526","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=348526"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/348526\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=348526"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=348526"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=348526"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}