[{"element_type":"user_image","content":"https://cdn-learn.adafruit.com/user_assets/assets/000/000/895/original/mandelbrotx.jpg?1716414867","metadata":{"caption":""}},{"element_type":"text","content":"\n        \u003cp\u003eIt's no secret that I keep trying to think of new things to do with the NeoTrinkey. One day, for some reason*, I wondered if it would be possible to render the Mandelbrot set in ascii... with a NeoTrinkey.\u003c/p\u003e\n\u003cp\u003eSince the NeoTrinkey runs CircuitPython and since many, many projects are shared online in Python... it seemed reasonable to assume I could find code that would help me do this. And I did - I found a github project by \"LadyClaire\" : \u003ca href=\"https://github.com/claiire/python-mandelbrot\"\u003ehttps://github.com/claiire/python-mandelbrot\u003c/a\u003e - this seemed exactly like what I wanted.\u003c/p\u003e\n\u003cp\u003eExcept... well, I said it was \"complicated.\" The math to render the Mandelbrot set involves manipulating points on the complex number plane and Python easily does such math, CircuitPython\u0026nbsp;\u003cstrong\u003edoesn't\u003c/strong\u003e.\u003c/p\u003e\n\u003cp\u003eWhich meant I couldn't just run LadyClaire's code - I needed to write my own \u003ca title=\"github code for doing complex math in CircuitPython\" href=\"https://github.com/mrklingon/neotrinkey/blob/main/complex.py\" target=\"_blank\"\u003ecomplex.py\u003c/a\u003e module that let me do the work. Import complex.py and you get:\u003c/p\u003e\n\u003cul class=\"TreeView__UlBox-sc-4ex6b6-0 TIGQC\"\u003e\n\u003cli id=\"0absC\" class=\"PRIVATE_TreeView-item\"\u003e\u003cspan class=\"PRIVATE_TreeView-item-content-text\"\u003e\u003cspan class=\"Text-sc-17v1xeu-0 gPDEWA\"\u003eabsC - returns absolute value of a complex number\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\n\u003cli id=\"1plsC\" class=\"PRIVATE_TreeView-item\"\u003e\u003cspan class=\"PRIVATE_TreeView-item-content-text\"\u003e\u003cspan class=\"Text-sc-17v1xeu-0 gPDEWA\"\u003eplsC - adds two complex numbers\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\n\u003cli id=\"2sqrC\" class=\"PRIVATE_TreeView-item\"\u003e\u003cspan class=\"PRIVATE_TreeView-item-content-text\"\u003e\u003cspan class=\"Text-sc-17v1xeu-0 gPDEWA\"\u003esqrC - squares two complex numbers\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\n\u003cli id=\"3mltC\" class=\"PRIVATE_TreeView-item\"\u003e\u003cspan class=\"PRIVATE_TreeView-item-content-text\"\u003e\u003cspan class=\"Text-sc-17v1xeu-0 gPDEWA\"\u003emltC - multiplies a complex number by a number\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\n\u003cli id=\"4mltCC\" class=\"PRIVATE_TreeView-item\"\u003e\u003cspan class=\"PRIVATE_TreeView-item-content-text\"\u003e\u003cspan class=\"Text-sc-17v1xeu-0 gPDEWA\"\u003emltCC - multiplies two complex numbers.\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\n\u003cli class=\"PRIVATE_TreeView-item\"\u003emltI - multiplies a complex number by i\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003e\u003cspan class=\"PRIVATE_TreeView-item-content-text\"\u003e\u003cspan class=\"Text-sc-17v1xeu-0 gPDEWA\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"PRIVATE_TreeView-item-content-text\"\u003e\u003cspan class=\"Text-sc-17v1xeu-0 gPDEWA\"\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"PRIVATE_TreeView-item-content-text\"\u003e\u003cspan class=\"Text-sc-17v1xeu-0 gPDEWA\"\u003e\u0026nbsp;\u003c/span\u003e\u003c/span\u003e\u003c/p\u003e\n\u003cp\u003e\u003cspan class=\"PRIVATE_TreeView-item-content-text\"\u003e\u003cspan class=\"Text-sc-17v1xeu-0 gPDEWA\"\u003eWith those functions, I could tweak the code into\u0026nbsp;\u003ca title=\"render mandelbrot in Ascii with a NeoTrinkey!\" href=\"https://github.com/mrklingon/neotrinkey/blob/main/mandelbrotx.py\"\u003emandelbrotx.py\u003c/a\u003e - adding in some blinking lights (you need \u003ca title=\"Blinking number module\" href=\"https://github.com/mrklingon/neotrinkey/blob/main/ncount.py\" target=\"_blank\"\u003encount.py)\u003c/a\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan class=\"PRIVATE_TreeView-item-content-text\"\u003e\u003cspan class=\"Text-sc-17v1xeu-0 gPDEWA\"\u003e. The mandelbrotx.py module (which you'll rename code.py) has a variable REPL - \u003cstrong\u003eREPL=True\u003c/strong\u003e directs the output to the REPL, \u003cstrong\u003eREPL=False\u003c/strong\u003e sends it out as keystrokes. \u003c/span\u003e\u003c/span\u003e\u003c/p\u003e\n\u003cp\u003e\u003cspan class=\"PRIVATE_TreeView-item-content-text\"\u003e\u003cspan class=\"Text-sc-17v1xeu-0 gPDEWA\"\u003eWhen you run the program you need to touch pad #2 to start the rendering - you'll see lights blink as each row is calculated. When it's done you'll see the image at the top - generated not by some supercomputer... but your friendly, NeoTrinkey!\u003c/span\u003e\u003c/span\u003e\u003c/p\u003e\n\u003cp\u003e\u0026nbsp;\u003c/p\u003e\n\u003cp\u003e*Note: I know the reason, it's because I follow a Mastodon account, \u003ca href=\"mailto:mrandelbot@botsin.space\"\u003emrandelbot@botsin.space\u003c/a\u003e, which posts random images from the Mandelbrot set.\u003c/p\u003e\n      ","metadata":{}}]