{"id":1071,"date":"2021-04-11T06:55:43","date_gmt":"2021-04-11T05:55:43","guid":{"rendered":"http:\/\/www.vatland.no\/?p=1071"},"modified":"2021-06-25T06:32:27","modified_gmt":"2021-06-25T05:32:27","slug":"silly-powershell-txt-fractal-animation","status":"publish","type":"post","link":"https:\/\/www.vatland.no\/index.php\/silly-powershell-txt-fractal-animation\/","title":{"rendered":"SIlly powershell TXT Fractal animation"},"content":{"rendered":"\n<p>Found some c# code drawing a Mandelbrot fractal (I&#8217;am so sorry I cant remember where or who) and thought that would be fun to do in powershell. Ended up doing a little animation of the fractal. All done in ASCII. This will not work if you run it in ISE or VS Code  terminal.<img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"103\" data-attachment-id=\"1094\" data-permalink=\"https:\/\/www.vatland.no\/index.php\/silly-powershell-txt-fractal-animation\/fractal2\/\" data-orig-file=\"https:\/\/www.vatland.no\/wp-content\/uploads\/2021\/04\/fractal2.jpg\" data-orig-size=\"240,164\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Atle Vatland&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1624430313&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"fractal2\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/www.vatland.no\/wp-content\/uploads\/2021\/04\/fractal2.jpg\" class=\"wp-image-1094\" style=\"width: 150px;\" src=\"https:\/\/www.vatland.no\/wp-content\/uploads\/2021\/04\/fractal2.jpg\" alt=\"\"><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\nparam(\n    &#x5B;switch]$animate = $false\n)\n$buffer0 = &quot;&quot;\n$MAXCOUNT = 30 \n$ui = (get-host).ui\n$rui = $ui.rawui\n\nfunction fractal(&#x5B;float] $left, &#x5B;float] $top, &#x5B;float] $xside, &#x5B;float] $yside, &#x5B;float]$zoom) { \n    &#x5B;float]$maxx = $rui.MaxWindowSize.Width\n    &#x5B;float]$maxy = $rui.MaxWindowSize.Height\n    &#x5B;float]$xscale = $xside \/ $maxx \n    &#x5B;float]$yscale = $yside \/ $maxy \n    for (&#x5B;int]$y = 1; $y -le ($maxy - 1); $y++) { \n        for (&#x5B;int]$x = 1; $x -le ($maxx - 1); $x++) { \n            &#x5B;float]$cx = $x * $xscale + $left; \n            &#x5B;float]$cy = $y * $yscale + $top; \n            &#x5B;float]$zx = 0; \n            &#x5B;float]$zy = 0; \n            &#x5B;int]  $count = 0; \n            while (($zx * $zx + $zy * $zy -lt 4) -and ($count -lt $MAXCOUNT)) { \n                &#x5B;float]$tempx = $zx * $zx - $zy * $zy + $cx; \n                $zy = $zoom * $zx * $zy + $cy; \n                $zx = $tempx; \n                $count = $count + 1; \n            } \n            $t = $count + 65\n            $char = &#x5B;char]$t\n            $global:buffer&#x5B;$y * $maxx + $x] = $char\n        } \n    } \n}\n\n&#x5B;float] $left = -1.75 \n&#x5B;float] $top = -0.25 \n&#x5B;float] $xside = 0.25 \n&#x5B;float] $yside = 0.45 \n1..($rui.MaxWindowSize.Width * $rui.MaxWindowSize.Height) | ForEach-Object { $buffer0 += &quot;#&quot; }\n$global:buffer = $buffer0.ToCharArray()\n&#x5B;float]$loop = 5.0\nwhile ($loop -gt 1.0 ) {\n    fractal -left $left -top $top -xside $xside -yside $yside -zoom $loop\n    &#x5B;console]::SetCursorPosition(0,0) ;\n    &#x5B;string]$drawscreen = New-Object system.string($global:buffer, 0, $global:buffer.Length)\n    &#x5B;console]::SetCursorPosition(0, 0)\n    Write-Host $drawscreen\n    # $left, $top, $xside, $yside) \n    $loop -= 0.05\n    if (-not $animate) { $loop = -100.0 }\n}\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>Found some c# code drawing a Mandelbrot fractal (I&#8217;am so sorry I cant remember where or who) and thought that would be fun to do in powershell. Ended up doing a little animation of the fractal. All done in ASCII. This will not work if you run it in ISE or VS Code terminal.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[48],"tags":[102,103],"class_list":["post-1071","post","type-post","status-publish","format-standard","hentry","category-powershell","tag-4fun","tag-fractal"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":false,"jetpack-related-posts":[{"id":1146,"url":"https:\/\/www.vatland.no\/index.php\/list-nordpool-electric-prices-using-powershell\/","url_meta":{"origin":1071,"position":0},"title":"List NordPool electric prices using powershell.","author":"Atle","date":"January 10, 2022","format":false,"excerpt":"This is a small script using nordpoolgroup api to get todays electric prices for Kr.sand - Norway. This is the same API as their webpage uses. All the urls and parameters can be found using developermode in the browser. This code is only to demonstrate that it can be done.\u2026","rel":"","context":"In \"Api\"","block_context":{"text":"Api","link":"https:\/\/www.vatland.no\/index.php\/tag\/api\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1238,"url":"https:\/\/www.vatland.no\/index.php\/my-simple-keg-scale\/","url_meta":{"origin":1071,"position":1},"title":"My &#8216;simple&#8217; keg scale","author":"Atle","date":"June 2, 2024","format":false,"excerpt":"Since Plaato is retiring their Keg scale in 2024\/25 I had to find a new solution. Searching the web lead me to GitHub - Callwater\/Beerkeg-load-cell. Since I had some ESP and loadcells at my hands it was very quick to setup. Had some wood and a router in my 'workshop'\u2026","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.vatland.no\/wp-content\/uploads\/2024\/01\/w3-rotated.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.vatland.no\/wp-content\/uploads\/2024\/01\/w3-rotated.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.vatland.no\/wp-content\/uploads\/2024\/01\/w3-rotated.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.vatland.no\/wp-content\/uploads\/2024\/01\/w3-rotated.jpg?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":804,"url":"https:\/\/www.vatland.no\/index.php\/use-powershell-to-get-leakedcredentials-from-azure-using-graph\/","url_meta":{"origin":1071,"position":2},"title":"Use Powershell to get LeakedCredentials from Azure using Graph","author":"Atle","date":"November 1, 2018","format":false,"excerpt":"Leaked credentials listed from Azure using powershell and Microsoft Graph\u00a0We need one Azure AD Premium X license to get this log. Would it be nice to list all leakedcredentials using powershell?(or riskysignins or identiyriskevents). All of this could be achieved using powershell and REST api at Microsoft Graph. I have\u2026","rel":"","context":"In \"Powershell\"","block_context":{"text":"Powershell","link":"https:\/\/www.vatland.no\/index.php\/tag\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.vatland.no\/wp-content\/uploads\/2018\/11\/Leaked.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.vatland.no\/wp-content\/uploads\/2018\/11\/Leaked.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.vatland.no\/wp-content\/uploads\/2018\/11\/Leaked.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":934,"url":"https:\/\/www.vatland.no\/index.php\/simple-powershell-mru-list\/","url_meta":{"origin":1071,"position":3},"title":"Simple Powershell MRU list","author":"Atle","date":"December 23, 2019","format":false,"excerpt":"When using using my secret server powershell functions I got tired of constantly searching for secret ID's. I had to do a new search just because I could not remember the ID's. So I added some kind of MRU to my get-secretID function. This code block creates to classes mruitem\u2026","rel":"","context":"In &quot;Powershell&quot;","block_context":{"text":"Powershell","link":"https:\/\/www.vatland.no\/index.php\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":911,"url":"https:\/\/www.vatland.no\/index.php\/use-powershell-to-get-external-ip-address\/","url_meta":{"origin":1071,"position":4},"title":"Use powershell to get external IP address","author":"Atle","date":"September 23, 2019","format":false,"excerpt":"How can you get your external IP address from powershell? I use a simple script to query an external public web service. The service I'm using is hosted by ipinfo.io . I have created a small function that is placed in my powershell library. All my modules are loaded by\u2026","rel":"","context":"In &quot;Development&quot;","block_context":{"text":"Development","link":"https:\/\/www.vatland.no\/index.php\/category\/development\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":49,"url":"https:\/\/www.vatland.no\/index.php\/how-to-expand-enumerated-lists-in-powershell-ft\/","url_meta":{"origin":1071,"position":5},"title":"How to expand enumerated lists in Powershell FT.","author":"Atle","date":"February 21, 2013","format":false,"excerpt":"Have you ever seen {12,1234,34,124...} in PowerShell, and wondered \"how do I get it to display the rest\"? The builtin variable $FormatEnumerationLimit determines how many fields to display, default value is 4. To change : \u00a0$FormatEnumerationLimit=15 \u00a0","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.vatland.no\/index.php\/wp-json\/wp\/v2\/posts\/1071","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vatland.no\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.vatland.no\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.vatland.no\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vatland.no\/index.php\/wp-json\/wp\/v2\/comments?post=1071"}],"version-history":[{"count":5,"href":"https:\/\/www.vatland.no\/index.php\/wp-json\/wp\/v2\/posts\/1071\/revisions"}],"predecessor-version":[{"id":1098,"href":"https:\/\/www.vatland.no\/index.php\/wp-json\/wp\/v2\/posts\/1071\/revisions\/1098"}],"wp:attachment":[{"href":"https:\/\/www.vatland.no\/index.php\/wp-json\/wp\/v2\/media?parent=1071"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vatland.no\/index.php\/wp-json\/wp\/v2\/categories?post=1071"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vatland.no\/index.php\/wp-json\/wp\/v2\/tags?post=1071"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}