<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>mabbees</title><description>mabbees&apos; home on the web</description><link>https://mabbees.neocities.org/</link><item><title>(Reblog) Snowpeel</title><link>https://mabbees.neocities.org/posts/022-snowpeel/</link><guid isPermaLink="true">https://mabbees.neocities.org/posts/022-snowpeel/</guid><pubDate>Thu, 26 Feb 2026 01:00:00 GMT</pubDate><content:encoded>&lt;div class=&quot;h-entry  u-repost-of inline-flex space-x-4 astro-huxyrzvi&quot;&gt; &lt;div class=&quot;not-prose h-16 w-16 astro-huxyrzvi&quot;&gt; &lt;img src=&quot;/_astro/avatar.rvD9jS_v_fklQe.webp&quot; alt=&quot;&quot; width=&quot;256&quot; height=&quot;256&quot; loading=&quot;lazy&quot; class=&quot;rounded-full astro-huxyrzvi&quot; /&gt; &lt;/div&gt; &lt;article class=&quot;card astro-huxyrzvi&quot;&gt; &lt;h1 class=&quot;post-title not-prose p-name astro-huxyrzvi&quot;&gt;&lt;a href=&quot;https://www.lexaloffle.com/bbs/?uid=36705&quot; class=&quot;astro-huxyrzvi&quot;&gt;Snowpeel&lt;/a&gt;&lt;/h1&gt; &lt;p class=&quot;my-0 not-prose astro-huxyrzvi&quot;&gt; &lt;a class=&quot;u-url u-uid attribution inline-flex items-center space-x-2 astro-huxyrzvi&quot; href=&quot;https://www.lexaloffle.com/bbs/?uid=36705&quot;&gt; &lt;span class=&quot;inline-flex items-center space-x-2 opacity-80&quot;&gt;&lt;span class=&quot;text-sm italic&quot;&gt;Posted&lt;/span&gt;&lt;span class=&quot;text-sm italic&quot;&gt;&lt;time class=&quot;dt-published&quot;&gt;Feb 21, 2026&lt;/time&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;astro-huxyrzvi&quot;&gt;by&lt;/span&gt; &lt;span class=&quot;p-author h-card astro-huxyrzvi&quot;&gt; &lt;span class=&quot;p-name astro-huxyrzvi&quot;&gt;kitasuna&lt;/span&gt;&lt;data class=&quot;u-url astro-huxyrzvi&quot;&gt;&lt;/data&gt; &lt;/span&gt; &lt;/a&gt; &lt;/p&gt; &lt;div class=&quot;e-content prose astro-huxyrzvi&quot;&gt; &lt;p&gt;&lt;img src=&quot;/_astro/main_6.COAsXrhB_ZsUlCN.webp&quot; alt=&quot;&quot; width=&quot;256&quot; height=&quot;256&quot; loading=&quot;lazy&quot; /&gt; “Snowpeel” is a snowboard action game inspired by Excitebike
on the NES.&lt;/p&gt;&lt;a href=&quot;https://www.lexaloffle.com/bbs/?uid=36705&quot; target=&quot;_blank&quot;&gt;&lt;p&gt;Read more&lt;/p&gt;&lt;/a&gt; &lt;/div&gt; &lt;/article&gt; &lt;/div&gt; 
&lt;p&gt;The game formerly known as XCB is out. It’s now called Snowpeel! Go play it on the &lt;a href=&quot;https://www.lexaloffle.com/bbs/?pid=184644&quot;&gt;BBS&lt;/a&gt; or on Splore.&lt;/p&gt;
&lt;p&gt;Props to Eric (&lt;a href=&quot;https://www.lexaloffle.com/bbs/?uid=36705&quot;&gt;@kitasuna&lt;/a&gt;) on a job well done. It takes a remarkable amount of polish to go from &lt;em&gt;mostly-functional tech demo&lt;/em&gt; to &lt;em&gt;stable build&lt;/em&gt; to &lt;em&gt;actually fun to play game&lt;/em&gt;. Snowpeel is a lot of fun, and has me coming back to try to complete all the extra challenges. It’s also really cool to hear the &lt;a href=&quot;../020-xcb-music/&quot;&gt;music I wrote&lt;/a&gt; in the game. Here’s how I’ve done so far, can you beat my score?&lt;/p&gt;
&lt;figure&gt;&lt;p&gt;&lt;img src=&quot;/_astro/snowpeel%20v1.BeZ5sZc__Z15Msta.webp&quot; alt=&quot;&quot; width=&quot;384&quot; height=&quot;384&quot; loading=&quot;lazy&quot; /&gt;
&lt;/p&gt;&lt;figcaption class=&quot;text-center&quot;&gt;Snowpeel challenges&lt;/figcaption&gt;&lt;p&gt;&lt;/p&gt;&lt;/figure&gt;</content:encoded><author>Mabbees</author></item><item><title>(Reblog) RadicalSlice devlog</title><link>https://mabbees.neocities.org/posts/021-xcb-devlog/</link><guid isPermaLink="true">https://mabbees.neocities.org/posts/021-xcb-devlog/</guid><pubDate>Sun, 15 Feb 2026 01:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Eric (&lt;a href=&quot;https://www.lexaloffle.com/bbs/?uid=36705&quot;&gt;@kitasuna&lt;/a&gt;) published a new devlog video about XCB. This is the one that talks about integrating the music, so if you saw &lt;a href=&quot;/posts/020-xcb-music&quot;&gt;my last post&lt;/a&gt; and are wondering how the music and gameplay fit together, check this one out!&lt;/p&gt;
&lt;div class=&quot;h-entry  u-repost-of inline-flex space-x-4 astro-huxyrzvi&quot;&gt; &lt;div class=&quot;not-prose h-16 w-16 astro-huxyrzvi&quot;&gt; &lt;img src=&quot;/_astro/avatar.ChE1Rbq4_Z2iJCVx.webp&quot; alt=&quot;&quot; width=&quot;160&quot; height=&quot;160&quot; loading=&quot;lazy&quot; class=&quot;rounded-full astro-huxyrzvi&quot; /&gt; &lt;/div&gt; &lt;article class=&quot;card astro-huxyrzvi&quot;&gt; &lt;h1 class=&quot;post-title not-prose p-name astro-huxyrzvi&quot;&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=nXp7VSlnzec&quot; class=&quot;astro-huxyrzvi&quot;&gt;Adding Level Branching (and music!) to my Excitebike-like Snowboarding Game &lt;/a&gt;&lt;/h1&gt; &lt;p class=&quot;my-0 not-prose astro-huxyrzvi&quot;&gt; &lt;a class=&quot;u-url u-uid attribution inline-flex items-center space-x-2 astro-huxyrzvi&quot; href=&quot;https://www.youtube.com/watch?v=nXp7VSlnzec&quot;&gt; &lt;span class=&quot;inline-flex items-center space-x-2 opacity-80&quot;&gt;&lt;span class=&quot;text-sm italic&quot;&gt;Posted&lt;/span&gt;&lt;span class=&quot;text-sm italic&quot;&gt;&lt;time class=&quot;dt-published&quot;&gt;Jan 25, 2026&lt;/time&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;astro-huxyrzvi&quot;&gt;by&lt;/span&gt; &lt;span class=&quot;p-author h-card astro-huxyrzvi&quot;&gt; &lt;span class=&quot;p-name astro-huxyrzvi&quot;&gt;radicalslice&lt;/span&gt;&lt;data class=&quot;u-url astro-huxyrzvi&quot;&gt;&lt;/data&gt; &lt;/span&gt; &lt;/a&gt; &lt;/p&gt; &lt;div class=&quot;e-content prose astro-huxyrzvi&quot;&gt;  &lt;/div&gt; &lt;/article&gt; &lt;/div&gt; </content:encoded><author>Mabbees</author></item><item><title>The Music of XCB</title><link>https://mabbees.neocities.org/posts/020-xcb-music/</link><guid isPermaLink="true">https://mabbees.neocities.org/posts/020-xcb-music/</guid><pubDate>Mon, 12 Jan 2026 01:00:00 GMT</pubDate><content:encoded>&lt;p&gt;My friend Eric (&lt;a href=&quot;https://www.lexaloffle.com/bbs/?uid=36705&quot;&gt;@kitasuna&lt;/a&gt;) is working on a new PICO-8 game called XCB, and I wrote the music for it! XCB is a game about snowboarding, inspired by the mechanics in &lt;em&gt;Excitebike&lt;/em&gt;. Your goal is to dodge the rough spots on the slopes, land sweet jumps, and use your boost power to carve your way down the mountain within the time limit. You can check out his devlog channel, &lt;a href=&quot;https://www.youtube.com/@radicalslice&quot;&gt;radicalslice&lt;/a&gt;, over on YouTube.&lt;/p&gt;
&lt;p&gt;I wrote two pieces of music for XCB, &lt;em&gt;Downhill Dash&lt;/em&gt; and &lt;em&gt;Sunshine on the Mountain&lt;/em&gt;. The second one is the one used in the game, though I’m sure I’ll get a chance to reuse &lt;em&gt;Downhill Dash&lt;/em&gt; in a future game. I’ll write about both so you can see how my thought process developed over time by comparing the two.&lt;/p&gt;
&lt;h3&gt;Downhill Dash&lt;/h3&gt;
&lt;p&gt;I was thinking about racing game music when writing for XCB. It’s not not a racing game in the sense of going head-to-head against other snowboarders, but it’s still about &lt;em&gt;going fast&lt;/em&gt;. The first thing I wrote was the intro to &lt;em&gt;Downhill Dash&lt;/em&gt;, which kicks off with a &lt;em&gt;“3… 2… 1… Let’s Go!”&lt;/em&gt; kind of phrase.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;If the gameplay of XCB is &lt;strong&gt;&lt;em&gt;Excitebike&lt;/em&gt;&lt;/strong&gt;, the music is at it’s heart &lt;strong&gt;&lt;em&gt;Super Mario Kart&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;figure&gt;&lt;audio controls src=&quot;/_astro/downhill_dash.B0VgpQOE.wav&quot;&gt;&lt;/audio&gt;&lt;figcaption&gt;&lt;em&gt;Downhill Dash&lt;/em&gt;&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;For the rest of the piece, I essentially looked for as many opportunities as I could to reuse the intro motif to build out a short melody. There’s not any completely new material until the B-section. Then to bring it back to the A-section, I reused a similar “rhythm blast” figure to the one in the intro (ba-BUP ba-BUP ba-BUP!). Re-using material is a good approach to songwriting, both in terms of effort and in terms of creating memorable music.&lt;/p&gt;
&lt;h3&gt;Sunshine on the Mountain&lt;/h3&gt;
&lt;p&gt;I went in a different direction with the second song, but you can still hear some of their shared “DNA”: the groovy little bass-fills at the ends of phrases, the B-section harmony, the song form. Some key differences though, are the &lt;em&gt;intro&lt;/em&gt; and the &lt;em&gt;rhythm&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Instead of the lengthy &lt;em&gt;“3… 2… 1… Let’s Go!”&lt;/em&gt; opening, I started &lt;em&gt;Sunshine on the Mountain&lt;/em&gt; off with a short drum-fill. I think it turned out to be a better gameplay fit. Get right to the action!&lt;/p&gt;
&lt;figure&gt;&lt;audio controls src=&quot;/_astro/sunshine_on_the_mountain.BOUEIVOW.wav&quot;&gt;&lt;/audio&gt;&lt;figcaption&gt;&lt;em&gt;Sunshine on the Mountain&lt;/em&gt;&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;Rhythmically, one big difference between the two songs is that I traded the &lt;strong&gt;son-clave&lt;/strong&gt; rhythm in &lt;em&gt;Downhill Dash&lt;/em&gt; for it’s little brother, the &lt;strong&gt;half-clave&lt;/strong&gt; in &lt;em&gt;Sunshine on the Mountain&lt;/em&gt;. One way think about half-clave is that it divides the bar into three groups, where the third group is cut short (count “ONE-two-three, ONE-two-three, ONE-two”). Half-clave sounds like it’s always going &lt;em&gt;forward&lt;/em&gt;, which makes it a good fit for this kind of game.&lt;/p&gt;
&lt;figure&gt;&lt;audio controls src=&quot;/_astro/sonclave.Bke_A8gf.wav&quot;&gt;&lt;/audio&gt;&lt;audio controls src=&quot;/_astro/halfclave.DlPKK3iI.wav&quot;&gt;&lt;/audio&gt;&lt;figcaption&gt;&lt;strong&gt;Son-clave&lt;/strong&gt; (top) versus &lt;strong&gt;half-clave&lt;/strong&gt; (bottom)&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h3&gt;Dynamic music&lt;/h3&gt;
&lt;p&gt;When I write for video games, I always look for opportunities to make the music react to what’s happening in the game. There are a couple such spots in XCB.&lt;/p&gt;
&lt;figure&gt;&lt;audio controls src=&quot;/_astro/sunshine_boost.By25GflV.wav&quot;&gt;&lt;/audio&gt;&lt;figcaption&gt;boost mode&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;I added a layer of arpeggiated chords over the main song for when the player &lt;em&gt;boosts&lt;/em&gt; that I think can best be described as “chirpy”. It’s a little tough to layer tracks like this in PICO-8 while keeping the everything synced, but the cool frame stop effect makes for a good opportunity to get the start of the music to sync with the start of the boost.&lt;/p&gt;
&lt;figure&gt;&lt;audio controls src=&quot;/_astro/sunshine_end.Dh1YM8IQ.wav&quot;&gt;&lt;/audio&gt;&lt;figcaption&gt;Victory fanfare&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;I also wrote a little fanfare for when you reach the end of a run. It’s got an “extra” bar in it to build anticipation for the final note. I’m not sure what Eric has in mind for scoring yet, but I thought this would make room for the results screen to dramatically “tally up” your final score.&lt;/p&gt;</content:encoded><author>Mabbees</author></item><item><title>What is a Spritesheet?</title><link>https://mabbees.neocities.org/posts/019-what-is-a-spritesheet/</link><guid isPermaLink="true">https://mabbees.neocities.org/posts/019-what-is-a-spritesheet/</guid><pubDate>Fri, 21 Nov 2025 01:00:00 GMT</pubDate><content:encoded>&lt;p&gt;In my &lt;a href=&quot;./018-spritesheet-tricks&quot;&gt;last post&lt;/a&gt; I talked about some tricks for fitting more sprites into your spritesheet, but I didn’t go into a lot of context about what that even &lt;em&gt;means&lt;/em&gt;. In this post, I want to cover what a spritesheet is and why you might use one. I’ll start by explaining a bit about how game engines work.&lt;/p&gt;
&lt;h3&gt;How do game engines work with images?&lt;/h3&gt;
&lt;p&gt;Here’s a frame of a game. It’s made up of a bunch of smaller images, called &lt;em&gt;sprites&lt;/em&gt; in gamedev lingo, that get layered together to produce the final image.&lt;/p&gt;
&lt;figure&gt;&lt;p&gt;&lt;img src=&quot;/_astro/jelpi_0.CHf2c2TE_GNwGJ.webp&quot; alt=&quot;&quot; width=&quot;384&quot; height=&quot;384&quot; loading=&quot;lazy&quot; /&gt;
&lt;/p&gt;&lt;figcaption class=&quot;text-center&quot;&gt;A screenshot of the game &lt;em&gt;Jelpi&lt;/em&gt;.&lt;/figcaption&gt;&lt;p&gt;&lt;/p&gt;&lt;/figure&gt;
&lt;p&gt;There are a few different ways game engines could handle drawing a frame like this. One way is to load a bunch of separate image files — one for each sprite — and draw each one in its corresponding position in the frame. Indeed, many game engines support this workflow, and if I were inventing a game engine from first-principles, this is probably what I’d come up with.&lt;/p&gt;
&lt;figure&gt;&lt;p&gt;&lt;img src=&quot;/_astro/frame-from-files.gF2tb1ag_9GWAB.webp&quot; alt=&quot;&quot; width=&quot;592&quot; height=&quot;304&quot; loading=&quot;lazy&quot; /&gt;&lt;/p&gt;&lt;figcaption class=&quot;text-center&quot;&gt;&lt;p&gt;A frame drawn from individual files&lt;/p&gt;&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;But there’s another way! You could combine all of your sprites into a single image, called a &lt;em&gt;spritesheet&lt;/em&gt;, then draw a frame by clipping out rectangular pieces of it and pasting them into place.&lt;/p&gt;
&lt;figure&gt;&lt;p&gt;&lt;img src=&quot;/_astro/frame-from-spritesheets.CIuLDNrr_Z2bsrts.webp&quot; alt=&quot;&quot; width=&quot;592&quot; height=&quot;304&quot; loading=&quot;lazy&quot; /&gt;&lt;/p&gt;&lt;figcaption class=&quot;text-center&quot;&gt;&lt;p&gt;A frame drawn from a single spritesheet&lt;/p&gt;&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;So, there you have it. &lt;strong&gt;A spritesheet is an image that contains a collection of individual sprites!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;But that raises an important question… &lt;em&gt;why?&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;Why use spritesheets?&lt;/h3&gt;
&lt;p&gt;Depending on your game engine or target platform, the answer could be “that’s just how it works”. For example, PICO-8 doesn’t support loading and drawing separate image files. There’s only one spritesheet that has to contain everything, and its size is limited to 128x128 pixels (this is why &lt;em&gt;Spooky Stylin’&lt;/em&gt; needed to use some clever &lt;a href=&quot;./018-spritesheet-tricks&quot;&gt;Spritesheet Tricks&lt;/a&gt;). A lot of “retro” consoles had similar constraints as well due to limitations of the technology.&lt;/p&gt;
&lt;p&gt;But spritesheets aren’t &lt;em&gt;just&lt;/em&gt; a retro thing. A lot of modern games still use spritesheets or &lt;em&gt;texture atlases&lt;/em&gt;, a similar technique of combining multiple 3d-model textures into one image. Why is that?&lt;/p&gt;
&lt;p&gt;One reason is performance. It can be much more efficient to load a batch of images all in one go, rather than one at a time, both in terms of getting the images from your filesystem into your game, and in terms of getting the images from your game onto the graphics card where they’ll be ready to be drawn to the screen. That is to say, spritesheets are a useful &lt;em&gt;optimization&lt;/em&gt; technique.&lt;/p&gt;
&lt;p&gt;Another reason is that, depending on your workflow, spritesheets can also be more &lt;em&gt;convenient&lt;/em&gt; to work with. A lot of animation programs have a way to export frames as a spritesheet — some can also export useful metadata about how many frames there are, which frame each animation starts on, etc. This means you can export a single file instead of a bunch of individual frames.&lt;/p&gt;
&lt;h3&gt;It’s not all-or-nothing&lt;/h3&gt;
&lt;p&gt;So far, I’ve talked about two extremes—one spritesheet for everything, or one file per sprite—but in practice, that’s quite rare. Lots of games use an approach that’s somewhere in between. For example, each character could be on a separate spritesheet, the tileset used for the level could be another spritesheet, and rarely used or one-off sprites could be loaded as individual images. Splitting up sprites like this is a good middle-ground. That way, your game engine has to load fewer images in total compared to the one-image-per-sprite approach, and you can also keep your assets organized more easily compared to the one-spritesheet-for-all approach.&lt;/p&gt;</content:encoded><author>Mabbees</author></item><item><title>Spritesheet Tricks</title><link>https://mabbees.neocities.org/posts/018-spritesheet-tricks/</link><guid isPermaLink="true">https://mabbees.neocities.org/posts/018-spritesheet-tricks/</guid><description>How to fit more sprites into your spritesheet</description><pubDate>Sat, 15 Nov 2025 06:16:00 GMT</pubDate><content:encoded>&lt;p&gt;Last month, CJ and I published a new dressup game called &lt;a href=&quot;https://illuminesce.itch.io/spooky-stylin&quot;&gt;Spooky Stylin’&lt;/a&gt; as part of our arcade bundle &lt;a href=&quot;https://illuminesce.itch.io/tomodachi-8in1&quot;&gt;Tomodachi 8-in-1&lt;/a&gt;. In this post, I want to talk about some of the programming techniques we used.&lt;/p&gt;
&lt;p&gt;PICO-8 has limited spritesheet space, but &lt;a href=&quot;https://illuminesce.itch.io/spooky-stylin&quot;&gt;Spooky Stylin’&lt;/a&gt; needs to be able to draw a lot of different outfits. So how did we get our images to fit? We used a technique to cram two spritesheets into one! Of course, this space-saving doesn’t come for free. In order to make it work, we need to carefully manage our color usage.&lt;/p&gt;
&lt;h3&gt;The plan&lt;/h3&gt;
&lt;div class=&quot;_container_xdi3q_1&quot;&gt;&lt;/div&gt;
&lt;p&gt;At a high level, here’s the technique. There are two major steps, encoding and decoding.&lt;/p&gt;
&lt;h5&gt;&lt;strong&gt;Encoding&lt;/strong&gt;&lt;/h5&gt;
&lt;ol&gt;
&lt;li&gt;Recolor layer 1 to use only colors 0, 1, 2, and 3 (the “column” colors)&lt;/li&gt;
&lt;li&gt;Recolor layer 2 to use only colors 0, 4, 8, and 12 (the “row” colors)&lt;/li&gt;
&lt;li&gt;Combine the layers, using the palette grid as a look-up-table to determine the combined color&lt;/li&gt;
&lt;/ol&gt;
&lt;h5&gt;&lt;strong&gt;Decoding&lt;/strong&gt;&lt;/h5&gt;
&lt;ol&gt;
&lt;li&gt;Use only the column colors to recover layer 1&lt;/li&gt;
&lt;li&gt;Use only the row colors to recover layer 2&lt;/li&gt;
&lt;li&gt;Remap the row/column colors to the original image colors&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Arranging the 16 colors into a grid to shows how to encode and decode colors. The columns tell you the color of the first image, the rows tell you the color of the second image.&lt;/p&gt;
&lt;figure&gt;&lt;p&gt;&lt;img src=&quot;/_astro/color-encoding.BMyodWYu_1ITcsb.webp&quot; alt=&quot;&quot; width=&quot;384&quot; height=&quot;384&quot; loading=&quot;lazy&quot; /&gt;&lt;/p&gt;&lt;figcaption class=&quot;text-center&quot;&gt;&lt;p&gt;Using a color grid as a look-up-table to combine two colors.&lt;/p&gt;&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;One thing to notice is that step one restricts each layer to using only 4 colors. That’s the tradeoff we make.&lt;/p&gt;
&lt;h3&gt;A &lt;strong&gt;bit&lt;/strong&gt; of theory&lt;/h3&gt;
&lt;p&gt;PICO-8 stores color using 4 bits per pixel&lt;sup&gt;&lt;a href=&quot;#user-content-fn-1&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;. In &lt;em&gt;Spooky Stylin’&lt;/em&gt;, we restricted ourselves to using only 3 colors per clothing item, plus a transparent background color, making 4 colors in total. That means we only need 2 bits per pixel, leaving 2 bits left over for a second 4-color spritesheet!&lt;/p&gt;
&lt;figure&gt;&lt;p&gt;&lt;img src=&quot;/_astro/spritesheet-combined.DE0N6vFT_13l5rE.webp&quot; alt=&quot;&quot; width=&quot;384&quot; height=&quot;384&quot; loading=&quot;lazy&quot; /&gt;&lt;/p&gt;&lt;figcaption class=&quot;text-center&quot;&gt;&lt;p&gt;Two spritesheets layered into one. It looks messy and chaotic.&lt;/p&gt;&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;This looks really messy, but the important part is that all the data we need is there, ready to be decoded.&lt;/p&gt;
&lt;h3&gt;Implementation details&lt;/h3&gt;
&lt;p&gt;If you believe the math then it’s &lt;em&gt;possible&lt;/em&gt; to fit two 4-color spritesheets into one 16-color spritesheet, but making it happen in code still poses some challenges.&lt;/p&gt;
&lt;h4&gt;Encoding&lt;/h4&gt;
&lt;p&gt;The first problem we needed to solve is combining our two spritesheets so we can store them as one in the final cart. I initially assumed this would require looping through all the pixels and doing a bunch of bitwise math, but it turns out there’s a faster way!&lt;/p&gt;
&lt;p&gt;We can use a feature of the PICO-8 graphics system called &lt;em&gt;bit masking&lt;/em&gt;. With bit masking, when we draw to the screen, PICO-8 won’t overwrite the screen color directly. Instead, it will &lt;em&gt;combine&lt;/em&gt; the color we’re drawing and the color that’s already on the screen. It’s like changing the layer &lt;em&gt;blend-mode&lt;/em&gt; in Photoshop&lt;sup&gt;&lt;a href=&quot;#user-content-fn-2&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;. The final color is determined using a formula:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;dst_color = (dst_color &amp;amp; ~write_mask) | (src_color &amp;amp; write_mask &amp;amp; read_mask)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The mask values come from an 8-bit number that we can specify by &lt;code&gt;poke&lt;/code&gt;-ing it into memory (the first 4 bits we poke define the &lt;code&gt;read_mask&lt;/code&gt;, and the next 4 bits define the &lt;code&gt;write_mask&lt;/code&gt;). For example, setting the mask to &lt;code&gt;0b00110011&lt;/code&gt; will make our draw calls affect only the lowest 2 bits.&lt;/p&gt;
&lt;p&gt;We used this to combine two layers into one like so:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;clear the screen&lt;/li&gt;
&lt;li&gt;draw layer 1 using only the lowest 2 bits&lt;/li&gt;
&lt;li&gt;draw layer 2 using only the highest 2 bits&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;astro-code astro-code-themes min-light night-owl&quot; style=&quot;color:#24292eff&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;cls&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;-- draw the first layer using the &quot;column colors&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;poke&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0x5f5e&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;b00110011)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;({[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;draw_layer_1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;-- draw the second layer using the &quot;row colors&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;poke&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0x5f5e&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;b11001100)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;({[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;draw_layer_2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;Decoding&lt;/h4&gt;
&lt;p&gt;Once the data is written, we still need to be able to decode it. Getting back the original image requires &lt;em&gt;multiple passes&lt;/em&gt; of recoloring: one pass to get the layer from the combined image, and a second pass to restore the original colors. Taking it one step further, in &lt;em&gt;Spooky Stylin’&lt;/em&gt; we let the player pick the character’s skin tone and hair color, which sometimes adds a third recoloring.&lt;/p&gt;
&lt;p&gt;Conceptually, my approach to managing all of this is to define each recoloring as a function. Then I can use &lt;em&gt;function composition&lt;/em&gt; as the glue to stick multiple recoloring passes together. I go into more depth on this topic in my post on &lt;a href=&quot;../007-palette-swaps&quot;&gt;Palette Swaps&lt;/a&gt;. In code it could look something like this:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes min-light night-owl&quot; style=&quot;color:#24292eff&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;-- define palettes for separating layers&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;-- and recoloring to original colors&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;lyr_1_pal&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; tbl_to_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;({&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;		[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;		0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;		0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;		0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;lyr_2_pal&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; tbl_to_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;({&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;		[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;		1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;		2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;		3&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;skin_pal&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; tbl_to_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;({&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;green_skin_pal&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; tbl_to_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;({&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;  [&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;11&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;  [&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;  [&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;hat_1_pal&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; tbl_to_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;({&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;-- draw the base character from layer 2 using green skin&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;pal_to_tbl&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;chain&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;({&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;lyr_2_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;skin_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;green_skin_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;})))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;draw_character&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;-- draw hat 1 from layer 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;pal_to_tbl&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;chain&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;({&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;lyr_1_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;hat_1_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;})))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;draw_hat_1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Acknowledgements and Inspiration&lt;/h3&gt;
&lt;p&gt;I wrote my own implementation, but I’m certainly not the first to try out this technique in PICO-8. I first learned about it from the post &lt;a href=&quot;https://8bit-caaz.tumblr.com/post/171458093376/layering-sprite-data&quot;&gt;Layering Sprite Data&lt;/a&gt; by &lt;a href=&quot;https://8bit-caaz.tumblr.com/&quot;&gt;8bit Caaz&lt;/a&gt;. I also found these &lt;a href=&quot;https://www.lexaloffle.com/bbs/?tid=39713&quot;&gt;two&lt;/a&gt; &lt;a href=&quot;https://www.lexaloffle.com/bbs/?tid=39726&quot;&gt;BBS&lt;/a&gt; posts by &lt;a href=&quot;https://www.lexaloffle.com/bbs/?uid=45932&quot;&gt;Two_Owls&lt;/a&gt; helpful.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Footnotes&lt;/h2&gt;
&lt;section class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Quick binary refresher (or primer): a &lt;em&gt;bit&lt;/em&gt; holds one of 2 values (either 0 or 1). An &lt;em&gt;n&lt;/em&gt;-bit number can differentiate between 2&lt;sup&gt;&lt;em&gt;n&lt;/em&gt;&lt;/sup&gt; values. Equivalently, a choice between &lt;em&gt;n&lt;/em&gt; values can be stored in one log&lt;sub&gt;2&lt;/sub&gt;(&lt;em&gt;n&lt;/em&gt;) bit number. A 16-color image uses log&lt;sub&gt;2&lt;/sub&gt;(16) = &lt;strong&gt;4 bits per pixel&lt;/strong&gt;. &lt;a href=&quot;#user-content-fnref-1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;I haven’t actually used Photoshop in years, but I think it’s still the most widely-recognized image editing software that has layers. I would have felt a little too hipster saying “it’s like layer blend-modes in Procreate”. &lt;a href=&quot;#user-content-fnref-2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;</content:encoded><author>Mabbees</author></item><item><title>On verbal shutdown</title><link>https://mabbees.neocities.org/posts/017-verbal-shutdown/</link><guid isPermaLink="true">https://mabbees.neocities.org/posts/017-verbal-shutdown/</guid><pubDate>Fri, 19 Sep 2025 06:16:00 GMT</pubDate><content:encoded>&lt;p&gt;I want to tell you something very personal about myself today. I’m someone who experiences &lt;strong&gt;verbal shutdown&lt;/strong&gt;&lt;sup&gt;&lt;a href=&quot;#user-content-fn-1&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;p&gt;It usually happens in situations with loud noises, crowds, bright lights, or other distractions, and it sometimes results in well-meaning people around me wanting to know “what’s wrong?” or “how can I help?“. The frustrating thing is that in asking, they’re implicitly seeking a verbal response, &lt;em&gt;which is exactly what I’m NOT able to provide&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;I’m writing this post for exactly those people. I completely understand wanting to help and not knowing how, and I understand feeling anxious about it. The thing is, I’m not sure I have an answer. If I ever figure that out, maybe I’ll make a separate post about it. For now, the best I can do is try to put some words to what verbal shutdown feels like — a task I’ve found fiendishly difficult due to the aforementioned &lt;em&gt;verbal shutdown&lt;/em&gt; (and because, in my experience, shutdown affects my ability to &lt;em&gt;think&lt;/em&gt; and therefore &lt;em&gt;write&lt;/em&gt; words not just to &lt;em&gt;say&lt;/em&gt; them). I want to describe it to you the best way I know how: through analogies. None of them are perfect, but together they form a more complete picture.&lt;/p&gt;
&lt;h2&gt;Analogy 1&lt;/h2&gt;
&lt;p&gt;I’m sure you’ve had the experience of having a word “on tip of your tongue”. You know there is a word that you want to say — a word that would perfectly fit the situation — but you can’t quite remember it. If you speak multiple languages, you’ve probably experienced the version of this where you can remember the word for something… just not in the language you’re currently trying to speak.&lt;/p&gt;
&lt;p&gt;When tip-of-the-tongue moments happen once in a while, you can shrug them off. When they happen multiple times in a single conversation, you might start to feel like something’s wrong. When they happen multiple times &lt;em&gt;per sentence&lt;/em&gt;, well… you’ll probably feel like giving up entirely.&lt;/p&gt;
&lt;p&gt;That’s what verbal shutdown feels like to me. It’s not necessarily about being unable to speak in an &lt;strong&gt;absolute&lt;/strong&gt; sense, but it is a feeling of being unable to communicate, often alongside intense feelings of failure. The pain of verbal shutdown is that I know, in general, I have the ability to communicate with words—sometimes, I daresay I even manage to be &lt;em&gt;fucking eloquent&lt;/em&gt;—but in this moment, I am utterly failing at a task most people take for granted. It sucks.&lt;/p&gt;
&lt;h2&gt;Analogy 2&lt;/h2&gt;
&lt;p&gt;You know you need to say &lt;em&gt;something&lt;/em&gt;, but your mind is suddenly blank… and yet at the same time, no! Not blank, not blank at all! It’s a crowded room full of people all talking over each other all at once. In one way, you’re at a loss for words, in another way, it’s the exact opposite. You have &lt;em&gt;plenty&lt;/em&gt; of words. Too many, in fact — so many, you can’t organize any of them into a coherent thought.&lt;/p&gt;
&lt;p&gt;You think, maybe if you concentrate on a single voice, you’ll be able to make out a coherent sentence. You give it a try, focusing in on the loudest person. Turns out, the loudest person in the room is also an asshole. You don’t want to say &lt;em&gt;that&lt;/em&gt;. You try focusing in on someone else—anyone else—but the loud asshole keeps talking, and it’s hard to make out other voices. You decide to say nothing.&lt;/p&gt;
&lt;h2&gt;Analogy 3&lt;/h2&gt;
&lt;p&gt;Have you ever played the game Taboo? It’s a party game where you try to get your teammates to guess a secret word by telling them clues. You’re not allowed to say the word directly, and to add to the challenge there’s a list of related words you can’t say either. To enforce the rules, one person from the other team acts as &lt;em&gt;referee&lt;/em&gt;, ready to press a buzzer if you screw up by saying a banned word. With the right group of people and the right mindset, it can be a really fun game! It can also be anxiety-provoking.&lt;/p&gt;
&lt;p&gt;Experiencing verbal shutdown feels like I’m playing the game Taboo, but with real-life stakes. Taboo meets Squid Game. It feels like there are gaps in my vocabulary, and there are things I desperately need to communicate in spite of them. If I’m successful, well… it doesn’t feel like &lt;em&gt;winning&lt;/em&gt;. My reward is that my doctor &lt;em&gt;doesn’t&lt;/em&gt; misdiagnose me, my partner &lt;em&gt;doesn’t&lt;/em&gt; get mad at me, or my waiter &lt;em&gt;doesn’t&lt;/em&gt; get my order wrong. Speaking of…&lt;/p&gt;
&lt;h2&gt;Analogy 4&lt;/h2&gt;
&lt;p&gt;My next analogy is ordering at a restaurant. The main thing I want to get across in this analogy is that I don’t experience verbal ability and verbal shutdown as a binary (“can speak” or “can’t speak”). They feel like a continuous gradient, but with discrete &lt;em&gt;tipping points&lt;/em&gt;. One tipping point is when my ability to form words is hampered enough that &lt;em&gt;not talking&lt;/em&gt; starts to seem more attractive than continuing to talk and risking having a frustrating miscommunication or saying something I regret. Unfortunately, even past this tipping point there can be immense social pressure to keep talking &lt;em&gt;anyway&lt;/em&gt; (not to mention consequences for breaking these expectations). It’s situations where I have to aggressively &lt;strong&gt;mask&lt;/strong&gt; that bring me to the second tipping point: where forming coherent words is essentially impossible.&lt;/p&gt;
&lt;p&gt;Finding something to eat sometimes comes with varying degrees of challenge. Analagously, here are what different degrees of verbal ability feel like to me:&lt;/p&gt;
&lt;h6&gt;Very verbal - you can say exactly what you mean to say.&lt;/h6&gt;
&lt;p&gt;You’re at your favorite restaurant. You’ve tried everything on the menu and you love all of it. You’re good friends with the cook and feel comfortable ordering off-menu.&lt;/p&gt;
&lt;h6&gt;Mostly verbal - you can say most of what you want to say. You sometimes need to “talk around” points where you don’t have the right words.&lt;/h6&gt;
&lt;p&gt;You’re at a restaurant you’ve been to before. You know the menu pretty well. They don’t have root beer floats like you wanted, but you can still order a root beer and a scoop of ice cream. Close enough!&lt;/p&gt;
&lt;h6&gt;Somewhat verbal - you can communicate the broad message you want to get across, but not without effort.&lt;/h6&gt;
&lt;p&gt;You’re at a restaurant you’ve been to once or twice. You don’t know the menu very well. You find a few things that look okay but aren’t quite your speed. Maybe the kitchen can hold the mustard. Maybe you can pick off the mushrooms… that kind of thing.&lt;/p&gt;
&lt;h6&gt;Partial verbal shutdown - you can’t access many parts of your vocabulary. The things you &lt;em&gt;can&lt;/em&gt; say aren’t what you mean. Face it, you’d probably be better off keeping your mouth shut.&lt;/h6&gt;
&lt;p&gt;You’re at a restaurant you’ve never been to before. The menu has stains on it, and some items are scribbled out. Most of the things you can read look unappetizing, but one seems okay. You try ordering that only to be told it’s sold out. You give up on eating something you actually enjoy. If you’re lucky, maybe you can stomach the stinky tofu without vomiting. At least it’s calories.&lt;/p&gt;
&lt;h6&gt;Total verbal shutdown - you can’t access &lt;em&gt;most&lt;/em&gt; of your vocabulary. You’re just about physically incapable of forming a full sentence. Most words you try to say come out garbled and incomprehensible.&lt;/h6&gt;
&lt;p&gt;You’re at a restaurant you’ve never been to with a cuisine you’ve never tried. You can’t read anything on the menu at all. Most of the items have an ominous number of spicy pepper icons next to them. You try to pronounce the name one of the dishes you &lt;em&gt;hope&lt;/em&gt; is safe, but the waiter just shoots you a nasty look. You sheepishly gesture at what you were trying to order. They impatiently tell you the thing you were pointing to was a &lt;em&gt;side dish&lt;/em&gt; and you need to order an entrée for it to come with. You break down in tears.&lt;/p&gt;
&lt;h2&gt;Closing thoughts&lt;/h2&gt;
&lt;p&gt;If you have people in your life who struggle with communication, I hope I’ve given you some framing to empathize with their struggles. If you’re someone who can relate strongly to the analogies I’ve described here, I hope I’ve given you ways of explaining them to people in your life. And if you relate to these descriptions, but you’ve never had a label to describe it, consider that &lt;em&gt;verbal shutdown&lt;/em&gt; might be what you’re experiencing. I hope you can find some comfort in knowing you’re not alone.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Footnotes&lt;/h2&gt;
&lt;section class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;I’m using the phrase “verbal shutdown” as opposed to “nonverbal” or “nonspeaking”. The former is temporary, whereas the latter can be long-term or lifelong. I make the distinction because I don’t want to give the false impression that because &lt;em&gt;I&lt;/em&gt; can speak (most of the time), someone who is &lt;em&gt;nonverbal&lt;/em&gt; must therefore be able to “snap out of it” and is selfishly &lt;em&gt;choosing&lt;/em&gt; not to speak. &lt;a href=&quot;#user-content-fnref-1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;</content:encoded><author>Mabbees</author></item><item><title>PICOJAM 2025</title><link>https://mabbees.neocities.org/posts/016-picojam-2025/</link><guid isPermaLink="true">https://mabbees.neocities.org/posts/016-picojam-2025/</guid><pubDate>Fri, 15 Aug 2025 06:16:00 GMT</pubDate><content:encoded>&lt;p&gt;I had a great time at &lt;a href=&quot;https://itch.io/jam/picojam-2025&quot;&gt;PICOJAM 2025&lt;/a&gt; last weekend! A bunch of other game developers and I got together at &lt;a href=&quot;https://www.picopicocafe.com/&quot;&gt;Pico Pico Cafe&lt;/a&gt; to make games based on the theme ‘祭り’ (festival) or ‘溶ける’ (melt).&lt;/p&gt;
&lt;p&gt;A lot of the folks at the jam were already seasoned game-jammers and programmers, and were confident enough in their skills that they split into smaller teams. As a result, it had a much different vibe than, for example, &lt;a href=&quot;/010-global-game-jam&quot;&gt;Global Game Jam&lt;/a&gt;, which tends towards larger team sizes with a mix of veterans and newbies.&lt;/p&gt;
&lt;p&gt;I mostly focused on writing music, which worked out well both because I enjoy it and because the small team sizes meant there were a lot of games in need of music. I contributed to 3 games over the course of the jam.&lt;/p&gt;
&lt;h3&gt;Taiko Terror&lt;/h3&gt;
&lt;figure&gt;&lt;a href=&quot;https://ugokuware.itch.io/taiko-terror&quot; target=&quot;_blank&quot;&gt;&lt;p&gt;&lt;img src=&quot;/_astro/taiko_terror_0.gQ8jWzTc_Z2pXnt6.webp&quot; alt=&quot;&quot; width=&quot;384&quot; height=&quot;384&quot; loading=&quot;lazy&quot; /&gt;&lt;/p&gt;&lt;/a&gt;&lt;figcaption class=&quot;text-center&quot;&gt;&lt;p&gt;Taiko Terror - by ugokoware, CJ, and mabbees&lt;/p&gt;&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;A game about a devious little beetle. Dash to avoid getting hit by the taiko drummer’s &lt;em&gt;bachi&lt;/em&gt;, but gain points by taunting them. The closer you can get without being hit, the higher your score. You can play &lt;a href=&quot;https://ugokuware.itch.io/taiko-terror&quot;&gt;Taiko Terror&lt;/a&gt; on itch.&lt;/p&gt;
&lt;p&gt;I wrote a short taiko rhythm and shamisen melody for this game. It was fun playing around with the PICO-8 sound effects editor to get a satisfyingly boom-y taiko drum sound. I later used the same taiko sound-effect as a custom instrument in the other two songs as well.&lt;/p&gt;
&lt;p&gt;Writing the melody was definitely the hardest part for me. I used the 平調子 (hirajoshi) scale&lt;sup&gt;&lt;a href=&quot;#user-content-fn-1&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;, which I haven’t composed with before. It’s got a very distinctive sound that doesn’t map well to anything in western music theory. I think it turned out well.&lt;/p&gt;
&lt;figure&gt;&lt;audio controls src=&quot;/_astro/taiko_taikai.Bmr-euTG.wav&quot;&gt;&lt;/audio&gt;&lt;figcaption&gt;Taiko Taikai&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h3&gt;Omatsuri TD&lt;/h3&gt;
&lt;figure&gt;&lt;a href=&quot;https://uchuzine.itch.io/omatsuri-td&quot; target=&quot;_blank&quot;&gt;&lt;p&gt;&lt;img src=&quot;/_astro/omatsuri_td.C6uF8cCH_2cuYls.webp&quot; alt=&quot;&quot; width=&quot;384&quot; height=&quot;384&quot; loading=&quot;lazy&quot; /&gt;&lt;/p&gt;&lt;/a&gt;&lt;figcaption class=&quot;text-center&quot;&gt;&lt;p&gt;Omatsuri TD - by uchuzine, npckc, and mabbees&lt;/p&gt;&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;A wholesome reskin of the tower-defense genre. Rather than fighting off invaders, the goal of this game is to build out the festival grounds so that everyone can find something to enjoy before they leave. You can play &lt;a href=&quot;https://uchuzine.itch.io/omatsuri-td&quot;&gt;Omatsuri TD&lt;/a&gt; on itch.&lt;/p&gt;
&lt;p&gt;I started out by writing 8 bars or so to get the general festival vibe, and only expanded it into a longer song after hearing it in the context of the game. The tower defense levels lasted long enough that it started to feel repetitive. My main idea was to write something that sounds like a &lt;a href=&quot;https://en.wikipedia.org/wiki/Obon#Bon_Odori&quot;&gt;&lt;em&gt;Bon Odori&lt;/em&gt;&lt;/a&gt; folk song. I included a clapping rhythm that I remember from going to my local Bon Odori in Koenji (it’s the part that goes “ONE AND &lt;small&gt;two&lt;/small&gt; AND …”).&lt;/p&gt;
&lt;figure&gt;&lt;audio controls src=&quot;/_astro/odorimashou.Dkd5IjSs.wav&quot;&gt;&lt;/audio&gt;&lt;figcaption&gt;Odorimasho (Let’s Dance)&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h3&gt;Picogori&lt;/h3&gt;
&lt;figure&gt;&lt;a href=&quot;https://npckc.itch.io/picogori-2025&quot; target=&quot;_blank&quot;&gt;&lt;p&gt;&lt;img src=&quot;/_astro/picogoori_0.UMey58If_Z28JXzh.webp&quot; alt=&quot;&quot; width=&quot;384&quot; height=&quot;384&quot; loading=&quot;lazy&quot; /&gt;&lt;/p&gt;&lt;/a&gt;&lt;figcaption class=&quot;text-center&quot;&gt;&lt;p&gt;Picogori - by davemakes, npckc, and mabbees&lt;/p&gt;&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;A cozy little game about making shaved ice for animals at the festival. Each animal has different syrup preferences — you’ll have to try different combinations to find out what they like. No scoring, time-limit, or ending, just endless shaved ice.&lt;/p&gt;
&lt;figure&gt;&lt;audio controls src=&quot;/_astro/kakigoori_march.k8Q16pDQ.wav&quot;&gt;&lt;/audio&gt;&lt;figcaption&gt;Kakigoori March&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;This song came together the fastest, probably because I was already warmed up from the previous two and had already figured out some techinques for sounding like a 祭り.&lt;/p&gt;
&lt;h2&gt;Closing thoughts&lt;/h2&gt;
&lt;p&gt;One of my favorite moments from the jam was hearing npckc humming along with the songs I wrote. I generally aim for “hummability” when writing songs, so it was very gratifying. I think it makes songs more memorable when there’s some melody or hook that you can hum along to — even if it’s only for part of the song. It also helps me keep track of them more easily.&lt;/p&gt;
&lt;p&gt;I had a couple additional songwriting goals in mind for this jam as well. One was to capture the summer festival vibe, another was to develop a unique identity for each one. I’m really happy with the results. Each song sounds like it belongs at a 祭り, and each one sounds distinct.&lt;/p&gt;
&lt;p&gt;I’m really proud of all the games we made in such a short time at the jam, and I liked seeing everyone’s creativity on display. I hope it becomes a yearly tradition!&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Footnotes&lt;/h2&gt;
&lt;section class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Here’s what the 平調子 scale sounds like by itself. &lt;audio controls src=&quot;/_astro/hirajoshi.Cjp8rMEN.wav&quot;&gt;&lt;/audio&gt; …at least, I think it’s the 平調子 scale. The &lt;a href=&quot;https://en.wikipedia.org/wiki/Hiraj%C5%8Dshi_scale&quot;&gt;Wikipedia page&lt;/a&gt; for it didn’t clear up my confusion. &lt;a href=&quot;#user-content-fnref-1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;</content:encoded><author>Mabbees</author></item><item><title>Happy birthday, Illuminesce!</title><link>https://mabbees.neocities.org/posts/015-happy-birthday-illuminesce/</link><guid isPermaLink="true">https://mabbees.neocities.org/posts/015-happy-birthday-illuminesce/</guid><pubDate>Mon, 04 Aug 2025 06:16:00 GMT</pubDate><content:encoded>&lt;figure&gt;&lt;div class=&quot;_container_xdi3q_1&quot;&gt;&lt;/div&gt;&lt;figcaption&gt;&lt;p&gt;The card reads &lt;em&gt;happy birthday&lt;/em&gt;. Underneath that, a bunch of tiny dinosaurs
move into position to spell out &lt;em&gt;CJ&lt;/em&gt;.&lt;/p&gt;&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h3&gt;Happy birthday, Illuminesce!&lt;/h3&gt;
&lt;p&gt;I made a little card for &lt;a href=&quot;https://illuminesce.net/&quot;&gt;illuminesce&lt;/a&gt; for their birthday a few days ago. I was inspired by something &lt;a href=&quot;https://bsky.app/profile/lexaloffle.bsky.social&quot;&gt;Zep&lt;/a&gt; made for &lt;a href=&quot;https://bsky.app/profile/lexaloffle.bsky.social/post/3lqvz47cgjs2n&quot;&gt;Picotachi 74&lt;/a&gt;.&lt;/p&gt;</content:encoded><author>Mabbees</author></item><item><title>Lessons From Oz</title><link>https://mabbees.neocities.org/posts/014-lessons-from-oz/</link><guid isPermaLink="true">https://mabbees.neocities.org/posts/014-lessons-from-oz/</guid><description>A look at allegory through the ages</description><pubDate>Fri, 18 Apr 2025 13:49:29 GMT</pubDate><content:encoded>&lt;p&gt;(Minor spoilers ahead for both &lt;em&gt;The Wonderful Wizard of Oz&lt;/em&gt; and &lt;em&gt;Wicked&lt;/em&gt;)&lt;/p&gt;
&lt;p&gt;I recently went to see the movie adaptation of &lt;em&gt;Wicked&lt;/em&gt; (part 1) with a friend who had never seen &lt;em&gt;The Wizard of Oz&lt;/em&gt; in any of its incarnations. I was surprised to hear she didn’t know the original story, given how influential it has been to American media. It’s inspired stage adaptations, movies, TV shows, and lots of parodies — maybe because it’s so imaginative, maybe because so few &lt;em&gt;other&lt;/em&gt; stories since have been allowed to enter the public domain.&lt;/p&gt;
&lt;p&gt;In any case, it gave her friends and I a chance to fill her in on the references she missed, and sparked some conversations about themes in the movie. It also gave me an excuse to talk about the theory that &lt;em&gt;The Wonderful Wizard of Oz&lt;/em&gt;, written by L. Frank Baum in 1900, was a political allegory.&lt;/p&gt;
&lt;h3&gt;”The Wizard of Oz” and fiat currency&lt;/h3&gt;
&lt;p&gt;A theory put forth by Henry Littlefield, and discussed further in &lt;em&gt;The Historian’s Wizard of Oz&lt;/em&gt; by Ranjit S. Dighe, is that the book &lt;em&gt;The Wonderful Wizard of Oz&lt;/em&gt; is an allegory for the gold and silver monetary standards. For what it’s worth, current scholarly consensus is that the parallels are more likely coincidence than intentional inclusions by Baum, but in any case, here’s the summary:&lt;/p&gt;
&lt;p&gt;Dorothy is transported to the land of Oz (ounces?), where she dons the &lt;strong&gt;silver&lt;/strong&gt; shoes—the iconic &lt;em&gt;ruby&lt;/em&gt; slippers weren’t introduced until the technicolor film—and journeys down the yellow brick road (symbolizing &lt;strong&gt;gold&lt;/strong&gt;) making new friends along the way. This brings her to the Emerald city (symbolizing &lt;strong&gt;greenback paper money&lt;/strong&gt;), a supposed utopia that turns out to be hollow and fake. She meets the Wizard and finds that he is a fraud. In the end, the magic that brings her home was with her all along — the silver shoes.&lt;/p&gt;
&lt;p&gt;For context, when the book came out in 1900, the &lt;a href=&quot;https://en.wikipedia.org/wiki/Coinage_Act_of_1873&quot;&gt;Coinage Act of 1873&lt;/a&gt; would have still been on a lot of Americans’ minds. Prior to this act, Americans who owned gold &lt;strong&gt;or&lt;/strong&gt; silver bullion could get their metals struck into dollar coins by the US mint. The Coinage Act phased out the silver dollar coin, effectively giving preference to gold and ending “&lt;a href=&quot;https://en.wikipedia.org/wiki/Bimetallism&quot;&gt;bimetallism&lt;/a&gt;” in the US. 1873 also marked a year of economic depression and financial crisis now known to historians as the &lt;a href=&quot;https://en.wikipedia.org/wiki/Panic_of_1873&quot;&gt;Panic of 1873&lt;/a&gt; though at the time it was known as the &lt;em&gt;Great Depression&lt;/em&gt; (the 1929 financial crash would later steal that title). The deflation that resulted from the new gold standard, and the losses felt by miners and investors who found their silver suddenly drop in value both contributed to the depression, though they were not the only factors.&lt;/p&gt;
&lt;p&gt;Knowing this political context gives some weight to the idea that turn-of-the-century Americans, following the “cyclone” of economic disruption, might have seen bringing back the silver standard as a “magic spell” to return them to more familiar times.&lt;/p&gt;
&lt;h3&gt;”The Wizard of Oz” and fascism&lt;/h3&gt;
&lt;p&gt;The more modern telling, &lt;em&gt;Wicked&lt;/em&gt;, originally a book written by Gregory Maguire in 1995 and later adapted for Broadway by Stephen Schwartz in 2003, is also political allegory. In this case, we don’t need to speculate or theorize. &lt;em&gt;Wicked&lt;/em&gt; clearly warns against the dangers of fascism, and wears that fact proudly on its sleeve.&lt;/p&gt;
&lt;p&gt;A charismatic Wizard blames animals for all the problems in Oz, rather than address their root causes. His and Madame Morrible’s propaganda urges the people follow a black-and-white morality of “goodness” and “wickedness” marked by an extreme intolerance of otherness. We see this play out in the intimidation tactics and systemic violence levied against Professor Dillamond, the Cowardly Lion, and the other animals. We see it in the way Elphaba is ostracized and vilified both for looking different and for daring to stand up for the oppressed.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Wicked&lt;/em&gt; the Broadway show hit the stage amid the Iraq War, and used the opportunity to take some well-aimed shots at the Bush administration. We the audience are invited to draw parallels between the Wizard’s anti-animal crusade and the Bush administration’s scapegoating of Muslims. Broadway’s Glinda pointedly refers to Nessarose’s death as a “regime change”, mirroring the president’s rhetoric in overthrowing Saddam Hussein.&lt;/p&gt;
&lt;h3&gt;Lessons for 2025&lt;/h3&gt;
&lt;p&gt;I’m far from the first to have noticed how relevant the political allegory in &lt;em&gt;Wicked&lt;/em&gt; is to the Trump administration’s fascist machinations. One only need replace “talking animals” with “immigrants and trans people” in the narrative to see it. What’s strange to me is how relevant the theorized allegory about money from &lt;em&gt;The Wizard of Oz&lt;/em&gt; seems. Trump is causing tremendous damage to the economy, to global trade, and to faith in the dollar. His cryptocurrency ventures, built on hype, speculation, and hucksterism, seem to ask that we pay no attention to the man behind the curtain, but perhaps the magic we need is in the financial system we’ve had all along.&lt;/p&gt;
&lt;p&gt;Allegories can’t predict the future, nor should we expect works of fiction to contain the answers we need to present-day crises, but they can clue us into historical sentiments we might have otherwise missed.&lt;/p&gt;</content:encoded><author>Mabbees</author></item><item><title>Tracker Tips</title><link>https://mabbees.neocities.org/posts/013-tracker-tips/</link><guid isPermaLink="true">https://mabbees.neocities.org/posts/013-tracker-tips/</guid><description>Tips on making better sounding music in the PICO-8 tracker</description><pubDate>Fri, 21 Mar 2025 07:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I wrote a lot of songs in PICO-8 over the last two years. Not long enough to call myself an expert, but long enough to no longer call myself a beginner. I thought I’d take some time to write down some of the things I’ve learned—techniques that have helped me get the kind of sound I want out of the PICO-8 tracker.&lt;/p&gt;
&lt;p&gt;These techniques are not broad enough to qualify as general songwriting advice, but not specific enough to act as a tutorial for someone still figuring out how to use the tools. But if you’re in a similar part of your learning journey to me, I hope you find them useful to you as well.&lt;/p&gt;
&lt;h3&gt;Brighter waveforms need less volume&lt;/h3&gt;
&lt;p&gt;If you open up the SFX editor and start writing music without changing anything, you’ll get samples using the triangle wave at volume 5. I think this is a &lt;em&gt;little&lt;/em&gt; louder than you need for background music, but in general it sounds fine. Switch over to the square or sawtooth wave though, and at least to my ears, it sounds &lt;em&gt;&lt;strong&gt;really harsh&lt;/strong&gt;&lt;/em&gt;. So much so that for my first couple songs, I shied away from using those waveforms at all!&lt;/p&gt;
&lt;p&gt;Square and sawtooth waves can sound musical though, they just need a little less volume. Those waveforms have a lot stronger &lt;em&gt;overtones&lt;/em&gt; than the smoother waves, so you don’t need to set them as loud for them to stand out. Try a base volume of 3 or 4, and reserve 5, 6 and 7 for when you really want to accent a note.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/_astro/square-wave-volume.B_NtwdmE_1P4dc3.webp&quot; alt=&quot;A part written using the square wave and volume set to 3&quot; width=&quot;384&quot; height=&quot;384&quot; loading=&quot;lazy&quot; /&gt;&lt;/p&gt;
&lt;h3&gt;For drum parts, vary pitch instead of volume&lt;/h3&gt;
&lt;p&gt;I like to use the noise waveform to write drum parts, but I’ve found that getting &lt;em&gt;good&lt;/em&gt; sounding drums is tough. One difficulty is that there are only 7 levels of volume. I often wish I could set the volume to something in between (for example) 2 and 3 in order to get nice phrasing without the part getting too loud or too quiet.&lt;/p&gt;
&lt;p&gt;Luckily, there’s a way to get more variation: change the pitch instead of volume, or combine both approaches. Higher pitches &lt;em&gt;seem&lt;/em&gt; louder even when they’re at the same volume, so you can increase the pitch to create subtle accents in your drum parts without raising the volume too much.&lt;/p&gt;
&lt;figure&gt;&lt;div class=&quot;flex&quot;&gt;&lt;span&gt;&lt;img src=&quot;/_astro/drums-volume-articulation.Bd8BYIjr_Z1XCK8.webp&quot; alt=&quot;&quot; width=&quot;384&quot; height=&quot;384&quot; loading=&quot;lazy&quot; /&gt;&lt;/span&gt;&lt;span&gt;&lt;img src=&quot;/_astro/drums-pitch-articulation.b2yLeNwq_ZQ5qBe.webp&quot; alt=&quot;&quot; width=&quot;384&quot; height=&quot;384&quot; loading=&quot;lazy&quot; /&gt;&lt;/span&gt;&lt;/div&gt;&lt;figcaption class=&quot;text-center&quot;&gt;&lt;p&gt;&lt;em&gt;Left: a drum track with no pitch variation.&lt;/em&gt; &lt;br /&gt;
&lt;em&gt;Right: a drum track that varies the pitch to add accents to some beats.&lt;/em&gt;&lt;/p&gt;&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h3&gt;Use the slide effect for smooth volume changes&lt;/h3&gt;
&lt;p&gt;The &lt;em&gt;slide&lt;/em&gt; effect is a nice way to add some articulation to a melody. You can use it to “bend” between pitches. I used to think that was all it was for, but it turns out it’s also very useful for making notes change volume smoothly. In fact, that’s probably the &lt;strong&gt;primary&lt;/strong&gt; way I use it now.&lt;/p&gt;
&lt;p&gt;I like to vary the volume on notes starting with a louder attack on the first sample, then dropping to a lower volume for the sustain — like an ADSR envelope on a synthesizer. The sudden change in volume is quite noticeable, especially at slower tempos. It can sound like the note is being re-struck. The &lt;em&gt;slide&lt;/em&gt; effect smooths out the volume change.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/_astro/volume-changes.CKf5xb3L_2nS7Cs.webp&quot; alt=&quot;A track with notes that slide across volume changes smoothly&quot; width=&quot;384&quot; height=&quot;384&quot; loading=&quot;lazy&quot; /&gt;&lt;/p&gt;
&lt;h3&gt;Use the vibrato in the middle of notes&lt;/h3&gt;
&lt;p&gt;When I use the vibrato effect, I like to add it to the &lt;em&gt;middle&lt;/em&gt; of a note. That is, let the first sample or two play with no vibrato, and let the last sample or two play with no vibrato. To me, it sounds more musical that way. It matches the way a singer would sing it.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/_astro/vibrato.CKjfFPhl_8eGBi.webp&quot; alt=&quot;A long note with vibrato applied to the middle&quot; width=&quot;384&quot; height=&quot;384&quot; loading=&quot;lazy&quot; /&gt;&lt;/p&gt;
&lt;h3&gt;Use the detune filter for power chords and octaves&lt;/h3&gt;
&lt;p&gt;The detune filter has some cool effects depending on what waveform you’re using. I like to use it with the triangle wave to get power chords. In general, it’s a good way to make harmonies and accompaniment parts sound fuller without using multiple sound channels.&lt;/p&gt;
&lt;p&gt;Here are what the different waveforms sound like to me with the detune filter applied:&lt;/p&gt;
&lt;h4&gt;Detune level 1&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;triangle - sounds like note + fourth below&lt;/li&gt;
&lt;li&gt;tilted saw - sounds like a chorus effect&lt;/li&gt;
&lt;li&gt;sawtooth - sounds like a chorus effect&lt;/li&gt;
&lt;li&gt;square - sounds like a chorus effect&lt;/li&gt;
&lt;li&gt;pulse - sounds like a chorus effect&lt;/li&gt;
&lt;li&gt;organ - sounds like a chorus effect&lt;/li&gt;
&lt;li&gt;noise - still sounds like noise&lt;/li&gt;
&lt;li&gt;phaser - sounds out of tune (almost like the note + semitone above)&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Detune level 2&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;triangle - sounds like note + fifth above&lt;/li&gt;
&lt;li&gt;tilted saw - sounds like note + octave above&lt;/li&gt;
&lt;li&gt;saw - sounds like note + octave above&lt;/li&gt;
&lt;li&gt;square - sounds like note + octave above&lt;/li&gt;
&lt;li&gt;pulse - sounds like note + octave above&lt;/li&gt;
&lt;li&gt;organ - sounds like note + octave above&lt;/li&gt;
&lt;li&gt;noise - still sounds like noise&lt;/li&gt;
&lt;li&gt;phaser - sounds like note + octave above&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When I first started writing music in PICO-8, the limit of 4 sound channels felt &lt;em&gt;very&lt;/em&gt; constraining. I’m used to writing music for piano or guitar, where playing chords with 4, 5, 6 or more notes is normal, so it was a happy discovery when I found out that I could get some basic harmony out of a single channel by detuning it.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/_astro/power-chords.Dd47uvgI_4qoT2.webp&quot; alt=&quot;A track using triangle wave and detune to sound like power chords&quot; width=&quot;384&quot; height=&quot;384&quot; loading=&quot;lazy&quot; /&gt;&lt;/p&gt;</content:encoded><author>Mabbees</author></item><item><title>Business Cart</title><link>https://mabbees.neocities.org/posts/012-business-cart/</link><guid isPermaLink="true">https://mabbees.neocities.org/posts/012-business-cart/</guid><description>Digital business cards in PICO-8</description><pubDate>Thu, 13 Mar 2025 06:16:00 GMT</pubDate><content:encoded>&lt;div class=&quot;_container_xdi3q_1&quot;&gt;&lt;/div&gt;
&lt;p&gt;Back in 2019, I attended a fair share of professional conferences and networking events. I brought a couple small problems to mind. One was that I often forgot to bring my business cards — or if I did remember to bring them, I ran out of the small supply I had with me. Another was that exchanging cards always felt wasteful to me. All these cards changing hands were eventually destined for the recycling bin or landfill.&lt;/p&gt;
&lt;p&gt;I had the idea to build a small website where you could upload a photo of your business card, or design a digital one. The site would generate a QR code that other people could scan to “collect” your card (and hopefully also consider adopting the habit of using digital cards). I never got that far along into building it before 2020 came crashing in, and suddenly the mild annoyance I had around networking events was not such a priority for me. For what it’s worth, I suspect the culture of 名刺交換 (business card exchange) is too strong here in Japan for much to have come of it anyway.&lt;/p&gt;
&lt;p&gt;But the idea of a digital business card still appeals to me. So I built one in PICO-8. I’m calling it my &lt;em&gt;business cart&lt;/em&gt;! Hopefully people find it quirky and memorable.&lt;/p&gt;
&lt;h2&gt;Make your own&lt;/h2&gt;
&lt;p&gt;Will &lt;em&gt;business carts&lt;/em&gt; catch on? Who knows. Probably not. But if it seems cool to you, you can make one too. Here’s how:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Download the cart below to your PICO-8 folder&lt;/li&gt;
&lt;li&gt;Open the cart - &lt;code&gt;load business-cart.p8.png&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Draw your logo and on contact details on the spritesheet&lt;/li&gt;
&lt;li&gt;Save it&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;That’s it!&lt;/p&gt;
&lt;p&gt;I’m licensing it under &lt;a href=&quot;https://creativecommons.org/licenses/by/4.0/&quot;&gt;CC BY 4.0&lt;/a&gt;.&lt;/p&gt;
&lt;img src=&quot;/_astro/business-cart.p8.CAmW5Kuo.png&quot; alt=&quot;PICO-8 Cartridge&quot; /&gt;</content:encoded><author>Mabbees</author></item><item><title>Pride flags</title><link>https://mabbees.neocities.org/posts/011-pride-flags/</link><guid isPermaLink="true">https://mabbees.neocities.org/posts/011-pride-flags/</guid><description>I made some pride flags in PICO-8</description><pubDate>Thu, 20 Feb 2025 06:22:00 GMT</pubDate><content:encoded>&lt;div class=&quot;_container_xdi3q_1&quot;&gt;&lt;/div&gt;
&lt;p&gt;I made some pride flags in PICO-8. You can cycle between rainbow, trans and non-binary pride flags with the ❎ button.&lt;/p&gt;
&lt;p&gt;This was my first time making a &lt;a href=&quot;https://www.lexaloffle.com/bbs/superblog.php?mode=gifs&amp;amp;postcarts=1&quot;&gt;postcart&lt;/a&gt;! It was fun, and I learned some new code-size optimization tricks from &lt;a href=&quot;https://demoman.net/?a=optimizing-for-tweetcarts&quot;&gt;demo-man&lt;/a&gt;. My first implementation already wasn’t &lt;em&gt;too&lt;/em&gt; far off from the 300 character limit, so it didn’t take much extra fiddling. Maybe next time I’ll be more ambitious and try to make a postcart game.&lt;/p&gt;
&lt;img src=&quot;/_astro/pride_flags.p8.CteD2Kx-.png&quot; alt=&quot;PICO-8 Cartridge&quot; /&gt;</content:encoded><author>Mabbees</author></item><item><title>Global Game Jam 2025</title><link>https://mabbees.neocities.org/posts/010-global-game-jam/</link><guid isPermaLink="true">https://mabbees.neocities.org/posts/010-global-game-jam/</guid><description>Over the weekend I helped organize, and participated in Global Game Jam.</description><pubDate>Wed, 29 Jan 2025 06:10:53 GMT</pubDate><content:encoded>&lt;p&gt;Over the weekend I helped organize, and participated in Global Game Jam over at &lt;a href=&quot;ggjtokyo.neocities.org&quot;&gt;Let’s Games! Tokyo&lt;/a&gt;. I helped make a game called ‘What is it Like to be a Bubble’. I’m proud of my team, and also what the other teams at our site accomplished. You can see all the games on our site’s demo video:&lt;/p&gt;

&lt;h3&gt;Team Peaceful Bubble&lt;/h3&gt;
&lt;p&gt;This year, I was glad to find other PICO-8 enthusiasts at the site to team up with. Josh (&lt;a href=&quot;https://www.lexaloffle.com/bbs/?uid=88392&quot;&gt;acedio&lt;/a&gt;) and Shane worked on a PICO-8 game at last year’s Global Game Jam. Eric (&lt;a href=&quot;https://www.lexaloffle.com/bbs/?uid=36705&quot;&gt;kitasuna&lt;/a&gt;) has made PICO-8 games at the last 2 Global Game Jams, and runs a vlog about some of his PICO-8 experiments. Douglas was new to PICO-8, but picked it up quickly.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/_astro/IMG_3124.De1dk8j-_Z1Yje0G.webp&quot; alt=&quot;Demoing our game titled &apos;What is it Like to be a Bubble&apos; on the projector in front of an audience&quot; width=&quot;1248&quot; height=&quot;936&quot; loading=&quot;lazy&quot; /&gt;&lt;/p&gt;
&lt;p&gt;I’m certainly not new to PICO-8, but what was new for me was working in PICO-8 &lt;em&gt;with a team&lt;/em&gt;. Other PICO-8 games I’ve made have been with at most one other person. Other game jams where I’ve worked in a team of 3+ people have used Unity or Unreal.&lt;/p&gt;
&lt;p&gt;I was pleasantly surprised by how smoothly our team of 5 was able to collaborate without stepping on each others’ toes. There were a &lt;em&gt;few&lt;/em&gt; times we had merge conflicts in the spritesheet, which were somewhat hard to resolve, but thankfully that didn’t take up too much of our time. It was more common to have merge conflicts in the code, and those were straightforward to resolve.&lt;/p&gt;
&lt;h3&gt;Making a Shmup&lt;/h3&gt;
&lt;p&gt;This year, it felt like the hardest part of the jam was deciding on what to make. The theme for the jam was ‘bubble’, which is thankfully open to plenty interpretations, but is also less helpful in picking a direction.&lt;/p&gt;
&lt;p&gt;We settled on making a shmup, as both a genre that our team members had an interest in, and something that could be reasonably executed on within 48 hours. It may be more accurate to say a shmup &lt;em&gt;inspired&lt;/em&gt; game. Our game has no shooting, which reduced our development scope, and seemed to fit the theme more nicely. We wanted our player to feel floaty and fragile like a bubble, not powerful like a fighter ship.&lt;/p&gt;
&lt;p&gt;Without the shooting part, our gameplay focuses on dodging bullets, and collecting pickups. I think it worked out well. Even with just those mechanics we were able to make an interesting challenge for players. Bullets and pickups working together to create push/pull tension.&lt;/p&gt;
&lt;h3&gt;We’re in Space&lt;/h3&gt;
&lt;p&gt;I made a lot of “scattered” contributions to the game: the credits page, the label image, sound effects, and little bits of code. But the part I’m most proud of is the music. Within a couple of hours of posting our game on itch.io, I already got a very flattering comment about the games’ music.&lt;/p&gt;
&lt;p&gt;I wrote two short songs for the game: Liftoff and Zero-G. The first one has a pensive mood. The second is more going for dance-club vibes — something the player can get into flow to. I think both sound pretty space-y.&lt;/p&gt;
&lt;figure&gt;&lt;audio controls src=&quot;/_astro/liftoff.DkxFjxLC.wav&quot;&gt;&lt;/audio&gt;&lt;figcaption&gt;Liftoff&lt;/figcaption&gt;&lt;/figure&gt;
&lt;figure&gt;&lt;audio controls src=&quot;/_astro/zero-g.D8CB2H9K.wav&quot;&gt;&lt;/audio&gt;&lt;figcaption&gt;Zero G&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;One of the challenges of writing Zero-G was trying to mimic the way sidechain compression sounds using the sfx tracker. It turns out that writing the drum part the way I would notate it on staff paper ends up sounding wrong to me. Instead I shifted the drum part back by a 32nd note, so it starts &lt;em&gt;just before&lt;/em&gt; the beat. This means there’s a &lt;em&gt;slight&lt;/em&gt; rhythm shift between the A section and B section of the song that sounds a little bit wonky to me, but I’m not sure how noticeable it is.&lt;/p&gt;
&lt;h3&gt;Check it out&lt;/h3&gt;
&lt;p&gt;You can check out our game, ‘What is it Like to be a Bubble’ over on itch.io. It’s playable right in your browser.&lt;/p&gt;
&lt;a href=&quot;https://mabbees.itch.io/what-is-it-like-to-be-a-bubble&quot;&gt;&lt;p&gt;What is it Like to be a Bubble by mabbees, Acedio, Douglas Driving,
radicalslice&lt;/p&gt;&lt;/a&gt;</content:encoded><author>Mabbees</author></item><item><title>Christmas concert</title><link>https://mabbees.neocities.org/posts/009-christmas-concert/</link><guid isPermaLink="true">https://mabbees.neocities.org/posts/009-christmas-concert/</guid><pubDate>Thu, 23 Jan 2025 01:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Last month, I played a Christmas concert in a band with my friend Honami and some of her other musician friends. It was a lot of fun, and I daresay went pretty well for my first time playing guitar on stage (I’ve played concerts before, but I started playing guitar &lt;em&gt;relatively&lt;/em&gt; recently compared to piano, which I feel more comfortable on).&lt;/p&gt;
&lt;p&gt;I’m looking forward to playing more live music with them. We’re planning another gig for sometime this year.&lt;/p&gt;
&lt;p&gt;CJ wrote nice things about me over on their blog! Big thanks to them, both for their support, and for recording the show — I’m linking their videos below.&lt;/p&gt;
&lt;div class=&quot;h-entry  u-repost-of inline-flex space-x-4 astro-huxyrzvi&quot;&gt; &lt;div class=&quot;not-prose h-16 w-16 astro-huxyrzvi&quot;&gt; &lt;img src=&quot;/_astro/avatar.CzXVRD59_ZGlOMn.webp&quot; alt=&quot;&quot; width=&quot;128&quot; height=&quot;128&quot; loading=&quot;lazy&quot; class=&quot;rounded-full astro-huxyrzvi&quot; /&gt; &lt;/div&gt; &lt;article class=&quot;card astro-huxyrzvi&quot;&gt; &lt;h1 class=&quot;post-title not-prose p-name astro-huxyrzvi&quot;&gt;&lt;a href=&quot;https://illuminesce.net/blog/posts/2025-01-19-Mabbees-Concert/&quot; class=&quot;astro-huxyrzvi&quot;&gt;social media types&lt;/a&gt;&lt;/h1&gt; &lt;p class=&quot;my-0 not-prose astro-huxyrzvi&quot;&gt; &lt;a class=&quot;u-url u-uid attribution inline-flex items-center space-x-2 astro-huxyrzvi&quot; href=&quot;https://illuminesce.net/blog/posts/2025-01-19-Mabbees-Concert/&quot;&gt; &lt;span class=&quot;inline-flex items-center space-x-2 opacity-80&quot;&gt;&lt;span class=&quot;text-sm italic&quot;&gt;Posted&lt;/span&gt;&lt;span class=&quot;text-sm italic&quot;&gt;&lt;time class=&quot;dt-published&quot;&gt;Dec 5, 2024&lt;/time&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;astro-huxyrzvi&quot;&gt;by&lt;/span&gt; &lt;span class=&quot;p-author h-card astro-huxyrzvi&quot;&gt; &lt;span class=&quot;p-name astro-huxyrzvi&quot;&gt;illuminesce&lt;/span&gt;&lt;data class=&quot;u-url astro-huxyrzvi&quot;&gt;&lt;/data&gt; &lt;/span&gt; &lt;/a&gt; &lt;/p&gt; &lt;div class=&quot;e-content prose astro-huxyrzvi&quot;&gt; &lt;blockquote&gt;
&lt;p&gt;As some of you may already know, my co-dev and partner mabbees is very into music. He plays the cello, piano, and guitar, and has a great voice. He did the PICO-8 music for our game, Tomodachi 8in1.
&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;https://mabbees.bandcamp.com/&quot;&gt;Check out the albums on Bandcamp.&lt;/a&gt;
&lt;br /&gt;&lt;br /&gt;I am biased, but multiple sources close to me say that he’s quite talented. He even did a talk on musical modes for Nerd Nite Tokyo! It’s one of the most-watched videos on &lt;a href=&quot;https://youtu.be/TPb9KejlTR4?si=sHivYOcobUwFgkcZ&quot;&gt;Nerd Nite Tokyo’s YouTube&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;&lt;a href=&quot;https://illuminesce.net/blog/posts/2025-01-19-Mabbees-Concert/&quot; target=&quot;_blank&quot;&gt;&lt;p&gt;Read more&lt;/p&gt;&lt;/a&gt; &lt;/div&gt; &lt;/article&gt; &lt;/div&gt; 
&lt;h3&gt;All I Want for Christmas is You&lt;/h3&gt;
&lt;div&gt;&lt;/div&gt;
&lt;h3&gt;Santa Claus is Coming to Town&lt;/h3&gt;
&lt;div&gt;&lt;/div&gt;
&lt;h3&gt;ステキなホリディー (Suteki na Holiday)&lt;/h3&gt;
&lt;div&gt;&lt;/div&gt;
&lt;h3&gt;Jingle Bell Rock&lt;/h3&gt;
&lt;div&gt;&lt;/div&gt;
</content:encoded><author>Mabbees</author></item><item><title>(Reblog) Fortune Telling and Creative Pursuits</title><link>https://mabbees.neocities.org/posts/008-fortune-teller/</link><guid isPermaLink="true">https://mabbees.neocities.org/posts/008-fortune-teller/</guid><pubDate>Tue, 07 Jan 2025 09:26:56 GMT</pubDate><content:encoded>&lt;p&gt;My friend &lt;a href=&quot;https://perroquadrado.neocities.org/&quot;&gt;perroquadrado&lt;/a&gt; shared a project they made over the break — a short fortune-telling web experience. They even wrote background music for it!&lt;/p&gt;
&lt;div class=&quot;h-entry  u-repost-of inline-flex space-x-4 astro-huxyrzvi&quot;&gt; &lt;div class=&quot;not-prose h-16 w-16 astro-huxyrzvi&quot;&gt; &lt;img src=&quot;/_astro/avatar.BI_cdY0p_Z1o2kk0.webp&quot; alt=&quot;&quot; width=&quot;128&quot; height=&quot;128&quot; loading=&quot;lazy&quot; class=&quot;rounded-full astro-huxyrzvi&quot; /&gt; &lt;/div&gt; &lt;article class=&quot;card astro-huxyrzvi&quot;&gt; &lt;h1 class=&quot;post-title not-prose p-name astro-huxyrzvi&quot;&gt;&lt;a href=&quot;https://perroquadrado.neocities.org/blog/january-07-2025-fortunes&quot; class=&quot;astro-huxyrzvi&quot;&gt;Fortune Telling and Creative Pursuits&lt;/a&gt;&lt;/h1&gt; &lt;p class=&quot;my-0 not-prose astro-huxyrzvi&quot;&gt; &lt;a class=&quot;u-url u-uid attribution inline-flex items-center space-x-2 astro-huxyrzvi&quot; href=&quot;https://perroquadrado.neocities.org/blog/january-07-2025-fortunes&quot;&gt; &lt;span class=&quot;inline-flex items-center space-x-2 opacity-80&quot;&gt;&lt;span class=&quot;text-sm italic&quot;&gt;Posted&lt;/span&gt;&lt;span class=&quot;text-sm italic&quot;&gt;&lt;time class=&quot;dt-published&quot;&gt;Jan 7, 2025&lt;/time&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;astro-huxyrzvi&quot;&gt;by&lt;/span&gt; &lt;span class=&quot;p-author h-card astro-huxyrzvi&quot;&gt; &lt;span class=&quot;p-name astro-huxyrzvi&quot;&gt;perroquadrado&lt;/span&gt;&lt;data class=&quot;u-url astro-huxyrzvi&quot;&gt;&lt;/data&gt; &lt;/span&gt; &lt;/a&gt; &lt;/p&gt; &lt;div class=&quot;e-content prose astro-huxyrzvi&quot;&gt; &lt;blockquote&gt;
&lt;p&gt;…I’ve been spending the past six months or so trying to build a healthier relationship with technology.
I hate a lot of what’s going on in the industry these days, but I decided that it’s not really healthy that
it’s gotten so bad that I hate being at my laptop or on my phone at all. I’m not going to let tech companies
take something I used to enjoy tinkering with, and there’s a ton of great tech out there that lets me feel
like I’m in control of my life again. Customising my own internet radio station player was so much fun that
it gave me the push I needed to come back and consider this idea again.&lt;/p&gt;
&lt;/blockquote&gt;&lt;a href=&quot;https://perroquadrado.neocities.org/blog/january-07-2025-fortunes&quot; target=&quot;_blank&quot;&gt;&lt;p&gt;Read more&lt;/p&gt;&lt;/a&gt; &lt;/div&gt; &lt;/article&gt; &lt;/div&gt; 
&lt;p&gt;I can relate a lot to their struggles with technology and the tech industry, and trying to regain a sense of fun with it. I think that’s part of what has drawn me to PICO-8. It feels fun to tinker with. It feels like a system that I can master. Although it’s closed-source, it still feels like it isn’t trying to hide anything from me.&lt;/p&gt;
&lt;p&gt;I’m also trying to make smaller projects that I can actually finish. Hopefully I’ll be able to put out more games and things this year.&lt;/p&gt;
&lt;p&gt;Anyway, you can check out the full post above, or head on over to the &lt;a href=&quot;https://perroquadrado.neocities.org/experiments/horoscopes/star-stuck&quot;&gt;Star Stuck Fortune Teller&lt;/a&gt; to get your horoscope. Here’s mine from today:&lt;/p&gt;
&lt;figure&gt;&lt;p&gt;&lt;img src=&quot;/_astro/starstuck.CrwMalkX_13K8dc.webp&quot; alt=&quot;The star stuck fortune teller booth. A dog in glasses and a comfy sweater
reads your fortune from a crystal ball&quot; width=&quot;418&quot; height=&quot;857&quot; loading=&quot;lazy&quot; /&gt;&lt;/p&gt;&lt;figcaption&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;The star stuck fortune teller booth. A dog in glasses and a comfy sweater
reads your fortune from a crystal ball. The horoscope reads:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;A major change is on the menu for love — a really extravagant one. You’ve
been carefully watched by the powers that be for some time now, and
they’re well pleased with what they saw. Congrats.&lt;/p&gt;&lt;/blockquote&gt;&lt;/figcaption&gt;&lt;/figure&gt;</content:encoded><author>Mabbees</author></item><item><title>Palette swaps</title><link>https://mabbees.neocities.org/posts/007-palette-swaps/</link><guid isPermaLink="true">https://mabbees.neocities.org/posts/007-palette-swaps/</guid><description>Composable palette swaps in PICO-8</description><pubDate>Tue, 10 Dec 2024 09:45:26 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;/_astro/recolored_buns.I3dcoA3h_1wx0QA.webp&quot; alt=&quot;Nine pixel-art rabbits in a grid. Each rabbit has a different fur color or pattern&quot; width=&quot;384&quot; height=&quot;384&quot; loading=&quot;lazy&quot; /&gt;&lt;/p&gt;
&lt;p&gt;In a &lt;a href=&quot;/posts/005-suspend-your-draw-calls/&quot;&gt;previous post&lt;/a&gt;, I talked about drawing effects and how they can be chained together using function composition. Composing functions is one of my all-time favorite techniques, and there’s another neat application of it in PICO-8: palette swaps.&lt;/p&gt;
&lt;h2&gt;What is a palette swap?&lt;/h2&gt;
&lt;p&gt;The concept of a palette swap is drawing something with a different set of colors. It’s a good way to get more mileage out of your PICO-8 sprites. There are a bunch of things you can do with palette swapping&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;create variations on a character&lt;/li&gt;
&lt;li&gt;make simple looping animations&lt;/li&gt;
&lt;li&gt;fade in or out of a scene&lt;/li&gt;
&lt;li&gt;simulate day/night cycles&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;But what does this mean for us as programmers? How do we &lt;em&gt;represent&lt;/em&gt; the concept in code?&lt;/p&gt;
&lt;h3&gt;Palette swaps as tables&lt;/h3&gt;
&lt;p&gt;One choice of representation is to use a look-up table. Keys in the table tell what color we want to remap, their corresponding values tell what color to map it to. Pretty straightforward. A nice benefit of using tables is that we can pass them directly to the PICO-8 &lt;code&gt;pal&lt;/code&gt; function.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes min-light night-owl&quot; style=&quot;color:#24292eff&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;-- a palette defined as a look-up table&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;my_palette&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 9&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;my_palette&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Palette swaps as functions&lt;/h3&gt;
&lt;p&gt;There’s another reasonable choice of representation, and that’s to use a function. At its core, a look-up table is hardly any different from a function. Both are ways of defining a relation, it’s just that a table maps keys to values, whereas a function maps inputs to outputs.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes min-light night-owl&quot; style=&quot;color:#24292eff&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;-- a palette defined as a lua function&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; my_palette&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	if&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 5&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; then&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; return&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	if&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 6&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; then&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; return&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	if&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 7&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; then&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; return&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 9&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	return&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;-- apply a remapping to the&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;-- draw palette&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; set_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	for&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;		pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;set_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;my_palette&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It’s often more convenient to define palettes as look-up tables than functions. Functions do have other upsides, which we’ll get to in a minute.&lt;/p&gt;
&lt;p&gt;Luckily, it’s easy to convert back and forth between these representations. To build a look-up table out of a function, we can iterate through all 16 colors and store the results in a table. To convert a look-up table to a function, we can build a function that checks the table for the input and returns the value it finds.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes min-light night-owl&quot; style=&quot;color:#24292eff&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;-- convert a remapping function to a look up table&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; pal_to_tbl&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;	local&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; tbl&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; {}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	for&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;		tbl&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	return&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; tbl&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;-- convert a look up table to a remapping function&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; tbl_to_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;tbl&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	return&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		return&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; tbl&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;or&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Drawing with palette swaps&lt;/h2&gt;
&lt;p&gt;Check out this image. The rabbit on the right is drawn with a palette swap, remapping brown to peach.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/_astro/buggy_palette_swap.B52odo0g_Z67gnc.webp&quot; alt=&quot;Two brown pixel-art rabbits. The one on the right is supposed to be peach colored, but it isn&apos;t.&quot; width=&quot;384&quot; height=&quot;384&quot; loading=&quot;lazy&quot; /&gt;&lt;/p&gt;
&lt;p&gt;What’s that, you say? They’re both still brown?! How strange. I &lt;em&gt;definitely&lt;/em&gt; applied a palette swap to the second one. Here’s the code to prove it:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes min-light night-owl&quot; style=&quot;color:#24292eff&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;alt_palette&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;	-- set color 14 (pink) to color 2 (maroon)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;14&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;	-- set color 4 (brown) to color 15 (peach)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 15&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; _draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	cls&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;	-- draw sprite on the left&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;40&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;64&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	draw_bun&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;	-- draw sprite on the right with a palette swap&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;88&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;64&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;alt_palette&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	draw_bun&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;	-- reset the palette&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What I didn’t mention is that the left sprite was &lt;em&gt;already&lt;/em&gt; being drawn with a palette swap. The original sprite looks like this. With the right palette swaps, this base sprite can be used to draw all 9 of the rabbits in the grid above.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/_astro/original_colors.CT38qoBS_1lzsT5.webp&quot; alt=&quot;A pixel-art rabbit with pink and blue spots&quot; width=&quot;384&quot; height=&quot;384&quot; loading=&quot;lazy&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And here’s the code for &lt;code&gt;draw_bun&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes min-light night-owl&quot; style=&quot;color:#24292eff&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; draw_bun&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;({&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;		-- set all fur colors to 4 (brown)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;		[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;		[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;		[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;		[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;	local&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;16&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	spr&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Admittedly, I cheated to make a point, but the point is it would be nice if we were able to apply a palette swap to &lt;em&gt;arbitrary&lt;/em&gt; drawings, not just to original drawings. I want the concept of palette swapping to be &lt;em&gt;general&lt;/em&gt; and &lt;em&gt;composable&lt;/em&gt;.&lt;/p&gt;
&lt;h3&gt;Combining palettes&lt;/h3&gt;
&lt;p&gt;How can we change the code to get the expected result for the second sprite — namely, a peach colored rabbit?&lt;/p&gt;
&lt;p&gt;We have a palette we can use to draw a brown rabbit and a palette to change brown to peach. What we still need is a way to combine both palette effects. This is where the function representation for palette swaps really shines. Combining palette swaps is function composition!&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes min-light night-owl&quot; style=&quot;color:#24292eff&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;-- compose two functions&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;-- can be used to chain two palette swaps together&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; compose&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	return&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		return&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;brown_bun&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; tbl_to_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;({&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;	-- set all fur colors to 4 (brown)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;peach_bun&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; tbl_to_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;({&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;	-- set color 14 (pink) to color 2 (maroon)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;14&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;	-- set color 4 (brown) to color 15 (peach)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 15&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; draw_bun&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;	local&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;16&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	spr&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; _draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	cls&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;	-- draw brown bunny on the left&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;24&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;pal_to_tbl&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;brown_bun&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	draw_bun&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;	-- draw peach bunny on the right&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;24&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;pal_to_tbl&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;		compose&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;brown_bun&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;peach_bun&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	draw_bun&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;	-- reset the palette&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;/_astro/fixed_palette_swap.DIQZISVI_1jfrng.webp&quot; alt=&quot;Pixel art of a brown rabbit on the left and a peach colored rabbit on the right. All according to plan.&quot; width=&quot;384&quot; height=&quot;384&quot; loading=&quot;lazy&quot; /&gt;&lt;/p&gt;
&lt;p&gt;And with that, we’ve fixed the bug. Combining the two palette swaps gives us the peach colored rabbit we wanted.&lt;/p&gt;
&lt;h3&gt;Refactoring&lt;/h3&gt;
&lt;p&gt;The code above produces the results I want, but not without making some significant changes to the code’s structure. Ideally, I want a way to define the &lt;code&gt;draw_bun&lt;/code&gt; function in a self-contained way that includes the palette swapping. Then I’d like to draw the peach colored rabbit as a variation on that function. That is to say, I want drawing with a palette swap to be a &lt;a href=&quot;/posts/005-suspend-your-draw-calls/&quot;&gt;composable effect&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Here’s a &lt;code&gt;draw_with_palette&lt;/code&gt; function we can use to manage palette swaps, even repeated ones. It makes use of a state variable, &lt;code&gt;draw_pal&lt;/code&gt;, to track what palette-swap we’re currently drawing with. It also takes care of combining palette swaps, and restoring the old palette afterwards. As long as we avoid calling &lt;code&gt;pal&lt;/code&gt; directly anywhere else, this function handles all our composable palette-swapping needs!&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes min-light night-owl&quot; style=&quot;color:#24292eff&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; return&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;draw_pal&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; draw_with_palette&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	return&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		return&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;			local&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; prev&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; draw_pal&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;			-- combine the old palette with the new one&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;			draw_pal&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; compose&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;draw_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;pal_to_tbl&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;draw_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;			-- restore the old palette&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;			draw_pal&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; prev&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;pal_to_tbl&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;draw_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;-- usage:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;brown_bun&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; tbl_to_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;({&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;	-- set color 5 (gray) to color 4 (brown)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;	-- set color 7 (white) to color 4 (brown)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;peach_bun&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; tbl_to_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;({&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;	-- set color 14 (pink) to color 2 (maroon)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;14&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;	-- set color 4 (brown) to color 15 (peach)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 15&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;draw_bun&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; draw_with_palette&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;brown_bun&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;	local&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 24&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;24&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	spr&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; _draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	cls&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;	-- draw brown bunny on the left&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;24&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	draw_bun&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;	-- draw peach bunny on the right&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;24&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	draw_with_palette&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;peach_bun&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;		(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;draw_bun&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Putting it all together&lt;/h2&gt;
&lt;p&gt;Having a composable palette swapping system is great for getting the most out of your sprites. It dovetails nicely with the system of drawing effects from my post &lt;a href=&quot;/posts/005-suspend-your-draw-calls/&quot;&gt;Suspend Your Draw Calls!&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here’s the code for the rabbit grid from earlier. Each one is drawn with a combination of two palette swaps. One to select which fur pattern to use, and the other to choose the colors.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes min-light night-owl&quot; style=&quot;color:#24292eff&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; draw_bun&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;	local&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;16&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	spr&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;--patterns&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;pal_solid&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; tbl_to_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;({&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;pal_dutch&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; tbl_to_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;({&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;pal_spotted&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; tbl_to_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;({&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;--colors&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;pal_gray&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;pal_orange&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; tbl_to_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;({&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 9&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;pal_brown&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; tbl_to_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;({&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	[&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; 15&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;--buns&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;solid_bun&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; draw_with_palette&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;pal_solid&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;draw_bun&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;dutch_bun&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; draw_with_palette&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;pal_dutch&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;draw_bun&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;spotted_bun&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; draw_with_palette&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;pal_spotted&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;draw_bun&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; _draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	cls&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;24&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;24&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	draw_with_palette&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;pal_gray&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;		(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;solid_bun&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;64&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;24&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	draw_with_palette&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;pal_gray&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;		(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;dutch_bun&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;104&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;24&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	draw_with_palette&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;pal_gray&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;		(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;spotted_bun&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;24&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;64&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	draw_with_palette&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;pal_orange&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;		(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;solid_bun&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;64&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;64&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	draw_with_palette&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;pal_orange&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;		(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;dutch_bun&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;104&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;64&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	draw_with_palette&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;pal_orange&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;		(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;spotted_bun&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;24&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;104&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	draw_with_palette&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;pal_brown&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;		(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;solid_bun&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;64&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;104&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	draw_with_palette&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;pal_brown&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;		(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;dutch_bun&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;104&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;104&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	draw_with_palette&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;pal_brown&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;		(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;spotted_bun&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Reference&lt;/h2&gt;
&lt;p&gt;If you’d like to use these functions in your own carts, here’s a summary of the library code from this article. You can also check out the demo cart for example usage.&lt;/p&gt;
&lt;p&gt;I’m licensing both under &lt;a href=&quot;https://creativecommons.org/licenses/by/4.0/&quot;&gt;CC BY 4.0&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes min-light night-owl&quot; style=&quot;color:#24292eff&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; return&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; compose&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	return&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		return&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; pal_to_tbl&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;	local&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; ret&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;{}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	for&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;		ret&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	return&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; ret&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; tbl_to_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;tbl&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	return&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		return&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; tbl&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;or&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;draw_pal&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; draw_with_palette&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	return&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		return&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;			local&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; prev&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; draw_pal&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;			draw_pal&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; compose&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;draw_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;pal_to_tbl&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;draw_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;			draw_pal&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; prev&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;pal_to_tbl&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;draw_pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;img src=&quot;/_astro/palette_demo.p8.DAKfvdAL.png&quot; alt=&quot;PICO-8 Cartridge&quot; /&gt;</content:encoded><author>Mabbees</author></item><item><title>(Reblog) social media types</title><link>https://mabbees.neocities.org/posts/006-social-media-types/</link><guid isPermaLink="true">https://mabbees.neocities.org/posts/006-social-media-types/</guid><pubDate>Fri, 06 Dec 2024 10:01:29 GMT</pubDate><content:encoded>&lt;div class=&quot;h-entry  u-repost-of inline-flex space-x-4 astro-huxyrzvi&quot;&gt; &lt;div class=&quot;not-prose h-16 w-16 astro-huxyrzvi&quot;&gt; &lt;img src=&quot;/_astro/avatar.CURAHdgr_4EKu7.webp&quot; alt=&quot;&quot; width=&quot;121&quot; height=&quot;121&quot; loading=&quot;lazy&quot; class=&quot;rounded-full astro-huxyrzvi&quot; /&gt; &lt;/div&gt; &lt;article class=&quot;card astro-huxyrzvi&quot;&gt; &lt;h1 class=&quot;post-title not-prose p-name astro-huxyrzvi&quot;&gt;&lt;a href=&quot;https://discographette.online/posts/social-media-types&quot; class=&quot;astro-huxyrzvi&quot;&gt;social media types&lt;/a&gt;&lt;/h1&gt; &lt;p class=&quot;my-0 not-prose astro-huxyrzvi&quot;&gt; &lt;a class=&quot;u-url u-uid attribution inline-flex items-center space-x-2 astro-huxyrzvi&quot; href=&quot;https://discographette.online/posts/social-media-types&quot;&gt; &lt;span class=&quot;inline-flex items-center space-x-2 opacity-80&quot;&gt;&lt;span class=&quot;text-sm italic&quot;&gt;Posted&lt;/span&gt;&lt;span class=&quot;text-sm italic&quot;&gt;&lt;time class=&quot;dt-published&quot;&gt;Dec 5, 2024&lt;/time&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;astro-huxyrzvi&quot;&gt;by&lt;/span&gt; &lt;span class=&quot;p-author h-card astro-huxyrzvi&quot;&gt; &lt;span class=&quot;p-name astro-huxyrzvi&quot;&gt;discographette&lt;/span&gt;&lt;data class=&quot;u-url astro-huxyrzvi&quot;&gt;&lt;/data&gt; &lt;/span&gt; &lt;/a&gt; &lt;/p&gt; &lt;div class=&quot;e-content prose astro-huxyrzvi&quot;&gt; &lt;blockquote&gt;
&lt;p&gt;…in the Fixed Type version of the scenario, if I see a friend who posts not often but see a post I like by them, I can hit like- all it serves is to signal to them I saw it, and that I liked it. This is like waving to someone you haven’t seen in a while, or nodding in response to something a friend said in a group you literally liked.&lt;br /&gt;&lt;br /&gt;In a Reactive Type, this action is interpreted entirely differently (and varies platform to platform) but inevitably, much like buying a toilet on amazon will recommend you more toilets, you will now be served MORE of that friend’s content. It’s essentially an onramp button that weights their posts being mixed into your timeline, which is not necessarily how everyone is using it…&lt;/p&gt;
&lt;/blockquote&gt;&lt;a href=&quot;https://discographette.online/posts/social-media-types&quot; target=&quot;_blank&quot;&gt;&lt;p&gt;Read more&lt;/p&gt;&lt;/a&gt; &lt;/div&gt; &lt;/article&gt; &lt;/div&gt; 
&lt;p&gt;Discographette wrote a neat breakdown of different design decisions across social media platforms, and their ramifications. I like her taxonomy of fixed vs reactive types.&lt;/p&gt;
&lt;p&gt;In general, I wish more platforms would take the “fixed” route. I found Cohost’s design to be quite refreshing—namely, showing only posts from people or tags that I follow, and always showing them in chronological order. The feedback loops inherent to “reactive” social media seem both harmful and inevitable.&lt;/p&gt;
&lt;p&gt;That said, as an American living in Japan, I can relate to the problem of not being able to keep up with my friends in different time zones. Chronological timelines tend to make this harder, since things that were posted while I’m asleep will require scrolling further back to see. It’s a prime example of something algorithmic curation &lt;em&gt;could&lt;/em&gt; be harnessed for to do good.&lt;/p&gt;</content:encoded><author>Mabbees</author></item><item><title>Suspend Your Draw Calls!</title><link>https://mabbees.neocities.org/posts/005-suspend-your-draw-calls/</link><guid isPermaLink="true">https://mabbees.neocities.org/posts/005-suspend-your-draw-calls/</guid><description>Reusable graphic effects in PICO-8 with higher-order functions</description><pubDate>Tue, 26 Nov 2024 08:50:28 GMT</pubDate><content:encoded>&lt;p&gt;I want to show you some cool graphic effects you can achieve in PICO-8. It’s also a nice case-study for applying some functional programming techniques. What do I mean by graphic effects? Let’s take a look at some examples.&lt;/p&gt;
&lt;p&gt;Text drawn with the regular &lt;code&gt;print&lt;/code&gt; function looks very plain. There are some things we can do to make it stand out more. We could add a drop shadow, or an outline. Or how about both?&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/_astro/first-implementation.Crnc5Wzn_ZamM6P.webp&quot; alt=&quot;sample text drawn with an outline, with a drop shadow, and with both&quot; width=&quot;384&quot; height=&quot;384&quot; loading=&quot;lazy&quot; /&gt;&lt;/p&gt;
&lt;h2&gt;Basic implementation&lt;/h2&gt;
&lt;p&gt;One way to code this is like this:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes min-light night-owl&quot; style=&quot;color:#24292eff&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; print_outline&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	for&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		for&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; j&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			print&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	print&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; print_shadow&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	print&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	print&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; print_outline_shadow&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	for&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		for&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; j&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			print&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	print&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	print&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;-- usage:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; _draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	cls&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	print_outline&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;outline&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;54&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;14&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	print_shadow&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;shadow&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;52&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;62&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	print_outline_shadow&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;both&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;56&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;70&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;14&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is fine, but I think we can do better. Conceptually, &lt;code&gt;print_outline_shadow&lt;/code&gt; is &lt;strong&gt;combining&lt;/strong&gt; the effects of the other two functions. It would be nice if the structure of the code reflected this. Come to think of it, there’s another way to combine both effects. We could add an outline to text with a drop-shadow instead of adding a drop-shadow to outlined text. Right now the code doesn’t give us a good way to do that—we’d have to define a new function from scratch for &lt;code&gt;print_shadow_outline&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;I’m going to take this code through some refactors to bring out the shared structure and make these effects composable.&lt;/p&gt;
&lt;h2&gt;Refactoring&lt;/h2&gt;
&lt;p&gt;For starters, I’m going to change the &lt;code&gt;print&lt;/code&gt; calls to use the current draw color instead of passing the color as an argument. This means adding calls to &lt;code&gt;color&lt;/code&gt; to setup the draw state.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes min-light night-owl&quot; style=&quot;color:#24292eff&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; print_outline&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	for&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		for&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; j&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			print&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	print&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; print_shadow&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	print&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	print&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The next refactor I’ll make is similar. I’m going to use the &lt;code&gt;camera&lt;/code&gt; function to handle the offsets.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes min-light night-owl&quot; style=&quot;color:#24292eff&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; print_outline&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	for&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		for&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; j&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			print&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	print&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; print_shadow&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	print&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	print&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That was a lot of change with not much to show for it. The functions still behave the same, but the code is looking a lot worse! There was a purpose to all this though. All the &lt;code&gt;print&lt;/code&gt; calls are now exactly the same. That sets us up nicely for the next refactor.&lt;/p&gt;
&lt;h3&gt;Higher-order functions&lt;/h3&gt;
&lt;p&gt;This is where I’ll show of the first bit of functional programming knowhow. The &lt;code&gt;print&lt;/code&gt; call is now repeated in several places. What can we do to clean up a repeated section of code? Same thing we always do as programmers — store the repeated part in a variable and reuse it!&lt;/p&gt;
&lt;p&gt;It’s important to take care while doing this. We can’t just say &lt;code&gt;draw = print(text, x, y)&lt;/code&gt; because we’re not interested in the return value of &lt;code&gt;print&lt;/code&gt;, we want to reuse its &lt;em&gt;side-effect&lt;/em&gt;. We can achieve this by wrapping the &lt;code&gt;print&lt;/code&gt; call in a function.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes min-light night-owl&quot; style=&quot;color:#24292eff&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; draw_with_outline&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;draw&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	for&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		for&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; j&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; draw_with_shadow&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;draw&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;-- usage:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; _draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	cls&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;	local&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; draw_text_1&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;		print&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;outline&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;54&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;	local&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; draw_text_2&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;		print&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;shadow&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;52&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;62&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	draw_with_outline&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;draw_text1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;14&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	draw_with_shadow&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;draw_text2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Generality&lt;/h3&gt;
&lt;p&gt;Even though we started with text effects, the fact that we abstracted out the &lt;code&gt;draw&lt;/code&gt; function means this also works when drawing circles, rectangles, lines, etc. Cool!&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes min-light night-owl&quot; style=&quot;color:#24292eff&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; _draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	cls&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;	-- both the text and the rectangle&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;	-- are drawn with a shadow!&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	draw_with_shadow&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;		print&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;my cool game&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;42&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;		rect&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;32&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;32&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;96&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;96&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It would be even cooler to do the same thing when drawing a sprite. Luckily, there’s not too much else we need to change to make that work. All we need to do is stop relying on the &lt;code&gt;color&lt;/code&gt; function, and use of &lt;code&gt;pal&lt;/code&gt; instead. &lt;code&gt;pal&lt;/code&gt; gives us control over the palette PICO-8 uses when drawing &lt;strong&gt;anything&lt;/strong&gt;, in much the way that &lt;code&gt;color&lt;/code&gt; gives us control over the draw color PICO-8 uses for &lt;code&gt;print&lt;/code&gt;, &lt;code&gt;circle&lt;/code&gt;, etc.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes min-light night-owl&quot; style=&quot;color:#24292eff&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; set_color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;	-- set all 16 colors to &apos;c&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	for&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;		pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; draw_with_outline&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;draw&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	for&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		for&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; j&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			set_color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	set_color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; draw_with_shadow&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;draw&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	set_color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	set_color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;-- usage:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; _draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	cls&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	draw_with_outline&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;		spr&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;64&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;64&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;14&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we can apply an outline or drop-shadow effect when drawing sprites.&lt;/p&gt;
&lt;h3&gt;Suspended functions&lt;/h3&gt;
&lt;p&gt;There are more changes I want to make. I want to show how these effects can be composed together. To make that easier, instead of writing functions that we call to draw something to the screen, I’m going to switch to functions that return a “suspended” draw call. I’m also going to change the argument order, to put the draw function last.&lt;/p&gt;
&lt;p&gt;We’ve already seen closures once before. I used a closure to extract the &lt;code&gt;print&lt;/code&gt; call earlier and pass it as an argument to &lt;code&gt;draw_with_outline&lt;/code&gt;. We can return a closure from a function too.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes min-light night-owl&quot; style=&quot;color:#24292eff&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; draw_with_outline&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	return&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		for&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;			for&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; j&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;				camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;				color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;				draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;			end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;		color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;		camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;		draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; draw_with_shadow&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	return&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;		camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;		color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;		draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;		camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;		color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;		draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;-- usage:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; _draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	cls&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;	-- don&apos;t forget the extra `()` at the very end!&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	draw_with_outline&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;14&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;		draw_with_shadow&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			print&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;outline&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		end&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	)()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There is an issue to watch out for now—it’s easy to forget the extra set of &lt;code&gt;()&lt;/code&gt; needed to call the closure. I’ve forgotten it many times and wondered why on earth my sprites were never showing up.&lt;/p&gt;
&lt;h3&gt;Composing effects&lt;/h3&gt;
&lt;p&gt;The last refactor I want to do is to address the deeply nested code. Ironically, the way to address the nesting (in the usage), involves more nesting (in the library functions). Such is life. The extra level of nesting comes about by returning a &lt;em&gt;partially applied&lt;/em&gt; or “curried” function.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes min-light night-owl&quot; style=&quot;color:#24292eff&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; draw_with_outline&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	return&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		return&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;			for&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;				for&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; j&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;					camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;					color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;					draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;				end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;			end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; draw_with_shadow&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	return&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		return&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we come to one of my favorite techniques. Since these effects are now functions that accept a draw function and return another draw function, they can be composed end-to-end. The combinators &lt;code&gt;compose&lt;/code&gt; and &lt;code&gt;chain&lt;/code&gt; do just that for a pair or a list of effects, respectively.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes min-light night-owl&quot; style=&quot;color:#24292eff&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; return&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; compose&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	return&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		return&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; chain&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;fs&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;	local&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; ret&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	foreach&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;fs&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;		ret&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; compose&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;ret&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	return&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; ret&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;-- usage:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; _draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;	-- a nice flat list of effects&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;	-- no &quot;extra&quot; nesting required&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	chain&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;({&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;		draw_with_shadow&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;		draw_with_outline&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;14&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;		draw_with_shadow&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;7&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;	})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;		(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			print&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;fancy text&lt;/span&gt;&lt;span style=&quot;color:#22863A&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;44&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;60&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		end&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;		()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Debugging and cleaning up&lt;/h3&gt;
&lt;p&gt;We’ve done the refactoring we need in order to make effects composable, but there are still a few minor details to work out. One issue is with the camera, and one is with the color palette.&lt;/p&gt;
&lt;p&gt;Now that our implementation uses &lt;code&gt;camera&lt;/code&gt;, it might cause problems when our &lt;code&gt;_draw()&lt;/code&gt; function is already using &lt;code&gt;camera&lt;/code&gt;. It also causes problems when using multiple effects. It would be nicer if we took into account the current camera state when we use &lt;code&gt;draw_with_shadow&lt;/code&gt; or &lt;code&gt;draw_with_outline&lt;/code&gt; and put it back how it was when we’re done. We can do this by reading the camera state from memory and storing it in a variable. Similarly, let’s put the palette back how it was. We can also address a bug that happens when chanining effects — we want to override the palette &lt;em&gt;only if we haven’t already changed it with another effect&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;While I’m at it, I’ll also drop the argument for the initial color. Instead I’ll let PICO-8 use the current palette and draw color, which will handle the case when the sprite we want to draw uses multiple colors.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes min-light night-owl&quot; style=&quot;color:#24292eff&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;draw_color&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; nil&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; draw_with_color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	return&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; suspend&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;		-- get the current palette state&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;		local&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; p1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;p2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;p3&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;p4&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; peek4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0x5f00&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;		local&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; prev&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; draw_color&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;		-- set the draw color, but only if it hasn&apos;t already been changed&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;		draw_color&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; prev&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; or&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		for&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;draw_color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;		draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;		-- restore the palette&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;		poke4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0x5f00&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;p1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;p2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;p3&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;p4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;		draw_color&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; prev&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; draw_with_outline&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	return&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		return&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;			-- get the current camera state&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;			local&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; peek2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0x5f28&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			draw_with_color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;				for&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;					for&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; j&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;						camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;						draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;					end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;				end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;			end&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;			-- restore the camera state&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; draw_with_shadow&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	return&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		return&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;			local&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; peek2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0x5f28&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			draw_with_color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;				camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;				draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;			end&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;/_astro/demo.BNNstvu__ZAYBq9.webp&quot; alt=&quot;sample text and sprites drawn with effects&quot; width=&quot;384&quot; height=&quot;384&quot; loading=&quot;lazy&quot; /&gt;&lt;/p&gt;
&lt;h2&gt;Closing remarks&lt;/h2&gt;
&lt;p&gt;I hope I’ve passed along some useful functional programming knowhow, some PICO-8 tips, or maybe even both. If it’s useful to you, feel free to build on this code for your own projects. It’s something I use in a lot of my own carts.&lt;/p&gt;
&lt;p&gt;If you’re not used to functional programming, these techniques can seem obtuse—they certainly felt that way to me when I was first learning them. Over time, I developed enough familiarity with them that they became second nature. I hope by showing the refactoring process step-by-step, I could help to de-mystify the way this code works.&lt;/p&gt;
&lt;p&gt;I started out by saying I wanted to do “better” than the straightforward implementation. I certainly like my approach better. I like composable code, in particular because of how it makes it easy and fun to try different combinations, but I want to acknowledge that there are tradeoffs. My implemantation is a lot longer than the straightforward version, and not so straightforward to debug. If you’re trying to optimize your token count, this might not be the best approach.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Reference&lt;/h2&gt;
&lt;p&gt;Here’s a complete reference of the effects in this article, and a demo cart showing them off.&lt;/p&gt;
&lt;p&gt;I’m licensing both under &lt;a href=&quot;https://creativecommons.org/licenses/by/4.0/&quot;&gt;CC BY 4.0&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes min-light night-owl&quot; style=&quot;color:#24292eff&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; return&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; compose&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#212121&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;g&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	return&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		return&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; g&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; chain&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;fs&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;	local&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; ret&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;	foreach&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;fs&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;		ret&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; compose&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;ret&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	return&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; ret&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;draw_color&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt; nil&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; draw_with_color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	return&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		return&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;			-- get the current palette&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;			local&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; p1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;p2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;p3&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;p4&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; peek4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0x5f00&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;			local&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; prev&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; draw_color&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;			draw_color&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; prev&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; or&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; c&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;			for&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;15&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;				pal&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;draw_color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;			end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;			-- restore the palette&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			poke4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0x5f00&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;p1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;p2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;p3&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;p4&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;			draw_color&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; prev&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; draw_with_outline&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	return&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		return&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;			-- get the current camera state&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;			local&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; peek2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0x5f28&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			draw_with_color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;				for&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;					for&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; j&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;=-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;						camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;j&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;						draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;					end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;				end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;			end&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C2C3C5;font-style:inherit&quot;&gt;			-- restore the camera state&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#6F42C1;font-style:inherit&quot;&gt; draw_with_shadow&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	return&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FF9800&quot;&gt;draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		return&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;			local&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt; peek2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;0x5f28&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			draw_with_color&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)(&lt;/span&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;				camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#D32F2F&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#1976D2&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;				draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;			end&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			camera&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6F42C1&quot;&gt;			draw&lt;/span&gt;&lt;span style=&quot;color:#24292EFF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;		end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;	end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D32F2F;font-style:inherit&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;img src=&quot;/_astro/suspend_demo.p8.DPZOcNJV.png&quot; alt=&quot;PICO-8 Cartridge&quot; /&gt;</content:encoded><author>Mabbees</author></item><item><title>Microformats and Webmentions</title><link>https://mabbees.neocities.org/posts/004-webmentions/</link><guid isPermaLink="true">https://mabbees.neocities.org/posts/004-webmentions/</guid><description>I made a couple of updates to my site: microformats and webmentions. They&apos;re mostly invisible changes, but hopefully they will make blogging here on neocities more fun and engaging.</description><pubDate>Thu, 31 Oct 2024 07:53:44 GMT</pubDate><content:encoded>&lt;p&gt;I made a couple of updates to my site: microformats and webmentions. They’re mostly invisible changes, but hopefully they will make blogging here on neocities more fun and engaging.&lt;/p&gt;
&lt;h3&gt;Changes&lt;/h3&gt;
&lt;p&gt;My posts now use the &lt;a href=&quot;https://microformats.org/wiki/h-entry&quot;&gt;h-entry microformat&lt;/a&gt;, which makes it easier for software to parse. Software such as … maybe your blog! It’s a format for making posts rebloggable. Going the other direction, I added some tools to my site-generator to embed posts. Now I can reblog other posts here! The embeds are generated automatically by (you guessed it) parsing the h-entry microformat.&lt;/p&gt;
&lt;p&gt;I also set up &lt;a href=&quot;https://indieweb.org/Webmention&quot;&gt;webmentions&lt;/a&gt;. This is a way for me to notify other people when I link to their sites, and for other people to notify me when they link to my site. I handle outgoing webmentions through &lt;a href=&quot;https://github.com/remy/wm#readme&quot;&gt;@remy/webmention&lt;/a&gt;, and incoming webmentions through &lt;a href=&quot;https://webmention.io/&quot;&gt;webmention.io&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;Inspiration&lt;/h3&gt;
&lt;p&gt;What’s the point of all this? The point is to have conversations! Right here on our very own websites, without needing to have Tumblr or Bluesky or Facebook act as the middleman. I was specifically inspired by what Natalie Weizenbaum is doing over at &lt;a href=&quot;https://nex-3.com/&quot;&gt;nex-3.com&lt;/a&gt;, and her essay on what she calls the “Sociable Web”.
If everything went according to plan, maybe you’ll see this post in the webmentions list over on Natalie’s blog.&lt;/p&gt;
&lt;div class=&quot;h-entry  u-repost-of inline-flex space-x-4 astro-huxyrzvi&quot;&gt; &lt;div class=&quot;not-prose h-16 w-16 astro-huxyrzvi&quot;&gt; &lt;img src=&quot;/_astro/avatar.C-6bQ9Yb_Z13PuUf.webp&quot; alt=&quot;&quot; width=&quot;904&quot; height=&quot;904&quot; loading=&quot;lazy&quot; class=&quot;rounded-full astro-huxyrzvi&quot; /&gt; &lt;/div&gt; &lt;article class=&quot;card astro-huxyrzvi&quot;&gt; &lt;h1 class=&quot;post-title not-prose p-name astro-huxyrzvi&quot;&gt;&lt;a href=&quot;https://nex-3.com/blog/a-sociable-web/&quot; class=&quot;astro-huxyrzvi&quot;&gt;A Sociable Web&lt;/a&gt;&lt;/h1&gt; &lt;p class=&quot;my-0 not-prose astro-huxyrzvi&quot;&gt; &lt;a class=&quot;u-url u-uid attribution inline-flex items-center space-x-2 astro-huxyrzvi&quot; href=&quot;https://nex-3.com/blog/a-sociable-web/&quot;&gt; &lt;span class=&quot;inline-flex items-center space-x-2 opacity-80&quot;&gt;&lt;span class=&quot;text-sm italic&quot;&gt;Posted&lt;/span&gt;&lt;span class=&quot;text-sm italic&quot;&gt;&lt;time class=&quot;dt-published&quot;&gt;Oct 19, 2024&lt;/time&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;astro-huxyrzvi&quot;&gt;by&lt;/span&gt; &lt;span class=&quot;p-author h-card astro-huxyrzvi&quot;&gt; &lt;span class=&quot;p-name astro-huxyrzvi&quot;&gt;Natalie&lt;/span&gt;&lt;data class=&quot;u-url astro-huxyrzvi&quot;&gt;&lt;/data&gt; &lt;/span&gt; &lt;/a&gt; &lt;/p&gt; &lt;div class=&quot;e-content prose astro-huxyrzvi&quot;&gt; &lt;blockquote&gt;
&lt;p&gt;The deepest virtue of independent websites communicating with
loosely-coupled conventions and protocols isn’t anything technical. It’s the
fact that you can &lt;strong&gt;just do it&lt;/strong&gt;. You don’t need a platform to exist, you
don’t even need anyone else to be doing the same thing (although it’s more fun
that way). You can write a blog and people can read it via RSS or just by
loading it up every now and then. You can hook up as much IndieWeb technology
as you want, or just focus on the cultural aspect by writing link roundups and
leaving comments on the stuff you read.&lt;/p&gt;
&lt;/blockquote&gt;&lt;a href=&quot;https://nex-3.com/blog/a-sociable-web/&quot; target=&quot;_blank&quot;&gt;&lt;p&gt;Read more&lt;/p&gt;&lt;/a&gt; &lt;/div&gt; &lt;/article&gt; &lt;/div&gt; 
&lt;p&gt;The web is feeling more and more corporate every day, and the corporate web is feeling more and more hostile every day. It’s nice to have spaces that are our own. It’s nice that folks on the indie web are figuring out how we can do that without completely giving up the functionality of other platforms. It’s not, at this point in time, as convenient and easy to use. Maybe it never will be completely. But none of the technology involved is so arcane that it couldn’t be made easy to use.&lt;/p&gt;</content:encoded><author>Mabbees</author></item><item><title>QR codes in PICO-8</title><link>https://mabbees.neocities.org/posts/003-qr-codes/</link><guid isPermaLink="true">https://mabbees.neocities.org/posts/003-qr-codes/</guid><description>I wrote a tool to generate QR codes in PICO-8</description><pubDate>Thu, 31 Oct 2024 02:30:01 GMT</pubDate><content:encoded>&lt;div class=&quot;_container_xdi3q_1&quot;&gt;&lt;/div&gt;
&lt;p&gt;My partner gifted me a Miyoo Mini Plus for Christmas last year. I love it! It’s such a cute little system. One of the best things about it is that with a little convincing, it can &lt;a href=&quot;https://github.com/XK9274/pico-8-wrapper-miyoo&quot;&gt;run PICO-8 natively&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I’ve enjoyed bringing it with me to indie game developer meetups and I showing off the PICO-8 games I’ve been working on. It’s been a fun way to share my portfolio. It’s made me realize it would be really convenient if I could pull up a QR code on the miyoo, then people could scan it and find the games online. So of course, I built a PICO-8 cart to generate QR codes. A saner person might have generated a QR code using an existing tool and simply imported it into PICO-8, but well… where’s the fun in that?&lt;/p&gt;
&lt;h3&gt;Implementation&lt;/h3&gt;
&lt;p&gt;I followed &lt;a href=&quot;https://www.thonky.com/qr-code-tutorial/&quot;&gt;Thonky’s QR code tutorial&lt;/a&gt; to work out the implementation. To me, the most interesting part was learning about error-correcting codes. QR codes use a method called Reed-Solomon Error correction, which uses some clever number theory, and can be implemented efficiently using some clever programming tricks. Apart from that, there are a bunch of fiddly details that are easy to get wrong, but I did eventually get my program to make QR codes that my phone can scan. As coding exercises go, this one felt pretty rewarding.&lt;/p&gt;
&lt;p&gt;I only implemented a subset of what QR codes are capable of. My cart always uses alphanumeric mode, error-correction level Q, and version 10 (57 × 57). That puts a limit on how long a message it can encode of 221 characters — still more than enough for sharing URLs.&lt;/p&gt;
&lt;h3&gt;The Cart&lt;/h3&gt;
&lt;p&gt;Here’s the cart. You can generate a QR code either by dragging and dropping a text file, by hard-coding a value, or by running the cart from the command-line.&lt;/p&gt;
&lt;img src=&quot;/_astro/qr.p8.XIdL5Baq.png&quot; alt=&quot;PICO-8 Cartridge&quot; /&gt;</content:encoded><author>Mabbees</author></item><item><title>Spooky Halloween Tune</title><link>https://mabbees.neocities.org/posts/002-spooky-tune/</link><guid isPermaLink="true">https://mabbees.neocities.org/posts/002-spooky-tune/</guid><description>A spooky tune I wrote for Tomodachi 8in1</description><pubDate>Mon, 21 Oct 2024 09:45:39 GMT</pubDate><content:encoded>&lt;audio controls src=&quot;/_astro/spooky.DSN4_Sak.wav&quot;&gt;&lt;/audio&gt;
&lt;p&gt;This is a little tune I wrote for Tomodachi 8in1. It’s going to be the background music for a Halloween themed dressup mini-game.&lt;/p&gt;
&lt;p&gt;I think the theremin part at the end sounds like a ghost had to sneeze!&lt;/p&gt;</content:encoded><author>Mabbees</author></item><item><title>Egg&apos;ry Buggy Clap Your Hands!</title><link>https://mabbees.neocities.org/posts/001-eggbug-party/</link><guid isPermaLink="true">https://mabbees.neocities.org/posts/001-eggbug-party/</guid><description>A tribute song I wrote for Cohost.</description><pubDate>Mon, 30 Sep 2024 09:56:27 GMT</pubDate><content:encoded>&lt;div class=&quot;_container_xdi3q_1&quot;&gt;&lt;/div&gt;
&lt;p&gt;I wrote this song for COMPOST #6, a community music jam over on cohost. The theme was “party”, and entries were supposed to be completed in under 2 hours. I did pretty well, though it probably took me a little longer (especially if you include the time it took to add eggbugs).&lt;/p&gt;
&lt;p&gt;I’m really happy with what I was able to come up with! I can tell I’m getting better at writing songs with the PICO-8 tracker, and better at being able to put my ideas down quickly.&lt;/p&gt;
&lt;h3&gt;Remixing&lt;/h3&gt;
&lt;p&gt;Feel free to use this in your own PICO-8 projects with attribution! I’m licensing it under &lt;a href=&quot;https://creativecommons.org/licenses/by/4.0/&quot;&gt;CC BY 4.0&lt;/a&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Music by &lt;a href=&quot;https://mabbees.neocities.org/&quot;&gt;mabbees&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Eggbug sprite by &lt;a href=&quot;https://axolotine.neocities.org/&quot;&gt;Axolotine&lt;/a&gt; (adapted by me for the PICO-8 color palette)&lt;/li&gt;
&lt;/ul&gt;
&lt;img src=&quot;/_astro/eggbug.p8.B1oSg5H3.png&quot; alt=&quot;PICO-8 Cartridge&quot; /&gt;</content:encoded><author>Mabbees</author></item></channel></rss>