{"id":548,"date":"2023-03-11T00:40:13","date_gmt":"2023-03-10T21:40:13","guid":{"rendered":"https:\/\/notes.profidev.online\/?p=548"},"modified":"2023-03-28T23:52:40","modified_gmt":"2023-03-28T20:52:40","slug":"animacziya-snega","status":"publish","type":"post","link":"https:\/\/notes.profidev.online\/ru\/effect\/548\/","title":{"rendered":"Snow animation"},"content":{"rendered":"\n<figure class=\"wp-block-video\"><video height=\"496\" style=\"aspect-ratio: 957 \/ 496;\" width=\"957\" controls src=\"https:\/\/notes.profidev.online\/wp-content\/uploads\/2023\/03\/vokoscreenng-2023-03-10_22-35-17.webm\"><\/video><\/figure>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;htmlmixed&quot;,&quot;mime&quot;:&quot;text\/html&quot;,&quot;theme&quot;:&quot;cobalt&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:false,&quot;fileName&quot;:&quot;&quot;,&quot;TrpContentRestriction&quot;:{&quot;restriction_type&quot;:&quot;exclude&quot;,&quot;selected_languages&quot;:[],&quot;panel_open&quot;:true},&quot;language&quot;:&quot;HTML&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;html&quot;}\">&lt;div class='landscape'&gt;\n  &lt;div class='moon'&gt;&lt;\/div&gt;\n  &lt;div class='hills'&gt;\n    &lt;div&gt;&lt;\/div&gt;\n    &lt;div&gt;&lt;\/div&gt;\n    &lt;div&gt;&lt;\/div&gt;\n    &lt;div&gt;&lt;\/div&gt;\n    &lt;div&gt;&lt;\/div&gt;\n  &lt;\/div&gt;\n  &lt;div class='tree'&gt;\n    &lt;div&gt;\n      &lt;span&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n    &lt;div&gt;\n      &lt;span&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n    &lt;div&gt;\n      &lt;span&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n    &lt;div&gt;\n      &lt;span&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n    &lt;div&gt;\n      &lt;span&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n    &lt;div&gt;\n      &lt;span&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n    &lt;div&gt;\n      &lt;span&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n    &lt;div&gt;\n      &lt;span&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n    &lt;div&gt;\n      &lt;span&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n    &lt;div&gt;\n      &lt;span&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n    &lt;div&gt;\n      &lt;span&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n    &lt;div&gt;\n      &lt;span&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n    &lt;div&gt;\n      &lt;span&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n    &lt;div&gt;\n      &lt;span&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n    &lt;div&gt;\n      &lt;span&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n    &lt;div&gt;\n      &lt;span&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n    &lt;div&gt;\n      &lt;span&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n    &lt;div&gt;\n      &lt;span&gt;&lt;\/span&gt;\n    &lt;\/div&gt;\n  &lt;\/div&gt;\n&lt;\/div&gt;\n&lt;canvas id='snow'&gt;&lt;\/canvas&gt;\n\/\/\u0410\u0432\u0442\u043e\u0440: Stephen Scaff. @StephenScaff<\/pre><\/div>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;css&quot;,&quot;mime&quot;:&quot;text\/css&quot;,&quot;theme&quot;:&quot;cobalt&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:false,&quot;fileName&quot;:&quot;&quot;,&quot;TrpContentRestriction&quot;:{&quot;restriction_type&quot;:&quot;exclude&quot;,&quot;selected_languages&quot;:[],&quot;panel_open&quot;:true},&quot;language&quot;:&quot;CSS&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;css&quot;}\">* {\n  margin: 0;\n  padding: 0;\n  box-sizing: border-box;\n}\n\n*:before, *:after {\n  content: '';\n  display: block;\n  position: absolute;\n}\n\nhtml, body {\n  height: 100vh;\n  background: #eee;\n  overflow: hidden;\n}\n\n.landscape {\n  position: relative;\n  height: 650px;\n  background: #234;\n  overflow: hidden;\n}\n\n.moon {\n  position: absolute;\n  left: 55%;\n  bottom: 100px;\n  width: 350px;\n  height: 350px;\n  margin: 0 0 0 -50px;\n  border-radius: 50%;\n  background: #ccc;\n}\n\n.moon:after {\n  top: 100px;\n  left: 100px;\n  width: 50px;\n  height: 50px;\n  border-radius: 50%;\n  background: rgba(0, 0, 0, 0.1);\n  box-shadow: 120px 80px 0 rgba(0, 0, 0, 0.1), 100px -60px 0 -20px rgba(0, 0, 0, 0.1), -70px 40px 0 -20px rgba(0, 0, 0, 0.1), -20px -50px 0 -15px rgba(0, 0, 0, 0.1), -20px 120px 0 -15px rgba(0, 0, 0, 0.1), 50px 50px 0 -15px rgba(0, 0, 0, 0.1);\n}\n\n.tree {\n  position: absolute;\n  left: 50%;\n  bottom: 0;\n  margin: 0 0 0 -320px;\n}\n\n.tree div {\n  position: relative;\n  float: left;\n  display: block;\n  width: 6px;\n  height: 8px;\n  margin: 0 30px -5px 0;\n  background: #eee;\n}\n\n.tree div:before {\n  bottom: 8px;\n  border: solid transparent;\n  content: &quot; &quot;;\n  height: 0;\n  width: 0;\n  position: absolute;\n  border-bottom-color: #eee;\n  border-width: 12px;\n  left: 50%;\n  margin-left: -12px;\n}\n\n.tree div:after {\n  bottom: 15px;\n  border: solid transparent;\n  content: &quot; &quot;;\n  height: 0;\n  width: 0;\n  position: absolute;\n  border-bottom-color: #eee;\n  border-width: 10px;\n  left: 50%;\n  margin-left: -10px;\n}\n\n.tree div span:before {\n  bottom: 22px;\n  border: solid transparent;\n  content: &quot; &quot;;\n  height: 0;\n  width: 0;\n  position: absolute;\n  border-bottom-color: #eee;\n  border-width: 8px;\n  left: 50%;\n  margin-left: -8px;\n}\n\n.tree div span:after {\n  bottom: 28px;\n  border: solid transparent;\n  content: &quot; &quot;;\n  height: 0;\n  width: 0;\n  position: absolute;\n  border-bottom-color: #eee;\n  border-width: 6px;\n  left: 50%;\n  margin-left: -6px;\n}\n\n.hills {\n  position: absolute;\n  left: 50%;\n  bottom: 0;\n}\n\n.hills div {\n  overflow: hidden;\n  border-radius: 8%;\n  transform: rotate(45deg);\n}\n\n.hills div:nth-child(1),\n.hills div:nth-child(2),\n.hills div:nth-child(3) {\n  position: absolute;\n  bottom: -350px;\n  width: 500px;\n  height: 500px;\n  background: #293d52;\n}\n\n.hills div:nth-child(1) {\n  left: -750px;\n}\n\n.hills div:nth-child(2) {\n  left: -250px;\n}\n\n.hills div:nth-child(3) {\n  left: 250px;\n}\n\n.hills div:nth-child(4),\n.hills div:nth-child(5) {\n  position: absolute;\n  bottom: -400px;\n  left: -600px;\n  width: 500px;\n  height: 500px;\n  background: #30475f;\n}\n\n.hills div:nth-child(4) {\n  left: -500px;\n}\n\n.hills div:nth-child(5) {\n  left: 0;\n}\n\ncanvas {\n  position: absolute;\n  top: 0;\n  left: 0;\n  z-index: 1;\n}\n\n\/* Codepen Preview Mode *\/\n@media only screen and (max-height: 450px) {\n  .landscape {\n    margin-top: -270px;\n  }\n}<\/pre><\/div>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;cobalt&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:false,&quot;fileName&quot;:&quot;&quot;,&quot;TrpContentRestriction&quot;:{&quot;restriction_type&quot;:&quot;exclude&quot;,&quot;selected_languages&quot;:[],&quot;panel_open&quot;:true},&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">var w = window.innerWidth,\n    h = window.innerHeight,\n    canvas = document.getElementById('snow'),\n    ctx = canvas.getContext('2d'),\n    rate = 50,\n    arc = 500,\n    time,\n    count,\n    size = 2,\n    speed = 10,\n    lights = new Array,\n    colors = ['#eee'];\n\ncanvas.setAttribute('width',w);\ncanvas.setAttribute('height',h);\n\nfunction init() {\n  time = 0;\n  count = 0;\n\n  for(var i = 0; i &lt; arc; i++) {\n    lights[i] = {\n      x: Math.ceil(Math.random() * w),\n      y: Math.ceil(Math.random() * h),\n      toX: Math.random() * 5 + 1,\n      toY: Math.random() * 5 + 1,\n      c: colors[Math.floor(Math.random()*colors.length)],\n      size: Math.random() * size\n    }\n  }\n}\n\nfunction bubble() {\n  ctx.clearRect(0,0,w,h);\n\n  for(var i = 0; i &lt; arc; i++) {\n    var li = lights[i];\n\n    ctx.beginPath();\n    ctx.arc(li.x,li.y,li.size,0,Math.PI*2,false);\n    ctx.fillStyle = li.c;\n    ctx.fill();\n\n    li.x = li.x + li.toX * (time * 0.05);\n    li.y = li.y + li.toY * (time * 0.05);\n\n    if(li.x &gt; w) { li.x = 0; }\n    if(li.y &gt; h) { li.y = 0; }\n    if(li.x &lt; 0) { li.x = w; }\n    if(li.y &lt; 0) { li.y = h; }\n  }\n  if(time &lt; speed) {\n    time++;\n  }\n  timerID = setTimeout(bubble,1000\/rate);\n}\ninit();\nbubble();<\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":550,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[38],"class_list":["post-548","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-effect","tag-canvas"],"_links":{"self":[{"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/posts\/548","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/comments?post=548"}],"version-history":[{"count":0,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/posts\/548\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/media\/550"}],"wp:attachment":[{"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/media?parent=548"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/categories?post=548"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/tags?post=548"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}