{"id":1829,"date":"2022-12-22T22:51:56","date_gmt":"2022-12-22T21:51:56","guid":{"rendered":"https:\/\/hannes.enjoys.it\/blog\/?p=1829"},"modified":"2022-12-22T22:53:18","modified_gmt":"2022-12-22T21:53:18","slug":"animated-snowflakes-in-qgis","status":"publish","type":"post","link":"https:\/\/hannes.enjoys.it\/blog\/2022\/12\/animated-snowflakes-in-qgis\/","title":{"rendered":"Animated snowflakes in QGIS"},"content":{"rendered":"\n<p>Inspired by <a href=\"https:\/\/mapstodon.space\/@bogind\/109558968869019746\">https:\/\/mapstodon.space\/@bogind\/109558968869019746<\/a> and listening to <a href=\"https:\/\/www.youtube.com\/watch?v=AdyAF9M3XVw\">https:\/\/www.youtube.com\/watch?v=AdyAF9M3XVw<\/a> on repeat thanks to <a href=\"https:\/\/ruby.social\/@halfbyte\/109558803178815394\">https:\/\/ruby.social\/@halfbyte\/109558803178815394<\/a> I made:<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"1018\" style=\"aspect-ratio: 1680 \/ 1018;\" width=\"1680\" controls src=\"https:\/\/hannes.enjoys.it\/blog\/wp-content\/uploads\/20221222-animated-snowflakes.mp4\"><\/video><\/figure>\n\n\n\n<p>This was the final expression (with lots of opportunity to improve):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">with_variable(\n  'point_at_top_of_canvas',\n  densify_by_count(\n    make_line(\n      point_n( @map_extent, 3),  -- no idea if these indexes are stable\n      point_n( @map_extent, 4)\n    ),\n    42  -- number of trajectories\n  ),\n  collect_geometries(\n    array_foreach(\n      generate_series(1, num_points(@point_at_top_of_canvas)),\n      with_variable(\n        'point_n_of_top_line',\n        point_n(@point_at_top_of_canvas, @element),\n        point_n(\n          wave_randomized(\n            make_line(\n              @point_n_of_top_line,\n              -- make it at least touch the bottom of the canvas:\n              translate(@point_n_of_top_line, 0, -@map_extent_height)\n            ),\n            -- fairly stupid frequency and wavelength but hey, works in any crs\n            1, @map_extent_width\/5,\n            1, @map_extent_width\/100,\n            seed:=@element  -- stable waves \\o\/\n          ),\n          floor(epoch(now())%10000\/50)  -- TODO make it loop around according to num_points of each line\n        )\n      )\n    )\n  )\n)<\/code><\/pre>\n\n\n\n<p>Use it on an empty polygon layer with an inverted polygon style and set it to refresh at a high interval (0.01s?). Or use this QGIS project (I included some intermediate steps of the style as layer styles if you want to learn about this kind of stuff):<\/p>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-f8dc64c4-903b-4585-ac1e-af5f0f7009ee\" href=\"https:\/\/hannes.enjoys.it\/blog\/wp-content\/uploads\/20221222-animated-snowflakes.qgz_.zip\">20221222-animated-snowflakes.qgz_<\/a><a href=\"https:\/\/hannes.enjoys.it\/blog\/wp-content\/uploads\/20221222-animated-snowflakes.qgz_.zip\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-f8dc64c4-903b-4585-ac1e-af5f0f7009ee\">Download<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Inspired by https:\/\/mapstodon.space\/@bogind\/109558968869019746 and listening to https:\/\/www.youtube.com\/watch?v=AdyAF9M3XVw on repeat thanks to https:\/\/ruby.social\/@halfbyte\/109558803178815394 I made: This was the final expression (with lots of opportunity to improve): Use it on an empty polygon layer with an inverted polygon style and set it to refresh at a high interval (0.01s?). Or use this QGIS project (I included some [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,29,31],"tags":[],"class_list":["post-1829","post","type-post","status-publish","format-standard","hentry","category-cartography","category-gis","category-qgis"],"_links":{"self":[{"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/posts\/1829","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/comments?post=1829"}],"version-history":[{"count":3,"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/posts\/1829\/revisions"}],"predecessor-version":[{"id":1834,"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/posts\/1829\/revisions\/1834"}],"wp:attachment":[{"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/media?parent=1829"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/categories?post=1829"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hannes.enjoys.it\/blog\/wp-json\/wp\/v2\/tags?post=1829"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}