<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>mechgen.app</title>
  <subtitle>Free pixel mech avatar generator. 10M+ unique robots.</subtitle>
  <link href="https://mechgen.app/feed.xml" rel="self"/>
  <link href="https://mechgen.app/blog/"/>
  <updated>2026-02-05T00:00:00Z</updated>
  <id>https://mechgen.app/</id>
  <author>
    <name>MechGen Team</name>
  </author>
  <entry>
    <title>Pixel Art Avatar Design: Anatomy of a Mech</title>
    <link href="https://mechgen.app/blog/pixel-art-avatar-design-anatomy-of-a-mech/"/>
    <updated>2026-02-05T00:00:00Z</updated>
    <id>https://mechgen.app/blog/pixel-art-avatar-design-anatomy-of-a-mech/</id>
    <content type="html">&lt;p&gt;Every mech avatar generated by MechGen is assembled from seven distinct part categories, each with 10 unique variants. Understanding how these parts work together is the key to appreciating why no two mechs look quite the same — and how over 10 million unique combinations emerge from a relatively simple system.&lt;/p&gt;
&lt;h2 id=&quot;the-64x64-canvas&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/pixel-art-avatar-design-anatomy-of-a-mech/#the-64x64-canvas&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The 64x64 Canvas&lt;/h2&gt;
&lt;p&gt;All MechGen robots live on a 64x64 pixel grid. That is 4,096 total pixels to work with. Every part is drawn using &lt;code&gt;fillRect()&lt;/code&gt; calls directly on an HTML canvas — no sprite sheets, no external images, no SVGs. Pure programmatic pixel art.&lt;/p&gt;
&lt;p&gt;The drawing happens back-to-front in a specific order: accessory first, then legs, body, arms, head, antenna, and finally eyes on top. This layering ensures that parts overlap naturally, with the head sitting on the body and eyes rendered last so they are always visible.&lt;/p&gt;
&lt;h2 id=&quot;the-seven-part-categories&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/pixel-art-avatar-design-anatomy-of-a-mech/#the-seven-part-categories&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The Seven Part Categories&lt;/h2&gt;
&lt;h3 id=&quot;head-(10-variants)&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/pixel-art-avatar-design-anatomy-of-a-mech/#head-(10-variants)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Head (10 variants)&lt;/h3&gt;
&lt;p&gt;The head is the defining feature of any mech. It sits at the top-center of the canvas and establishes the robot’s silhouette. Variants range from the chunky &lt;strong&gt;Block&lt;/strong&gt; head (a simple square) to the sleek &lt;strong&gt;Dome&lt;/strong&gt; (rounded top), the aggressive &lt;strong&gt;Horned&lt;/strong&gt; (angular protrusions), and the regal &lt;strong&gt;Crown&lt;/strong&gt; (stepped top edge).&lt;/p&gt;
&lt;p&gt;Each head variant changes how the eyes and antenna sit, since those parts are positioned relative to the head’s bounds.&lt;/p&gt;
&lt;h3 id=&quot;eyes-(10-variants)&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/pixel-art-avatar-design-anatomy-of-a-mech/#eyes-(10-variants)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Eyes (10 variants)&lt;/h3&gt;
&lt;p&gt;Eyes give your mech personality. &lt;strong&gt;Dots&lt;/strong&gt; are the classic two-pixel eyes. &lt;strong&gt;Wide&lt;/strong&gt; stretches them horizontally for a surprised look. &lt;strong&gt;Visor&lt;/strong&gt; draws a single horizontal band across the face — very Cylon. &lt;strong&gt;Cyclops&lt;/strong&gt; is a single centered eye. &lt;strong&gt;X-Eyes&lt;/strong&gt; give a defeated look, while &lt;strong&gt;LED Strip&lt;/strong&gt; runs a row of tiny dots.&lt;/p&gt;
&lt;p&gt;Eyes are always drawn in the eye color from the active palette, making them pop against the head.&lt;/p&gt;
&lt;h3 id=&quot;antenna-(10-variants)&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/pixel-art-avatar-design-anatomy-of-a-mech/#antenna-(10-variants)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Antenna (10 variants)&lt;/h3&gt;
&lt;p&gt;The antenna sits above the head and adds verticality. &lt;strong&gt;None&lt;/strong&gt; keeps it clean. &lt;strong&gt;Spike&lt;/strong&gt; is a single pointed rod. &lt;strong&gt;Dual Rods&lt;/strong&gt; adds two parallel antennae. &lt;strong&gt;Dish&lt;/strong&gt; attaches a satellite receiver. &lt;strong&gt;Halo&lt;/strong&gt; floats a ring above the head for an angelic look.&lt;/p&gt;
&lt;p&gt;Since antenna is drawn after the head, it overlaps naturally at the attachment point.&lt;/p&gt;
&lt;h3 id=&quot;body-(10-variants)&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/pixel-art-avatar-design-anatomy-of-a-mech/#body-(10-variants)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Body (10 variants)&lt;/h3&gt;
&lt;p&gt;The body is the largest single part and defines the mech’s build. &lt;strong&gt;Standard&lt;/strong&gt; is a balanced rectangle. &lt;strong&gt;Tank&lt;/strong&gt; is extra wide and armored. &lt;strong&gt;Slim&lt;/strong&gt; is narrow and tall. &lt;strong&gt;Barrel&lt;/strong&gt; has a rounded profile. &lt;strong&gt;Orb&lt;/strong&gt; is completely spherical.&lt;/p&gt;
&lt;p&gt;The body connects the head above to the legs below, and provides attachment points for the arms on either side.&lt;/p&gt;
&lt;h3 id=&quot;arms-(10-variants)&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/pixel-art-avatar-design-anatomy-of-a-mech/#arms-(10-variants)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Arms (10 variants)&lt;/h3&gt;
&lt;p&gt;Arms extend from the body’s sides. &lt;strong&gt;Standard&lt;/strong&gt; arms are simple rectangles. &lt;strong&gt;Claws&lt;/strong&gt; end in grabby pincers. &lt;strong&gt;Cannons&lt;/strong&gt; are thick cylindrical weapons. &lt;strong&gt;Blades&lt;/strong&gt; taper to sharp points. &lt;strong&gt;None&lt;/strong&gt; removes the arms entirely for a streamlined look.&lt;/p&gt;
&lt;p&gt;Arms are drawn after the body so they can overlap the body’s edges naturally.&lt;/p&gt;
&lt;h3 id=&quot;legs-(10-variants)&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/pixel-art-avatar-design-anatomy-of-a-mech/#legs-(10-variants)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Legs (10 variants)&lt;/h3&gt;
&lt;p&gt;Legs ground the mech and affect its stance. &lt;strong&gt;Standard&lt;/strong&gt; legs are two simple columns. &lt;strong&gt;Treads&lt;/strong&gt; replace legs with tank tracks. &lt;strong&gt;Digitigrade&lt;/strong&gt; bends backward like a bird’s leg. &lt;strong&gt;Hover&lt;/strong&gt; removes ground contact entirely, showing thrust effects. &lt;strong&gt;Spider&lt;/strong&gt; adds four thin limbs. &lt;strong&gt;Wheels&lt;/strong&gt; replaces feet with circles.&lt;/p&gt;
&lt;h3 id=&quot;accessory-(10-variants)&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/pixel-art-avatar-design-anatomy-of-a-mech/#accessory-(10-variants)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Accessory (10 variants)&lt;/h3&gt;
&lt;p&gt;Accessories add the finishing touch. &lt;strong&gt;None&lt;/strong&gt; keeps it minimal. &lt;strong&gt;Jetpack&lt;/strong&gt; straps thrusters to the back. &lt;strong&gt;Shield&lt;/strong&gt; adds a protective panel to one side. &lt;strong&gt;Chest Light&lt;/strong&gt; embeds a glowing element in the torso. &lt;strong&gt;Shoulder Missiles&lt;/strong&gt; mount launchers on top. &lt;strong&gt;Energy Core&lt;/strong&gt; adds a visible power source. &lt;strong&gt;Wing Fins&lt;/strong&gt; extend small wings. &lt;strong&gt;Tail&lt;/strong&gt; appends a rear appendage.&lt;/p&gt;
&lt;p&gt;Since accessories are drawn first (behind everything else), they peek out from behind the body without covering important details.&lt;/p&gt;
&lt;h2 id=&quot;the-color-system&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/pixel-art-avatar-design-anatomy-of-a-mech/#the-color-system&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The Color System&lt;/h2&gt;
&lt;p&gt;Parts alone do not make a mech unique — color does. Each mech uses a five-color scheme:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Primary&lt;/strong&gt;: The main body and head color&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Secondary&lt;/strong&gt;: Used for arms, legs, and accents&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Accent&lt;/strong&gt;: Highlights and detail elements&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Eyes&lt;/strong&gt;: Always the eye color, designed to contrast with the head&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Background&lt;/strong&gt;: The canvas backdrop (or transparent)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;MechGen includes 12 curated palettes that ensure every random combination looks cohesive. The &lt;code&gt;darken()&lt;/code&gt; and &lt;code&gt;lighten()&lt;/code&gt; helper functions generate shading from these base colors, adding depth without requiring extra palette entries.&lt;/p&gt;
&lt;h2 id=&quot;the-math%3A-10-million-combinations&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/pixel-art-avatar-design-anatomy-of-a-mech/#the-math%3A-10-million-combinations&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The Math: 10 Million Combinations&lt;/h2&gt;
&lt;p&gt;With 10 variants per category across 7 categories, the raw combinatorial count is:&lt;/p&gt;
&lt;p&gt;10 x 10 x 10 x 10 x 10 x 10 x 10 = &lt;strong&gt;10,000,000 combinations&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Multiply that by 12 color palettes and 5 adjustable colors, and the actual design space is astronomically larger. But even at the part level, 10 million is enough to ensure that any seed string you provide — your name, your bot’s ID, a random UUID — maps to a visually distinct mech.&lt;/p&gt;
&lt;h2 id=&quot;designing-for-determinism&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/pixel-art-avatar-design-anatomy-of-a-mech/#designing-for-determinism&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Designing for Determinism&lt;/h2&gt;
&lt;p&gt;Every aspect of MechGen’s rendering is deterministic. Given the same part indices and color values, the canvas output is pixel-identical every time. This is what makes &lt;code&gt;MechGen.fromSeed()&lt;/code&gt; work: a string is hashed to a number, that number seeds a pseudorandom number generator (LCG algorithm), and the PRNG selects parts and palette in a fixed sequence.&lt;/p&gt;
&lt;p&gt;No randomness leaks in. No timing-dependent rendering. No floating-point drift. The same seed always produces the same robot, on any browser, on any device.&lt;/p&gt;
&lt;h2 id=&quot;try-it-yourself&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/pixel-art-avatar-design-anatomy-of-a-mech/#try-it-yourself&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Try It Yourself&lt;/h2&gt;
&lt;p&gt;Head over to the &lt;a href=&quot;https://mechgen.app/&quot;&gt;MechGen generator&lt;/a&gt; and click through the part categories. Watch how each swap changes the character’s personality. Or type a seed string in bot mode and see your deterministic mech materialize.&lt;/p&gt;
&lt;p&gt;Understanding the anatomy of a mech makes the generation process feel less like magic and more like design — which is exactly what it is.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Transparent Background Pixel Art: When and How to Use It</title>
    <link href="https://mechgen.app/blog/transparent-background-pixel-art/"/>
    <updated>2026-02-04T00:00:00Z</updated>
    <id>https://mechgen.app/blog/transparent-background-pixel-art/</id>
    <content type="html">&lt;h2 id=&quot;transparent-background-pixel-art%3A-when-and-how-to-use-it&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/transparent-background-pixel-art/#transparent-background-pixel-art%3A-when-and-how-to-use-it&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Transparent Background Pixel Art: When and How to Use It&lt;/h2&gt;
&lt;p&gt;A solid background color is the default for most pixel art. It’s simple, it’s predictable, and it works everywhere. But there are situations where a transparent background is the better choice – when you want your pixel art to float on top of other content, adapt to different background colors, or composite into a larger design without a visible bounding box.&lt;/p&gt;
&lt;p&gt;Transparent backgrounds add flexibility, but they also introduce complications. Not every platform handles transparency the same way, and a pixel art avatar that looks perfect with transparency in one context can look broken in another. Here’s when transparency helps, when it hurts, and how to implement it correctly.&lt;/p&gt;
&lt;h2 id=&quot;when-transparent-backgrounds-are-useful&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/transparent-background-pixel-art/#when-transparent-backgrounds-are-useful&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; When Transparent Backgrounds Are Useful&lt;/h2&gt;
&lt;h3 id=&quot;overlays-and-compositing&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/transparent-background-pixel-art/#overlays-and-compositing&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Overlays and Compositing&lt;/h3&gt;
&lt;p&gt;If you’re placing a pixel art avatar on top of a banner image, a slide deck, a stream overlay, or any other visual composition, transparency is essential. A solid-background avatar creates a visible rectangle that breaks the composition. A transparent-background avatar integrates cleanly into whatever is behind it.&lt;/p&gt;
&lt;p&gt;This is the original use case for transparent PNGs in game development – sprites need to float over backgrounds without showing a bounding box. The same principle applies to avatars used in any layered visual context.&lt;/p&gt;
&lt;h3 id=&quot;adapting-to-multiple-themes&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/transparent-background-pixel-art/#adapting-to-multiple-themes&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Adapting to Multiple Themes&lt;/h3&gt;
&lt;p&gt;Many platforms and websites support light and dark modes. An avatar with a dark blue background looks natural on a dark-themed page but creates an awkward dark rectangle on a white page. A transparent avatar adapts to both – the platform’s own background shows through, so the mech looks native in any theme.&lt;/p&gt;
&lt;h3 id=&quot;website-badges-and-embeds&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/transparent-background-pixel-art/#website-badges-and-embeds&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Website Badges and Embeds&lt;/h3&gt;
&lt;p&gt;If you’re embedding a pixel art mech as a badge on a README, a documentation site, or a personal portfolio, transparency lets it match the page’s visual style. The mech becomes a floating graphic element rather than a boxed image.&lt;/p&gt;
&lt;h3 id=&quot;profile-pictures-on-colored-surfaces&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/transparent-background-pixel-art/#profile-pictures-on-colored-surfaces&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Profile Pictures on Colored Surfaces&lt;/h3&gt;
&lt;p&gt;Some platforms display avatars on colored cards, gradient backgrounds, or patterned surfaces. Discord shows avatars on the sidebar, in messages, and in user popups – each with slightly different backgrounds. A transparent avatar works across all of these contexts without clashing.&lt;/p&gt;
&lt;h2 id=&quot;when-solid-backgrounds-are-better&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/transparent-background-pixel-art/#when-solid-backgrounds-are-better&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; When Solid Backgrounds Are Better&lt;/h2&gt;
&lt;p&gt;Transparency isn’t always the right choice. Here are the cases where a solid background wins:&lt;/p&gt;
&lt;h3 id=&quot;circular-cropping&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/transparent-background-pixel-art/#circular-cropping&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Circular Cropping&lt;/h3&gt;
&lt;p&gt;Platforms like X/Twitter and YouTube crop avatars to circles. The corners of your image are clipped regardless of whether they’re transparent or solid. With a circular crop, the background color fills the visible circle and actually contributes to the avatar’s identity. A bright cyan background behind a dark mech creates a distinctive, recognizable avatar. Transparency in a circular crop often just shows white or black (depending on the platform’s default), which can look washed out or hollow.&lt;/p&gt;
&lt;h3 id=&quot;small-display-sizes&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/transparent-background-pixel-art/#small-display-sizes&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Small Display Sizes&lt;/h3&gt;
&lt;p&gt;At very small sizes (32px in Discord chat, 20px in GitHub commit logs), transparent backgrounds mean the mech has to stand on its own without any framing. A solid background provides a consistent visual boundary that helps the mech read as a distinct avatar even at tiny sizes.&lt;/p&gt;
&lt;h3 id=&quot;high-contrast-environments&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/transparent-background-pixel-art/#high-contrast-environments&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; High-Contrast Environments&lt;/h3&gt;
&lt;p&gt;If the platform’s background color is close to your mech’s dominant color, a transparent background will make the mech partially disappear. A charcoal mech on a dark Discord sidebar becomes nearly invisible without a contrasting background behind it.&lt;/p&gt;
&lt;h2 id=&quot;how-mechgen-implements-transparency&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/transparent-background-pixel-art/#how-mechgen-implements-transparency&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; How MechGen Implements Transparency&lt;/h2&gt;
&lt;p&gt;In MechGen, transparency is handled through the background color system. Setting the background color to &lt;code&gt;&#39;transparent&#39;&lt;/code&gt; triggers three changes:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Skip background fill&lt;/strong&gt;: The render function skips the &lt;code&gt;fillRect&lt;/code&gt; call that normally paints the solid background color across the entire canvas.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Skip grid overlay&lt;/strong&gt;: The subtle grid pattern that normally appears behind the mech is also skipped, since drawing a grid on a transparent background would produce floating grid lines in the export.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Checkerboard preview&lt;/strong&gt;: The canvas element gets a CSS checkerboard pattern – the universal visual convention for “this area is transparent.” This lets you see exactly where the transparency is without it actually being a color in the exported image.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The underlying technology is the PNG alpha channel. PNG (Portable Network Graphics) supports full alpha transparency, meaning each pixel can be fully opaque, fully transparent, or anywhere in between. MechGen’s pixel art is fully opaque for the mech itself and fully transparent for the background – no partial transparency, which keeps the pixel art aesthetic clean.&lt;/p&gt;
&lt;h3 id=&quot;setting-transparency-via-the-api&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/transparent-background-pixel-art/#setting-transparency-via-the-api&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Setting Transparency via the API&lt;/h3&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Enable transparent background&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setColor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;bgColor&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;transparent&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// The canvas preview now shows a checkerboard behind the mech&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// Exports will have a fully transparent background&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Export a transparent PNG at Discord&#39;s recommended size&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;exportForPlatform&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;discord&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To switch back to a solid background:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Set a solid background color&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setColor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;bgColor&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;#1a1a2e&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;technical-detail%3A-shading-and-transparency&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/transparent-background-pixel-art/#technical-detail%3A-shading-and-transparency&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Technical Detail: Shading and Transparency&lt;/h3&gt;
&lt;p&gt;MechGen’s &lt;code&gt;darken()&lt;/code&gt; and &lt;code&gt;lighten()&lt;/code&gt; functions generate shadow and highlight colors from hex values. When the background is set to &lt;code&gt;&#39;transparent&#39;&lt;/code&gt;, these functions aren’t called for the background – there’s no hex value to manipulate. The mech parts themselves still use full shading, so you get a fully shaded robot floating on a transparent background.&lt;/p&gt;
&lt;h2 id=&quot;exporting-transparent-pngs&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/transparent-background-pixel-art/#exporting-transparent-pngs&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Exporting Transparent PNGs&lt;/h2&gt;
&lt;p&gt;When you export from MechGen with a transparent background, the output is a standard PNG file with alpha channel data. This file will work in:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Image editors&lt;/strong&gt; (Photoshop, GIMP, Figma, Pixelmator) – the transparency is preserved on import&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Web pages&lt;/strong&gt; – &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; tags and CSS &lt;code&gt;background-image&lt;/code&gt; both support PNG transparency&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Presentation software&lt;/strong&gt; – Google Slides, Keynote, and PowerPoint all handle transparent PNGs&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Stream software&lt;/strong&gt; – OBS, Streamlabs, and similar tools display transparent regions as see-through in overlays&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The one format that doesn’t support transparency is JPEG. If you or a platform converts your PNG to JPEG, the transparent regions will be filled with a solid color (usually white or black). This is a JPEG limitation, not a MechGen limitation – always verify that your target platform preserves PNG format.&lt;/p&gt;
&lt;h2 id=&quot;platform-transparency-support&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/transparent-background-pixel-art/#platform-transparency-support&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Platform Transparency Support&lt;/h2&gt;
&lt;p&gt;Here’s how major platforms handle transparent avatar uploads:&lt;/p&gt;
&lt;h3 id=&quot;discord&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/transparent-background-pixel-art/#discord&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Discord&lt;/h3&gt;
&lt;p&gt;Excellent transparency support. Transparent regions show through in all avatar contexts – message list, user panel, member sidebar. Discord’s dark theme means transparent mechs float on dark gray, which works well for most color schemes. One of the best platforms for transparent pixel art avatars.&lt;/p&gt;
&lt;h3 id=&quot;github&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/transparent-background-pixel-art/#github&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; GitHub&lt;/h3&gt;
&lt;p&gt;Good transparency support. Avatars display on white backgrounds in light mode and dark backgrounds in dark mode. Transparent mechs adapt to both. GitHub is a strong use case for transparency since many developers switch between themes.&lt;/p&gt;
&lt;h3 id=&quot;x-%2F-twitter&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/transparent-background-pixel-art/#x-%2F-twitter&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; X / Twitter&lt;/h3&gt;
&lt;p&gt;Mixed results. Twitter crops to a circle and fills transparent regions with white (light mode) or near-black (dark mode). This can work, but it can also create an unintended look if you designed the mech expecting a specific background color. Test both modes before committing to transparency here.&lt;/p&gt;
&lt;h3 id=&quot;steam&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/transparent-background-pixel-art/#steam&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Steam&lt;/h3&gt;
&lt;p&gt;Limited transparency support. Steam’s avatar display contexts generally assume opaque images. Transparent regions may render inconsistently. A solid background is usually the safer choice for Steam avatars.&lt;/p&gt;
&lt;h3 id=&quot;youtube&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/transparent-background-pixel-art/#youtube&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; YouTube&lt;/h3&gt;
&lt;p&gt;YouTube crops to a circle and generally fills transparent regions with white. Similar to Twitter, this can look fine or look odd depending on your mech’s color scheme. Solid backgrounds give more predictable results.&lt;/p&gt;
&lt;h3 id=&quot;twitch&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/transparent-background-pixel-art/#twitch&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Twitch&lt;/h3&gt;
&lt;p&gt;Decent transparency support in most contexts. The Twitch chat and channel display handle transparent PNGs reasonably well. Dark-themed by default, so transparent mechs float on Twitch’s dark purple-gray background.&lt;/p&gt;
&lt;h2 id=&quot;best-practices-for-transparent-pixel-art&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/transparent-background-pixel-art/#best-practices-for-transparent-pixel-art&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Best Practices for Transparent Pixel Art&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Design for the worst-case background.&lt;/strong&gt; Your transparent mech will appear on light backgrounds, dark backgrounds, and everything in between. Make sure the mech’s outline is distinct enough to read against any color. Avoid very dark mechs (they vanish on dark backgrounds) and very light mechs (they vanish on light backgrounds).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Consider adding an outline.&lt;/strong&gt; A 1-pixel dark outline around the mech’s silhouette ensures it stays readable on any background. This is a classic pixel art technique specifically because it solves the transparency readability problem.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Test on both light and dark backgrounds.&lt;/strong&gt; Before exporting, preview your transparent mech on white and on dark gray. If it looks good on both, it will work almost anywhere. MechGen’s checkerboard preview approximates this, but testing against solid colors is more realistic.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Use transparent for compositing, solid for standalone avatars.&lt;/strong&gt; If the mech will be placed into a designed composition (stream overlay, website, banner), use transparency. If it will be uploaded as a standalone profile picture, a solid background usually looks more polished.&lt;/p&gt;
&lt;h2 id=&quot;try-transparent-export&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/transparent-background-pixel-art/#try-transparent-export&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Try Transparent Export&lt;/h2&gt;
&lt;p&gt;Open the &lt;a href=&quot;https://mechgen.app/&quot;&gt;MechGen generator&lt;/a&gt;, click the background color picker, and set it to transparent. The checkerboard pattern will appear behind your mech, showing exactly which pixels will be see-through in the export. Download for your platform of choice and see how it looks in context – that’s the real test of whether transparency is the right choice for your use case.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Free Pixel Art Avatar Generators Compared (2026)</title>
    <link href="https://mechgen.app/blog/free-pixel-art-avatar-generators-compared/"/>
    <updated>2026-02-02T00:00:00Z</updated>
    <id>https://mechgen.app/blog/free-pixel-art-avatar-generators-compared/</id>
    <content type="html">&lt;p&gt;Choosing a free avatar generator in 2026 means navigating a crowded landscape of tools that range from simple randomizers to full-blown AI portrait systems. If you are specifically looking for pixel art or retro-style avatars, the field narrows — but there are still meaningful differences between what is available. This guide breaks down the categories, tradeoffs, and key features to help you pick the right tool for your project.&lt;/p&gt;
&lt;h2 id=&quot;what-counts-as-a-%E2%80%9Cpixel-art-avatar-generator%E2%80%9D&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/free-pixel-art-avatar-generators-compared/#what-counts-as-a-%E2%80%9Cpixel-art-avatar-generator%E2%80%9D&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; What Counts as a “Pixel Art Avatar Generator”&lt;/h2&gt;
&lt;p&gt;For this comparison, we are looking at tools that produce avatars in a distinctly pixelated or retro visual style. That excludes vector-based avatar builders (clean lines, scalable graphics), photorealistic AI portrait generators, and 3D model creators. We are focused on tools where the output looks intentionally low-resolution, chunky, and nostalgic — the kind of avatar that feels at home on a Discord server or a retro game.&lt;/p&gt;
&lt;p&gt;Within this space, the main categories are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Face generators&lt;/strong&gt; that assemble randomized human-like pixel faces from interchangeable parts (hair, eyes, mouth, skin tone)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;8-bit character makers&lt;/strong&gt; that produce full-body retro game characters with equipment and poses&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Abstract/geometric generators&lt;/strong&gt; that create identicons or pattern-based avatars from input strings&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Robot and creature generators&lt;/strong&gt; that build non-human characters from modular components&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each category serves different needs. A social app might want human faces. A blockchain project might want abstract identicons. A bot developer might want something that signals “this is not a human.”&lt;/p&gt;
&lt;h2 id=&quot;the-comparison-criteria&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/free-pixel-art-avatar-generators-compared/#the-comparison-criteria&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The Comparison Criteria&lt;/h2&gt;
&lt;h3 id=&quot;visual-style-and-aesthetic&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/free-pixel-art-avatar-generators-compared/#visual-style-and-aesthetic&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Visual Style and Aesthetic&lt;/h3&gt;
&lt;p&gt;Face generators tend to produce the most immediately recognizable avatars, but they carry a risk: they can look generic or fall into an uncanny valley where the pixel face almost looks human but not quite. Abstract identicons (the colored geometric grids you see on GitHub default avatars) are distinctive but impersonal — they are patterns, not characters.&lt;/p&gt;
&lt;p&gt;Robot and mech generators occupy an interesting middle ground. The output is clearly a character with personality, but it does not attempt to represent a real person. This makes mech avatars particularly useful for bots, AI agents, and contexts where you want to signal non-human identity without being boring.&lt;/p&gt;
&lt;p&gt;MechGen falls into this last category. Every avatar it produces is a pixel-art robot assembled from seven part categories (head, eyes, antenna, body, arms, legs, accessory), each with 10 variants. The result is always recognizably a mech but never the same mech twice.&lt;/p&gt;
&lt;h3 id=&quot;customization-depth&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/free-pixel-art-avatar-generators-compared/#customization-depth&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Customization Depth&lt;/h3&gt;
&lt;p&gt;Most free generators offer somewhere between “fully random” and “pick from 3-4 categories.” The depth of customization matters depending on your use case. If you just need a batch of unique avatars for placeholder content, a single “randomize” button is fine. If your users want to personalize their avatar, you need granular controls.&lt;/p&gt;
&lt;p&gt;Here is roughly how the landscape breaks down:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Minimal customization&lt;/strong&gt;: One-click randomizers, identicon generators. You get what you get.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Moderate customization&lt;/strong&gt;: Choose from a few categories (hairstyle, face shape, color). Common in face generators.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Deep customization&lt;/strong&gt;: Individual control over many part categories, plus color pickers for each element. Rarer in free tools.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;MechGen offers deep customization with 7 independently selectable part categories and 5 color channels (primary, secondary, accent, eyes, background), drawn from 12 curated palettes. You can cycle through parts individually or randomize everything at once.&lt;/p&gt;
&lt;h3 id=&quot;api-availability&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/free-pixel-art-avatar-generators-compared/#api-availability&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; API Availability&lt;/h3&gt;
&lt;p&gt;This is where most free generators fall short. The majority are browser-only tools with no programmatic interface. You click buttons, you download an image. That works for one-off use but fails for developers who need to generate avatars in code.&lt;/p&gt;
&lt;p&gt;A few categories of API access exist:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;No API&lt;/strong&gt;: Browser-only. Download your image manually.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;REST API with rate limits&lt;/strong&gt;: Server-hosted generation behind an HTTP endpoint. Usually requires an API key and has usage caps.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Client-side JavaScript API&lt;/strong&gt;: The generator exposes functions you can call directly in the browser or via a headless browser.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;MechGen takes the client-side approach. The global &lt;code&gt;MechGen&lt;/code&gt; object exposes methods like &lt;code&gt;fromSeed(string)&lt;/code&gt; for deterministic generation, &lt;code&gt;getImageDataURL(size)&lt;/code&gt; for base64 PNG output, and &lt;code&gt;exportForPlatform(&#39;discord&#39;)&lt;/code&gt; for platform-specific sizing. There is no server, no API key, no rate limit — everything runs in the browser.&lt;/p&gt;
&lt;p&gt;For server-side use, you can load MechGen in a headless browser like Puppeteer and call the same API. This gives you the flexibility of a REST API without depending on someone else’s server.&lt;/p&gt;
&lt;h3 id=&quot;privacy-and-data-collection&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/free-pixel-art-avatar-generators-compared/#privacy-and-data-collection&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Privacy and Data Collection&lt;/h3&gt;
&lt;p&gt;Privacy varies widely across avatar generators. Some common patterns:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;AI portrait generators&lt;/strong&gt; typically upload your photos to a server for processing. Your images may be stored, used for training, or shared with third parties. Read the terms of service carefully.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Server-side generators&lt;/strong&gt; with REST APIs log your requests by definition. The server sees every generation request and can correlate them.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Client-side generators&lt;/strong&gt; that run entirely in your browser never send data anywhere. No server sees your input.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;MechGen runs entirely client-side. There are no server calls, no analytics, no tracking, no cookies. The HTML file contains everything — all rendering logic, all part definitions, all color palettes. You could download the single HTML file, disconnect from the internet, and it would work identically.&lt;/p&gt;
&lt;p&gt;This matters for projects with strict privacy requirements or for developers who do not want to add third-party data processing disclosures to their privacy policy.&lt;/p&gt;
&lt;h3 id=&quot;cost-and-limitations&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/free-pixel-art-avatar-generators-compared/#cost-and-limitations&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Cost and Limitations&lt;/h3&gt;
&lt;p&gt;“Free” means different things across the landscape:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Free with limits&lt;/strong&gt;: Generate N avatars per day, pay for more. Common with AI-based generators.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Free with watermarks&lt;/strong&gt;: Output includes branding unless you upgrade. Common with design tools.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Free with accounts&lt;/strong&gt;: You must create an account and log in. Your usage is tracked.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Genuinely free&lt;/strong&gt;: No limits, no watermarks, no accounts. Use it however you want.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;MechGen is genuinely free. No account creation, no usage limits, no watermarks, no premium tier. The output is a clean PNG at whatever resolution you need.&lt;/p&gt;
&lt;h3 id=&quot;output-formats-and-platform-support&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/free-pixel-art-avatar-generators-compared/#output-formats-and-platform-support&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Output Formats and Platform Support&lt;/h3&gt;
&lt;p&gt;Most generators output a single PNG at one fixed resolution. Some offer SVG. Very few consider the specific requirements of different platforms — Discord wants 512x512, X (Twitter) looks best at 400x400, Steam uses 184x184, and so on.&lt;/p&gt;
&lt;p&gt;MechGen includes built-in platform export with &lt;code&gt;exportForPlatform()&lt;/code&gt; supporting Discord (512px), X (400px), Steam (184px), GitHub (460px), YouTube (800px), and Twitch (256px). The background can be set to transparent for avatars that need to sit on different colored surfaces.&lt;/p&gt;
&lt;h2 id=&quot;choosing-the-right-tool&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/free-pixel-art-avatar-generators-compared/#choosing-the-right-tool&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Choosing the Right Tool&lt;/h2&gt;
&lt;p&gt;Here is a quick decision framework:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Choose a face generator&lt;/strong&gt; if you need avatars that look like people — for social apps, user profiles, or mockups where human faces are expected.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Choose an identicon generator&lt;/strong&gt; if you need unique-but-abstract visuals tied to specific strings — for commit hashes, user IDs, or cryptographic contexts.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Choose an 8-bit character maker&lt;/strong&gt; if you need retro game-style characters with equipment and poses — for gaming communities or pixel art projects.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Choose a robot or mech generator&lt;/strong&gt; if you need avatars that are clearly non-human characters with personality — for bots, AI agents, developer tools, or anywhere you want to signal “this is a machine” while still being visually interesting.&lt;/p&gt;
&lt;h2 id=&quot;what-makes-mechgen-different&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/free-pixel-art-avatar-generators-compared/#what-makes-mechgen-different&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; What Makes MechGen Different&lt;/h2&gt;
&lt;p&gt;MechGen is not trying to be a general-purpose avatar tool. It is specifically a robot avatar generator with a developer-first API. The combination of deterministic seed-based generation, a client-side JavaScript API, zero external dependencies, and complete privacy makes it uniquely suited for a specific set of use cases: AI agent avatars, bot profile pictures, hackathon prototypes, and developer tools that need programmatic avatar generation without server infrastructure.&lt;/p&gt;
&lt;p&gt;If your project needs human faces or abstract patterns, MechGen is not the right tool. But if you need a pixel-art robot that is unique, deterministic, and generatable in one line of JavaScript, it is worth a look.&lt;/p&gt;
&lt;p&gt;Try the &lt;a href=&quot;https://mechgen.app/&quot;&gt;MechGen generator&lt;/a&gt; and see what your seed string produces.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Building a Color Palette for Pixel Art Robots</title>
    <link href="https://mechgen.app/blog/color-palettes-for-pixel-art-robots/"/>
    <updated>2026-01-30T00:00:00Z</updated>
    <id>https://mechgen.app/blog/color-palettes-for-pixel-art-robots/</id>
    <content type="html">&lt;h2 id=&quot;building-a-color-palette-for-pixel-art-robots&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/color-palettes-for-pixel-art-robots/#building-a-color-palette-for-pixel-art-robots&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Building a Color Palette for Pixel Art Robots&lt;/h2&gt;
&lt;p&gt;Color is the fastest way to ruin procedurally generated art. Give a random generator access to the full RGB spectrum and you’ll get garish, clashing combinations that look like they were designed by a malfunctioning traffic light. But constrain the color system intelligently and every random output looks intentional, cohesive, and polished.&lt;/p&gt;
&lt;p&gt;This is the central tension in procedural art: you want variety without chaos. For pixel art specifically – where you’re working with a tiny number of visible pixels – color choices carry even more weight than in higher-resolution work. Every pixel matters, and every color relationship is visible.&lt;/p&gt;
&lt;p&gt;Here’s how to build a color palette system that makes pixel art robots look good every time.&lt;/p&gt;
&lt;h2 id=&quot;the-5-role-palette-model&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/color-palettes-for-pixel-art-robots/#the-5-role-palette-model&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The 5-Role Palette Model&lt;/h2&gt;
&lt;p&gt;Rather than picking colors individually, effective pixel art palettes assign colors to roles. In MechGen’s system, each palette defines exactly 5 values:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Primary&lt;/strong&gt;: The dominant body color. This covers the largest surface area – the torso, head base, and leg structures. It’s what you “see” when you glance at the mech.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Secondary&lt;/strong&gt;: Detail and accent structure color. Used for arm segments, body panels, and structural details that break up the primary mass.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Accent&lt;/strong&gt;: High-contrast highlight color. Applied sparingly to draw attention – antenna tips, chest lights, energy cores, and joint highlights.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Eyes&lt;/strong&gt;: The eye/visor color. Often the most saturated or brightest value in the palette because eyes are the focal point of any character, even a robot.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Background&lt;/strong&gt;: The color behind the mech. This isn’t just “fill” – it establishes the contrast relationship with the entire figure.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This role-based approach means you can swap palettes freely and the mech’s visual hierarchy stays intact. A cyberpunk teal-and-magenta palette and a military olive-and-khaki palette will both produce readable mechs because the roles ensure the right colors end up in the right places.&lt;/p&gt;
&lt;h3 id=&quot;why-5-roles%2C-not-more%3F&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/color-palettes-for-pixel-art-robots/#why-5-roles%2C-not-more%3F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Why 5 Roles, Not More?&lt;/h3&gt;
&lt;p&gt;Pixel art has a long tradition of limited palettes. The NES used 4 colors per sprite. The Game Boy had 4 shades of green. Early CGA graphics had 4 colors total. These constraints weren’t just technical limitations – they forced artists to make every color count.&lt;/p&gt;
&lt;p&gt;With 5 base colors, you have enough range for a primary/secondary/accent hierarchy while keeping the total count low enough that the palette reads as unified. Add more roles and you start getting muddy compositions where no single color dominates. Fewer roles and you lose the ability to separate structural elements from detail elements.&lt;/p&gt;
&lt;p&gt;Five is the sweet spot for character sprites at the 64x64 scale.&lt;/p&gt;
&lt;h2 id=&quot;algorithmic-shading%3A-depth-from-a-single-hex-value&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/color-palettes-for-pixel-art-robots/#algorithmic-shading%3A-depth-from-a-single-hex-value&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Algorithmic Shading: Depth from a Single Hex Value&lt;/h2&gt;
&lt;p&gt;Here’s where the system gets interesting. MechGen doesn’t actually use just 5 flat colors. It generates shading variations algorithmically using &lt;code&gt;darken()&lt;/code&gt; and &lt;code&gt;lighten()&lt;/code&gt; helper functions. Given a single hex color, these functions produce shadow and highlight versions by adjusting the RGB channels:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Simplified concept&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;darken&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;hex&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; amount&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// Parse hex to RGB, reduce each channel, return new hex&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; r &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;parseInt&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;hex&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;slice&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; amount&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; g &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;parseInt&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;hex&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;slice&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; amount&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; b &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;parseInt&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;hex&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;slice&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; amount&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;r&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;padStart&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;0&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;g&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;padStart&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;0&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;b&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;padStart&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;0&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This means every base color automatically has a shadow and highlight variant. The mech’s body gets a darker underside and lighter top edge. Arm segments get shadow on one side. Legs show depth where they overlap the body. All from a single hex per role.&lt;/p&gt;
&lt;p&gt;The shading approach has a critical advantage for procedural systems: it’s automatic. You don’t need to hand-pick shadow colors for each palette. Define 5 base colors, and the darken/lighten functions derive a full shading ramp that’s always harmonious with the base.&lt;/p&gt;
&lt;h3 id=&quot;a-key-constraint&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/color-palettes-for-pixel-art-robots/#a-key-constraint&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; A Key Constraint&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;darken()&lt;/code&gt; and &lt;code&gt;lighten()&lt;/code&gt; functions only work with hex color strings – not named CSS colors or &lt;code&gt;rgb()&lt;/code&gt; values. This is a deliberate design choice. Hex strings are easy to parse component-wise, and standardizing on one format avoids edge cases. The one exception is the transparent background, which bypasses shading entirely since there’s no color to shade.&lt;/p&gt;
&lt;h2 id=&quot;what-makes-a-good-pixel-art-palette&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/color-palettes-for-pixel-art-robots/#what-makes-a-good-pixel-art-palette&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; What Makes a Good Pixel Art Palette&lt;/h2&gt;
&lt;p&gt;Whether you’re building palettes for MechGen or your own pixel art project, these principles consistently produce strong results:&lt;/p&gt;
&lt;h3 id=&quot;controlled-saturation-range&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/color-palettes-for-pixel-art-robots/#controlled-saturation-range&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Controlled Saturation Range&lt;/h3&gt;
&lt;p&gt;Limit how saturated your palette gets. One or two highly saturated colors (eyes, accent) create focal points. Primary and secondary colors should be more muted. If everything is vivid, nothing stands out.&lt;/p&gt;
&lt;h3 id=&quot;value-separation&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/color-palettes-for-pixel-art-robots/#value-separation&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Value Separation&lt;/h3&gt;
&lt;p&gt;The most important property of a palette isn’t hue – it’s value (lightness/darkness). Colors that are different hues but similar values will blend together at small sizes. Your primary and secondary colors need enough value contrast that they’re distinguishable at 32px display size.&lt;/p&gt;
&lt;p&gt;Test this by converting your palette to grayscale. If two roles become indistinguishable in grayscale, they need more value separation.&lt;/p&gt;
&lt;h3 id=&quot;temperature-consistency&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/color-palettes-for-pixel-art-robots/#temperature-consistency&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Temperature Consistency&lt;/h3&gt;
&lt;p&gt;Most strong palettes lean either warm or cool rather than mixing wildly. A warm palette (reds, oranges, ambers) with one cool accent (teal eyes) reads as intentional. A palette that bounces between warm and cool without a clear dominant temperature feels random.&lt;/p&gt;
&lt;p&gt;MechGen’s cyberpunk-themed palettes tend toward cool dominance (teals, blues, purples) with warm accents (orange, magenta, amber) – a classic combination in sci-fi visual design.&lt;/p&gt;
&lt;h3 id=&quot;background-contrast&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/color-palettes-for-pixel-art-robots/#background-contrast&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Background Contrast&lt;/h3&gt;
&lt;p&gt;The background color defines the overall contrast of the piece. Dark backgrounds make the mech pop and work well on platforms with dark themes (Discord, Steam). Light backgrounds feel more approachable and work in documentation, wikis, or light-themed UIs.&lt;/p&gt;
&lt;p&gt;For transparent backgrounds, think about where the avatar will appear. On a dark Discord sidebar, a mech with dark colors will disappear. On a white GitHub profile, a very light mech will wash out.&lt;/p&gt;
&lt;h2 id=&quot;mechgen%E2%80%99s-12-curated-palettes&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/color-palettes-for-pixel-art-robots/#mechgen%E2%80%99s-12-curated-palettes&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; MechGen’s 12 Curated Palettes&lt;/h2&gt;
&lt;p&gt;MechGen ships with 12 palettes, each tested across the full range of part combinations to ensure readability. They span a range of moods and themes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Deep cyans and electric blues for a classic cyberpunk feel&lt;/li&gt;
&lt;li&gt;Military olives, khakis, and rust for a rugged, industrial aesthetic&lt;/li&gt;
&lt;li&gt;Hot pinks and magentas for high-energy, synthwave-inspired designs&lt;/li&gt;
&lt;li&gt;Grayscale and muted tones for clean, minimal mechs&lt;/li&gt;
&lt;li&gt;Warm ambers and reds for aggressive, fiery robots&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each palette was built by selecting base colors, testing them through the darken/lighten shading system, and verifying that all 7 part categories remain visually distinct at 64x64 resolution.&lt;/p&gt;
&lt;p&gt;When you hit “Randomize” in the &lt;a href=&quot;https://mechgen.app/&quot;&gt;generator&lt;/a&gt;, the palette selection is part of the randomization. This is why every random mech looks cohesive – the palette system guarantees color harmony regardless of which parts are selected.&lt;/p&gt;
&lt;h2 id=&quot;building-your-own-palette&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/color-palettes-for-pixel-art-robots/#building-your-own-palette&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Building Your Own Palette&lt;/h2&gt;
&lt;p&gt;If you want to create custom palettes in MechGen, use the color picker controls to set each of the 5 roles. Here’s a workflow:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Start with primary.&lt;/strong&gt; Pick the dominant mood. This single color sets the character’s identity.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Choose secondary.&lt;/strong&gt; Pick a color 2-3 value steps away from primary, either warmer or cooler. This creates structural contrast.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Set the accent.&lt;/strong&gt; Go bold. This should be the most distinct color – it draws the eye and breaks up large areas.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Pick eye color.&lt;/strong&gt; High saturation or high brightness. The eyes are the focal point.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Set background.&lt;/strong&gt; Test both a dark and light option. Choose based on where you’ll use the avatar.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Then hit randomize a few times (keeping your palette) to see how the colors work across different part combinations. If any combination looks bad, adjust the problem role.&lt;/p&gt;
&lt;h2 id=&quot;constraints-create-character&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/color-palettes-for-pixel-art-robots/#constraints-create-character&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Constraints Create Character&lt;/h2&gt;
&lt;p&gt;The lesson from MechGen’s palette system applies broadly to pixel art: limitation is a feature, not a bug. Five roles, algorithmic shading, and curated palettes produce better results than unlimited color freedom because they ensure every output respects the same visual rules. When you design within constraints, the randomness becomes creative variety instead of visual noise.&lt;/p&gt;
&lt;p&gt;Try experimenting with palettes in the &lt;a href=&quot;https://mechgen.app/&quot;&gt;MechGen generator&lt;/a&gt; – swap between the 12 built-in options or build your own using the color pickers. See how the same mech transforms when you change nothing but the five colors that define it.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Zero-Dependency Web Tools: Why MechGen is a Single HTML File</title>
    <link href="https://mechgen.app/blog/single-html-file-web-app/"/>
    <updated>2026-01-28T00:00:00Z</updated>
    <id>https://mechgen.app/blog/single-html-file-web-app/</id>
    <content type="html">&lt;p&gt;&lt;a href=&quot;https://mechgen.app/&quot;&gt;MechGen&lt;/a&gt; is a pixel art mech avatar generator with over 10 million combinations, a full JavaScript API, platform-specific exports, a marketing page with feature sections, and SEO-optimized structured data. It is also a single HTML file. No React. No Vue. No Webpack. No npm install. No node_modules. Just one file with roughly 2,900 lines of HTML, CSS, and JavaScript.&lt;/p&gt;
&lt;p&gt;This is not a limitation or a shortcut. It is a deliberate architectural choice, and it comes with trade-offs worth examining.&lt;/p&gt;
&lt;h2 id=&quot;the-architecture&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/single-html-file-web-app/#the-architecture&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The Architecture&lt;/h2&gt;
&lt;p&gt;Open &lt;code&gt;index.html&lt;/code&gt; and you find three sections in the order browsers expect them:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;HTML structure&lt;/strong&gt;: Semantic markup for the full page (nav, hero, generator UI, feature sections, API docs, FAQ, footer), plus meta tags, Open Graph tags, and &lt;a href=&quot;http://schema.org/&quot;&gt;Schema.org&lt;/a&gt; structured data for SEO.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;CSS in a &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; block&lt;/strong&gt;: Dark cyberpunk theme using CSS custom properties (&lt;code&gt;--cyan&lt;/code&gt;, &lt;code&gt;--magenta&lt;/code&gt;, &lt;code&gt;--bg-deep&lt;/code&gt;), responsive breakpoints, animations, and a scanline overlay effect.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;JavaScript in a &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; block&lt;/strong&gt;: The entire application logic, including the PRNG, all drawing functions, the &lt;code&gt;MechGen&lt;/code&gt; API, UI event handlers, and export utilities.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Everything is self-contained. The only external resources are two Google Fonts loaded via &lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt; tags.&lt;/p&gt;
&lt;h2 id=&quot;canvas-based-rendering&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/single-html-file-web-app/#canvas-based-rendering&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Canvas-Based Rendering&lt;/h2&gt;
&lt;p&gt;The visual heart of MechGen is a 64x64 pixel canvas. Every mech component — heads, eyes, arms, legs, antenna, bodies, accessories — is drawn programmatically using &lt;code&gt;ctx.fillRect()&lt;/code&gt; calls. There are no sprite sheets, no SVGs, no image assets.&lt;/p&gt;
&lt;p&gt;Here is what drawing a mech part looks like in practice:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Simplified example of drawing a &quot;Dome&quot; head&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;drawDomeHead&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;ctx&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; colors&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  ctx&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;fillStyle &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; colors&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;primary&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// Main head block&lt;/span&gt;
  ctx&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fillRect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;24&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;18&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// Dome curve (stepped pixels)&lt;/span&gt;
  ctx&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fillRect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;22&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  ctx&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fillRect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;26&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// Highlight&lt;/span&gt;
  ctx&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;fillStyle &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; colors&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;lighter&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  ctx&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fillRect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;22&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Each part category has ten variants, and each variant is a function that places colored rectangles on the canvas. The drawing happens in a specific back-to-front order — accessory, legs, body, arms, head, antenna, eyes — to get correct visual layering.&lt;/p&gt;
&lt;p&gt;The 64x64 canvas is then displayed at a larger size using CSS with &lt;code&gt;image-rendering: pixelated&lt;/code&gt;, which preserves the crisp pixel edges instead of blurring them. For exports, the canvas is redrawn at the target resolution (512px default, with platform-specific sizes for Discord, GitHub, X, and others).&lt;/p&gt;
&lt;h3 id=&quot;why-canvas-over-svg-or-dom%3F&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/single-html-file-web-app/#why-canvas-over-svg-or-dom%3F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Why Canvas Over SVG or DOM?&lt;/h3&gt;
&lt;p&gt;For pixel art specifically, canvas is the natural fit:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Direct pixel control&lt;/strong&gt;: &lt;code&gt;fillRect()&lt;/code&gt; maps exactly to placing colored pixels on a grid. SVG or DOM elements would add abstraction that fights the pixel art paradigm.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Fast compositing&lt;/strong&gt;: Drawing hundreds of rectangles in a single render pass is trivially fast on canvas. No layout calculations, no reflow, no paint invalidation.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Clean export&lt;/strong&gt;: &lt;code&gt;canvas.toDataURL(&amp;quot;image/png&amp;quot;)&lt;/code&gt; gives you a base64 PNG in one call. No html2canvas hacks, no screenshot libraries.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Resolution independence&lt;/strong&gt;: Redraw at any size by scaling the coordinate system. The same drawing code produces a 128px thumbnail or an 800px YouTube avatar.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;why-no-framework%3F&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/single-html-file-web-app/#why-no-framework%3F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Why No Framework?&lt;/h2&gt;
&lt;p&gt;The honest answer: MechGen does not need one. Here is the decision framework that led to vanilla JavaScript:&lt;/p&gt;
&lt;h3 id=&quot;what-does-the-ui-actually-do%3F&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/single-html-file-web-app/#what-does-the-ui-actually-do%3F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; What does the UI actually do?&lt;/h3&gt;
&lt;p&gt;The generator UI has a canvas, some buttons, a few dropdown-style part selectors, color pickers, and text displays that show the current state. The marketing page below it is static content.&lt;/p&gt;
&lt;p&gt;This is not a data-driven dashboard with complex state flows. It is not a multi-page app with routing. There are no lists that grow and shrink dynamically, no real-time data subscriptions, no deeply nested component trees.&lt;/p&gt;
&lt;p&gt;The total interactive surface is small: click a button, update a value, re-render the canvas, sync a few text labels. Vanilla JavaScript handles this with direct DOM manipulation:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;updateUI&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getElementById&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;head-label&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;textContent &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;HEAD_NAMES&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;state&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;head&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getElementById&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;head-counter&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;textContent &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;
    &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;state&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;head &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; / 10&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// ... similar for other parts&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A framework would add an abstraction layer over operations that are already simple.&lt;/p&gt;
&lt;h3 id=&quot;what-about-state-management%3F&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/single-html-file-web-app/#what-about-state-management%3F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; What about state management?&lt;/h3&gt;
&lt;p&gt;MechGen’s state is a single flat object with about a dozen keys (seven part indices and four color values). When anything changes, the entire canvas re-renders and &lt;code&gt;updateUI()&lt;/code&gt; syncs the DOM. There is no partial update optimization needed because the render is fast (sub-millisecond for a 64x64 canvas) and the DOM updates touch fewer than 20 elements.&lt;/p&gt;
&lt;p&gt;React’s virtual DOM diffing, Vue’s reactivity system, Svelte’s compiled updates — these are powerful tools for managing complex, frequently changing UI trees. For MechGen’s scope, they would be solving a problem that does not exist.&lt;/p&gt;
&lt;h3 id=&quot;what-about-the-developer-experience%3F&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/single-html-file-web-app/#what-about-the-developer-experience%3F&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; What about the developer experience?&lt;/h3&gt;
&lt;p&gt;This is the most honest trade-off. JSX is pleasant to write. Component-based architecture is clean. Hot module replacement speeds up iteration. These are real benefits.&lt;/p&gt;
&lt;p&gt;But they come with costs: a build step, a &lt;code&gt;node_modules&lt;/code&gt; directory, configuration files, version management, and a deployment pipeline that needs to handle bundling. For a single-purpose tool, those costs outweigh the ergonomic benefits.&lt;/p&gt;
&lt;p&gt;With a single HTML file, the development workflow is: edit the file, refresh the browser. Deployment is: push the file to a static host. There is nothing to configure, nothing to update, nothing to break.&lt;/p&gt;
&lt;h2 id=&quot;the-trade-offs&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/single-html-file-web-app/#the-trade-offs&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The Trade-Offs&lt;/h2&gt;
&lt;p&gt;Being honest about the downsides matters. The single-file approach has real limitations:&lt;/p&gt;
&lt;h3 id=&quot;maintainability-at-scale&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/single-html-file-web-app/#maintainability-at-scale&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Maintainability at Scale&lt;/h3&gt;
&lt;p&gt;At 2,900 lines, the file is manageable. At 10,000 lines, it would not be. If MechGen needed to grow into a full platform with user accounts, galleries, and social features, the single-file approach would become a liability. The current scope sits comfortably within the pattern’s limits.&lt;/p&gt;
&lt;h3 id=&quot;no-component-reuse&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/single-html-file-web-app/#no-component-reuse&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; No Component Reuse&lt;/h3&gt;
&lt;p&gt;Every UI pattern is written inline. There is no button component, no card component, no reusable modal. If the same pattern appears in multiple places, it is duplicated or handled by a shared function. For MechGen’s relatively flat UI, this is fine. For a deeply nested interface, it would lead to painful repetition.&lt;/p&gt;
&lt;h3 id=&quot;testing&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/single-html-file-web-app/#testing&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Testing&lt;/h3&gt;
&lt;p&gt;Unit testing vanilla JavaScript in a single HTML file is awkward. You cannot import individual functions into a test runner without extraction. Integration testing via Playwright or Puppeteer works well (load the page, call the API, check results), but fine-grained unit tests require more effort.&lt;/p&gt;
&lt;h3 id=&quot;collaboration&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/single-html-file-web-app/#collaboration&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Collaboration&lt;/h3&gt;
&lt;p&gt;Multiple developers working on the same file leads to merge conflicts. This pattern works best for solo developers or very small teams with clear ownership boundaries.&lt;/p&gt;
&lt;h2 id=&quot;when-this-pattern-works&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/single-html-file-web-app/#when-this-pattern-works&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; When This Pattern Works&lt;/h2&gt;
&lt;p&gt;The single-file, zero-dependency approach is a good fit when:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The tool has a bounded scope&lt;/strong&gt;: MechGen generates pixel mechs. It is not going to become a social network. The feature set is defined and finite.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Performance matters more than developer ergonomics&lt;/strong&gt;: No framework means no framework overhead. The page loads instantly — there is no JavaScript bundle to parse, no hydration step, no framework initialization. The canvas renders on first paint.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Longevity matters&lt;/strong&gt;: A vanilla HTML file written today will work in browsers ten years from now. Framework code often requires ongoing maintenance just to keep up with breaking changes in the ecosystem.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Distribution simplicity matters&lt;/strong&gt;: A single file can be hosted anywhere, embedded in anything, forked with zero setup. It is the most portable format a web application can take.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;performance-characteristics&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/single-html-file-web-app/#performance-characteristics&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Performance Characteristics&lt;/h2&gt;
&lt;p&gt;The numbers speak clearly for the zero-dependency approach:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Zero JavaScript framework overhead&lt;/strong&gt;: No virtual DOM diffing, no reactivity bookkeeping, no component lifecycle management.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No build artifacts&lt;/strong&gt;: What you write is what the browser loads. No transpilation, no tree-shaking, no code splitting — because there is nothing to split.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Instant interactivity&lt;/strong&gt;: The generator is functional as soon as the script block executes. There is no hydration delay.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Minimal network requests&lt;/strong&gt;: One HTML file plus two font files. Three requests total for the complete application.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;the-philosophy&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/single-html-file-web-app/#the-philosophy&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The Philosophy&lt;/h2&gt;
&lt;p&gt;Choosing vanilla JavaScript for a tool like MechGen is not a rejection of modern frameworks. React, Vue, and Svelte are excellent tools that solve real problems at scale. The choice is about matching the tool to the job.&lt;/p&gt;
&lt;p&gt;MechGen is a focused utility that does one thing: generate pixel mechs. It does not need routing, server-side rendering, state management libraries, or a component ecosystem. Adding those things would not make it better at generating mechs. It would just make it harder to deploy, slower to load, and more complex to maintain.&lt;/p&gt;
&lt;p&gt;Sometimes the best dependency is no dependency at all.&lt;/p&gt;
&lt;p&gt;Try the &lt;a href=&quot;https://mechgen.app/&quot;&gt;MechGen generator&lt;/a&gt; to see what 2,900 lines of vanilla code can do, or read about the &lt;a href=&quot;https://mechgen.app/blog/javascript-avatar-api-bot-integration/&quot;&gt;JavaScript API&lt;/a&gt; to use it programmatically.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>How to Export Pixel Art Avatars for Every Platform</title>
    <link href="https://mechgen.app/blog/export-pixel-art-avatars-every-platform/"/>
    <updated>2026-01-25T00:00:00Z</updated>
    <id>https://mechgen.app/blog/export-pixel-art-avatars-every-platform/</id>
    <content type="html">&lt;h2 id=&quot;how-to-export-pixel-art-avatars-for-every-platform&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/export-pixel-art-avatars-every-platform/#how-to-export-pixel-art-avatars-for-every-platform&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; How to Export Pixel Art Avatars for Every Platform&lt;/h2&gt;
&lt;p&gt;You’ve created the perfect pixel art avatar. It looks crisp and clean at its native resolution. Then you upload it to Discord, and it turns into a blurry smudge. Or you set it as your GitHub profile picture, and the sharp edges you carefully placed are now soft, anti-aliased curves that destroy the pixel aesthetic.&lt;/p&gt;
&lt;p&gt;This is the most common frustration in pixel art: getting your work to display correctly at different sizes across different platforms. Each social platform has its own avatar dimensions, its own resizing algorithm, and its own way of mangling small images. Here’s how to handle all of them.&lt;/p&gt;
&lt;h2 id=&quot;platform-avatar-size-reference&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/export-pixel-art-avatars-every-platform/#platform-avatar-size-reference&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Platform Avatar Size Reference&lt;/h2&gt;
&lt;p&gt;Every major platform has a recommended (or required) avatar size. Using the right dimensions from the start avoids unnecessary resampling:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Platform&lt;/th&gt;
&lt;th&gt;Recommended Size&lt;/th&gt;
&lt;th&gt;Notes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;X / Twitter&lt;/td&gt;
&lt;td&gt;400 x 400 px&lt;/td&gt;
&lt;td&gt;Displayed at 200px, uploaded at 400px for retina&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Discord&lt;/td&gt;
&lt;td&gt;512 x 512 px&lt;/td&gt;
&lt;td&gt;Maximum upload size, displayed at 128px or smaller&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Steam&lt;/td&gt;
&lt;td&gt;184 x 184 px&lt;/td&gt;
&lt;td&gt;Exact display size for profile avatars&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GitHub&lt;/td&gt;
&lt;td&gt;460 x 460 px&lt;/td&gt;
&lt;td&gt;Displayed at various sizes across the UI&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;YouTube&lt;/td&gt;
&lt;td&gt;800 x 800 px&lt;/td&gt;
&lt;td&gt;Used across channel page, comments, and cards&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Twitch&lt;/td&gt;
&lt;td&gt;256 x 256 px&lt;/td&gt;
&lt;td&gt;Minimum 200x200, displayed at various sizes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The pattern is clear: most platforms want images between 256px and 800px, and they handle downscaling to display sizes internally. Your job is to provide a source image at the right resolution with the right scaling method.&lt;/p&gt;
&lt;h2 id=&quot;the-pixel-art-upscaling-problem&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/export-pixel-art-avatars-every-platform/#the-pixel-art-upscaling-problem&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The Pixel Art Upscaling Problem&lt;/h2&gt;
&lt;p&gt;Standard image resizing uses bilinear or bicubic interpolation – algorithms designed to create smooth transitions between pixels. This is ideal for photographs but devastating for pixel art. A sharp 1-pixel border between two colors becomes a 3-pixel gradient smear. Hard edges vanish. The entire aesthetic breaks.&lt;/p&gt;
&lt;p&gt;The solution is &lt;strong&gt;nearest-neighbor scaling&lt;/strong&gt; (sometimes called point sampling). This algorithm simply duplicates each pixel into a larger block without blending. A 64x64 image scaled to 512x512 with nearest-neighbor turns each original pixel into an 8x8 block of identical color. Every edge stays sharp.&lt;/p&gt;
&lt;h3 id=&quot;how-to-get-nearest-neighbor-scaling&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/export-pixel-art-avatars-every-platform/#how-to-get-nearest-neighbor-scaling&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; How to Get Nearest-Neighbor Scaling&lt;/h3&gt;
&lt;p&gt;In CSS, the property is:&lt;/p&gt;
&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token property&quot;&gt;image-rendering&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; pixelated&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This tells the browser to use nearest-neighbor when scaling an &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt; element. MechGen applies this to its canvas so the 64x64 mech art looks crisp at any display size.&lt;/p&gt;
&lt;p&gt;When exporting, the scaling happens on a temporary canvas using JavaScript:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Create a larger canvas&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; exportCanvas &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;canvas&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
exportCanvas&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;width &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; targetSize&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
exportCanvas&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;height &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; targetSize&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; ctx &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; exportCanvas&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getContext&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;2d&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Disable image smoothing for nearest-neighbor scaling&lt;/span&gt;
ctx&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;imageSmoothingEnabled &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Draw the small source onto the large canvas&lt;/span&gt;
ctx&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;drawImage&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;sourceCanvas&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; targetSize&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; targetSize&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Setting &lt;code&gt;imageSmoothingEnabled = false&lt;/code&gt; on the canvas context is the export-time equivalent of &lt;code&gt;image-rendering: pixelated&lt;/code&gt;. This ensures the PNG file itself contains crisp pixels, not just the on-screen display.&lt;/p&gt;
&lt;h2 id=&quot;using-mechgen%E2%80%99s-platform-exports&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/export-pixel-art-avatars-every-platform/#using-mechgen%E2%80%99s-platform-exports&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Using MechGen’s Platform Exports&lt;/h2&gt;
&lt;p&gt;MechGen includes built-in export functions that handle the sizing automatically. In the generator UI, the social export card lets you download pre-sized avatars for each platform with a single click.&lt;/p&gt;
&lt;p&gt;If you’re using the JavaScript API, the &lt;code&gt;exportForPlatform()&lt;/code&gt; method takes a platform name and triggers a download at the correct size:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Download a 512x512 PNG for Discord&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;exportForPlatform&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;discord&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Download a 400x400 PNG for X/Twitter&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;exportForPlatform&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;x&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Download a 184x184 PNG for Steam&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;exportForPlatform&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;steam&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For custom sizes, &lt;code&gt;getImageDataURL()&lt;/code&gt; returns a base64 PNG data URL at any specified dimension:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Get a 1024x1024 data URL for custom use&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; dataUrl &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getImageDataURL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1024&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;All exports use nearest-neighbor scaling internally, so you never have to worry about blurry output.&lt;/p&gt;
&lt;h2 id=&quot;transparent-background-export&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/export-pixel-art-avatars-every-platform/#transparent-background-export&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Transparent Background Export&lt;/h2&gt;
&lt;p&gt;Sometimes you need an avatar without a background – for overlaying on a custom color, compositing into a banner, or placing on a platform that applies its own background treatment.&lt;/p&gt;
&lt;p&gt;MechGen supports transparent background export. When the background color is set to &lt;code&gt;&#39;transparent&#39;&lt;/code&gt;, the generator:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Skips the background fill entirely (no solid color behind the mech)&lt;/li&gt;
&lt;li&gt;Skips the grid pattern that normally appears behind the art&lt;/li&gt;
&lt;li&gt;Shows a checkerboard pattern in the canvas preview (the universal convention for “this area is transparent”)&lt;/li&gt;
&lt;li&gt;Exports a PNG with an alpha channel, so the background is genuinely transparent&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Set transparent background&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setColor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;bgColor&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;transparent&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Export -- the PNG will have a transparent background&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;exportForPlatform&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;discord&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Transparent backgrounds are especially useful for platforms that display avatars on colored cards or gradient backgrounds, since your mech won’t have a conspicuous colored square around it.&lt;/p&gt;
&lt;h2 id=&quot;platform-specific-tips&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/export-pixel-art-avatars-every-platform/#platform-specific-tips&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Platform-Specific Tips&lt;/h2&gt;
&lt;h3 id=&quot;x-%2F-twitter&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/export-pixel-art-avatars-every-platform/#x-%2F-twitter&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; X / Twitter&lt;/h3&gt;
&lt;p&gt;Export at 400x400. Twitter crops avatars to a circle in most views, so keep important details away from the corners. Transparent backgrounds will show as white in the circular crop on light mode and black on dark mode – so a solid background is often better here unless you specifically want that effect.&lt;/p&gt;
&lt;h3 id=&quot;discord&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/export-pixel-art-avatars-every-platform/#discord&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Discord&lt;/h3&gt;
&lt;p&gt;Export at 512x512. Discord displays avatars at small sizes (32px-128px depending on context), so high-contrast designs with bold shapes read better than intricate details. Discord handles transparent PNGs well – the transparency shows through in most contexts, making it a great platform for transparent mech exports.&lt;/p&gt;
&lt;h3 id=&quot;steam&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/export-pixel-art-avatars-every-platform/#steam&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Steam&lt;/h3&gt;
&lt;p&gt;Export at 184x184. This is unusually small compared to other platforms, meaning your source art needs to hold up at low resolution. MechGen’s 64x64 base scales cleanly to 184px (approximately 2.875x), and since the export uses nearest-neighbor, there’s no blur. Bold, high-contrast mechs work best at this size.&lt;/p&gt;
&lt;h3 id=&quot;github&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/export-pixel-art-avatars-every-platform/#github&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; GitHub&lt;/h3&gt;
&lt;p&gt;Export at 460x460. GitHub shows your avatar at various sizes across the UI – from small 20px icons in commit logs to larger displays on your profile page. The platform handles downscaling well, so a 460px source gives you clean results at every size. GitHub also handles transparent PNGs correctly, showing them over the default page background.&lt;/p&gt;
&lt;h3 id=&quot;youtube&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/export-pixel-art-avatars-every-platform/#youtube&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; YouTube&lt;/h3&gt;
&lt;p&gt;Export at 800x800. YouTube uses your avatar in more contexts than almost any other platform: channel page, video page, comments, recommended channels, YouTube Shorts, and mobile app. At 800px, you provide enough resolution for all of these contexts. YouTube crops to a circle, so the same advice as Twitter applies – keep details centered.&lt;/p&gt;
&lt;h3 id=&quot;twitch&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/export-pixel-art-avatars-every-platform/#twitch&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Twitch&lt;/h3&gt;
&lt;p&gt;Export at 256x256. Twitch shows avatars at relatively small sizes in chat and channel listings. Bold, simple designs with high contrast read the best. Twitch handles transparent PNGs, but many streamers prefer a solid background that matches their channel branding.&lt;/p&gt;
&lt;h2 id=&quot;general-best-practices&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/export-pixel-art-avatars-every-platform/#general-best-practices&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; General Best Practices&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Always export at the target size, don’t resize after.&lt;/strong&gt; If you export a 512px PNG and then resize it to 400px in an image editor, the editor might use bilinear interpolation and blur your pixel art. Export at the exact size you need.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Test at display size, not export size.&lt;/strong&gt; Your avatar might look great at 512px but unreadable at 32px (the size Discord uses in message lists). Zoom out or shrink your browser to preview how the design reads at small sizes.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Choose colors with contrast in mind.&lt;/strong&gt; On dark-themed platforms (Discord, Steam, Twitch), light-colored mechs stand out. On light-themed platforms or dual-theme platforms (GitHub, X), mid-tone backgrounds help the avatar work in both modes.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Use integer scaling when possible.&lt;/strong&gt; A 64px source scales perfectly to 128, 256, and 512 (2x, 4x, 8x). Non-integer scaling factors like 2.875x (for Steam’s 184px) still work with nearest-neighbor, but some pixels will be slightly different sizes. At these dimensions, the difference is imperceptible.&lt;/p&gt;
&lt;h2 id=&quot;export-once%2C-use-everywhere&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/export-pixel-art-avatars-every-platform/#export-once%2C-use-everywhere&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Export Once, Use Everywhere&lt;/h2&gt;
&lt;p&gt;Head to the &lt;a href=&quot;https://mechgen.app/&quot;&gt;MechGen generator&lt;/a&gt; and design your mech. Use the social export buttons to grab correctly-sized versions for every platform you use. With nearest-neighbor upscaling baked into every export, your pixel art stays pixel-perfect no matter where it ends up.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Why Every AI Agent Needs a Unique Visual Identity</title>
    <link href="https://mechgen.app/blog/ai-agent-visual-identity/"/>
    <updated>2026-01-23T00:00:00Z</updated>
    <id>https://mechgen.app/blog/ai-agent-visual-identity/</id>
    <content type="html">&lt;p&gt;When you interact with a customer support chatbot, a coding assistant, or an AI research agent, what do you see? Usually nothing. Maybe a generic robot icon. Maybe a company logo. Maybe just a colored circle with the letter “A.”&lt;/p&gt;
&lt;p&gt;This is a UX problem hiding in plain sight. As AI agents become more sophisticated and more numerous, the lack of visual identity creates real friction: users cannot tell agents apart, they do not form trust with faceless tools, and multi-agent systems become a wall of indistinguishable text.&lt;/p&gt;
&lt;p&gt;Giving agents distinct visual identities is not cosmetic polish. It is a design decision that directly impacts how people perceive, remember, and interact with AI.&lt;/p&gt;
&lt;h2 id=&quot;humans-are-wired-to-read-faces&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-visual-identity/#humans-are-wired-to-read-faces&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Humans Are Wired to Read Faces&lt;/h2&gt;
&lt;p&gt;Decades of cognitive science research confirms something intuitive: humans process faces differently from other visual stimuli. We have dedicated neural machinery for facial recognition, and we apply it liberally. We see faces in electrical outlets, in the front grilles of cars, in arrangements of rocks.&lt;/p&gt;
&lt;p&gt;This tendency, called pareidolia, extends to digital interfaces. When a chatbot has even a simple avatar with “eye-like” features, users subconsciously engage with it as more of an entity and less of a text box. Studies in human-computer interaction have consistently shown that agents with visual representations receive more engagement, more patience during errors, and higher trust ratings.&lt;/p&gt;
&lt;p&gt;You do not need a photorealistic face to trigger this effect. In fact, you probably should not use one.&lt;/p&gt;
&lt;h2 id=&quot;the-uncanny-valley-problem&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-visual-identity/#the-uncanny-valley-problem&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The Uncanny Valley Problem&lt;/h2&gt;
&lt;p&gt;Photorealistic AI avatars are technically impressive and frequently counterproductive. When a digital face looks almost human but not quite right, users experience discomfort, the well-documented uncanny valley effect. This is worse than having no face at all, because it actively erodes trust.&lt;/p&gt;
&lt;p&gt;The current generation of AI-generated portrait avatars sits squarely in this uncomfortable zone. They look polished enough to raise expectations of human behavior, then fail to deliver. The result is a subtle but persistent sense that something is off.&lt;/p&gt;
&lt;p&gt;Pixel art sidesteps this entirely. A 64x64 pixel mech with block eyes and antenna does not pretend to be human. It declares itself as artificial, as a machine, which is exactly what an AI agent is. There is no mismatch between appearance and reality.&lt;/p&gt;
&lt;p&gt;This honesty in design has an underappreciated benefit: it sets appropriate expectations. Users who see a pixel robot avatar approach the interaction knowing they are talking to a tool. They calibrate their expectations accordingly, which leads to more productive interactions and less frustration.&lt;/p&gt;
&lt;h2 id=&quot;why-pixel-art-works-for-bot-avatars&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-visual-identity/#why-pixel-art-works-for-bot-avatars&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Why Pixel Art Works for Bot Avatars&lt;/h2&gt;
&lt;p&gt;Beyond avoiding the uncanny valley, pixel art has specific properties that make it well-suited for AI agent identity:&lt;/p&gt;
&lt;h3 id=&quot;distinctiveness-at-small-sizes&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-visual-identity/#distinctiveness-at-small-sizes&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Distinctiveness at Small Sizes&lt;/h3&gt;
&lt;p&gt;Avatars appear at small sizes in most interfaces: 32px in chat bubbles, 48px in sidebars, 64px in dashboards. Pixel art is designed for these constraints. A pixel mech with a horned head and cannon arms is immediately distinguishable from one with a dome head and tentacle arms, even at thumbnail scale. Photorealistic avatars lose their distinguishing features when scaled down; pixel art retains them.&lt;/p&gt;
&lt;h3 id=&quot;nostalgic-and-non-threatening&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-visual-identity/#nostalgic-and-non-threatening&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Nostalgic and Non-Threatening&lt;/h3&gt;
&lt;p&gt;Pixel art carries strong associations with retro gaming, an era most people remember fondly. These associations make pixel avatars feel approachable and playful rather than clinical or intimidating. For AI agents that users might already be wary of, this warmth matters.&lt;/p&gt;
&lt;h3 id=&quot;fast-to-generate-and-lightweight&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-visual-identity/#fast-to-generate-and-lightweight&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Fast to Generate and Lightweight&lt;/h3&gt;
&lt;p&gt;A pixel mech rendered on a 64x64 canvas is a few kilobytes as a PNG. There are no model weights to run, no diffusion steps to wait for, no API costs per generation. An avatar can be generated in milliseconds from a simple seed string, making it practical to assign unique identities to thousands of agents without any infrastructure overhead.&lt;/p&gt;
&lt;h3 id=&quot;combinatorial-variety&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-visual-identity/#combinatorial-variety&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Combinatorial Variety&lt;/h3&gt;
&lt;p&gt;With seven part categories (head, eyes, antenna, body, arms, legs, accessory) each having ten variants, combined with curated color palettes, the possibility space exceeds ten million unique combinations. That is more than enough to ensure every agent in any system gets a distinct appearance. Tools like &lt;a href=&quot;https://mechgen.app/&quot;&gt;MechGen&lt;/a&gt; make this combinatorial space accessible through a single function call.&lt;/p&gt;
&lt;h2 id=&quot;identity-in-multi-agent-systems&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-visual-identity/#identity-in-multi-agent-systems&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Identity in Multi-Agent Systems&lt;/h2&gt;
&lt;p&gt;The visual identity argument becomes even stronger when users interact with multiple agents simultaneously. Frameworks like CrewAI, AutoGen, and LangGraph enable systems where several specialized agents collaborate: a researcher gathers information, an analyst processes it, a writer drafts output, a reviewer checks quality.&lt;/p&gt;
&lt;p&gt;In these systems, the conversation log becomes a multi-party dialogue. Without visual differentiation, users must read the agent name on every message to track who said what. This is cognitively expensive and slow.&lt;/p&gt;
&lt;p&gt;With distinct avatars, users can scan the conversation visually. The teal mech with scanner eyes is the researcher. The red mech with the angular head is the critic. Pattern recognition takes over, and comprehension speed increases dramatically.&lt;/p&gt;
&lt;p&gt;This is not speculation. The same principle drives why messaging apps use profile photos and why code editors use distinct colors for different speakers in pair programming tools. Visual identity is a cognitive shortcut, and it works.&lt;/p&gt;
&lt;h2 id=&quot;practical-advice-for-agent-developers&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-visual-identity/#practical-advice-for-agent-developers&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Practical Advice for Agent Developers&lt;/h2&gt;
&lt;p&gt;If you are building agents and want to implement visual identity well, here are principles worth following:&lt;/p&gt;
&lt;h3 id=&quot;make-it-deterministic&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-visual-identity/#make-it-deterministic&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Make It Deterministic&lt;/h3&gt;
&lt;p&gt;An agent’s avatar should be the same every time a user encounters it. Consistency builds recognition. If the avatar changes between sessions, you lose the accumulated trust and familiarity. Seed-based generation (where the agent’s name or ID produces the same avatar every time) is the most reliable approach.&lt;/p&gt;
&lt;h3 id=&quot;make-it-distinct%2C-not-detailed&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-visual-identity/#make-it-distinct%2C-not-detailed&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Make It Distinct, Not Detailed&lt;/h3&gt;
&lt;p&gt;You need agents to be distinguishable from each other, not to be works of art. A limited palette with strong silhouette differences (different head shapes, arm styles, leg types) achieves this better than subtle color variations on the same template.&lt;/p&gt;
&lt;h3 id=&quot;keep-it-honest&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-visual-identity/#keep-it-honest&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Keep It Honest&lt;/h3&gt;
&lt;p&gt;Do not make your AI agent’s avatar look human. Users will discover it is not human, and they will feel deceived. An obviously robotic or mechanical avatar signals transparency about what the agent is.&lt;/p&gt;
&lt;h3 id=&quot;make-it-automatic&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-visual-identity/#make-it-automatic&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Make It Automatic&lt;/h3&gt;
&lt;p&gt;If assigning avatars requires manual work (uploading images, picking from a gallery, commissioning art), it will not scale, and most agents will end up with defaults. The best system is one where every agent gets an avatar automatically based on its identifier, with zero manual intervention.&lt;/p&gt;
&lt;h3 id=&quot;consider-the-context&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-visual-identity/#consider-the-context&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Consider the Context&lt;/h3&gt;
&lt;p&gt;A pixel mech works great in developer tools, chat interfaces, and dashboards. If your product targets enterprise executives, you might want a more minimal geometric style. The principle (unique, consistent, non-human) stays the same; the aesthetic adapts to your audience.&lt;/p&gt;
&lt;h2 id=&quot;the-identity-layer&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-visual-identity/#the-identity-layer&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The Identity Layer&lt;/h2&gt;
&lt;p&gt;As AI agents proliferate, the tools and frameworks for building them have matured rapidly. We have sophisticated orchestration, memory systems, tool use, and planning capabilities. But the identity layer, how agents present themselves to humans, remains underdeveloped.&lt;/p&gt;
&lt;p&gt;Visual identity is the simplest and most impactful piece of that layer. A unique avatar does not just make your agent look better. It makes your agent more recognizable, more trustworthy, and more effective in multi-agent contexts.&lt;/p&gt;
&lt;p&gt;The technology to generate millions of unique, deterministic, lightweight avatars already exists. &lt;a href=&quot;https://mechgen.app/&quot;&gt;MechGen&lt;/a&gt; offers over 10 million combinations through a zero-dependency JavaScript API. Every agent gets a face from a single seed string, with no image storage, no design work, and no API costs.&lt;/p&gt;
&lt;p&gt;The only thing left is to stop shipping agents without faces.&lt;/p&gt;
&lt;h2 id=&quot;further-reading&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-visual-identity/#further-reading&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Further Reading&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://mechgen.app/blog/ai-agent-avatars-deterministic-seeds/&quot;&gt;Give Your AI Agent a Face: Deterministic Avatars from Seed Strings&lt;/a&gt; – technical deep-dive on seed-based generation&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://mechgen.app/blog/javascript-avatar-api-bot-integration/&quot;&gt;Integrating MechGen’s JavaScript API into Your Bot&lt;/a&gt; – code examples for Discord, Slack, and web apps&lt;/li&gt;
&lt;/ul&gt;
</content>
  </entry>
  
  <entry>
    <title>Pixel Avatars for Discord Bots: A Developer&#39;s Guide</title>
    <link href="https://mechgen.app/blog/discord-bot-pixel-avatars-guide/"/>
    <updated>2026-01-22T00:00:00Z</updated>
    <id>https://mechgen.app/blog/discord-bot-pixel-avatars-guide/</id>
    <content type="html">&lt;p&gt;A Discord bot without an avatar looks unfinished. The default gray Discord logo signals “the developer did not bother,” and in a server list full of bots with polished icons, yours will blend into the background. But commissioning custom art takes time and money, and finding a free icon that is not already used by a dozen other bots is surprisingly difficult.&lt;/p&gt;
&lt;p&gt;Pixel art solves this elegantly. A pixel-art avatar is immediately recognizable in a server list. It reads clearly at small sizes. And it signals exactly the right thing: this is a bot, not a person, and it has character. This guide walks through generating and setting pixel-art bot avatars programmatically using MechGen and Discord.js.&lt;/p&gt;
&lt;h2 id=&quot;discord%E2%80%99s-avatar-requirements&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/discord-bot-pixel-avatars-guide/#discord%E2%80%99s-avatar-requirements&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Discord’s Avatar Requirements&lt;/h2&gt;
&lt;p&gt;Before generating anything, you need to know what Discord expects:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Recommended size&lt;/strong&gt;: 512x512 pixels (displayed at 128x128 in most contexts)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Formats&lt;/strong&gt;: PNG, JPG, or GIF (animated avatars require Nitro for users, but bots can use static images without restrictions)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Max file size&lt;/strong&gt;: 8MB&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Aspect ratio&lt;/strong&gt;: Square (1:1). Non-square images will be cropped.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Minimum size&lt;/strong&gt;: 128x128, but higher resolution is recommended for clarity on high-DPI screens&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For bot avatars specifically, 512x512 PNG is the sweet spot. It is large enough to look crisp on any screen, small enough to stay well under the 8MB limit, and PNG preserves the hard pixel edges that make pixel art look sharp.&lt;/p&gt;
&lt;p&gt;Avoid JPG for pixel art — the lossy compression smudges the clean pixel boundaries that give the style its charm.&lt;/p&gt;
&lt;h2 id=&quot;why-pixel-art-works-for-bots&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/discord-bot-pixel-avatars-guide/#why-pixel-art-works-for-bots&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Why Pixel Art Works for Bots&lt;/h2&gt;
&lt;p&gt;Pixel art has a few properties that make it ideal for bot avatars specifically:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Reads at small sizes.&lt;/strong&gt; Discord renders avatars at 32x32 or 40x40 in message lists. Complex illustrations turn to mush at these sizes. Pixel art, designed for low resolution, stays legible.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Instantly signals “not a human.”&lt;/strong&gt; A pixel robot avatar makes it immediately obvious that the user is interacting with a bot. This sets expectations correctly.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Scales without blurring.&lt;/strong&gt; With &lt;code&gt;image-rendering: pixelated&lt;/code&gt; (or nearest-neighbor scaling), pixel art scales up cleanly. A 64x64 source image becomes a crisp 512x512 export with no interpolation artifacts.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Deterministic generation is possible.&lt;/strong&gt; Unlike AI-generated portraits or hand-drawn illustrations, pixel art from modular parts can be generated from a seed string. The same bot name always produces the same avatar.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;generating-a-bot-avatar-with-mechgen&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/discord-bot-pixel-avatars-guide/#generating-a-bot-avatar-with-mechgen&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Generating a Bot Avatar with MechGen&lt;/h2&gt;
&lt;p&gt;MechGen is a client-side pixel-art mech avatar generator. Every mech is assembled from 7 part categories with 10 variants each, colored by one of 12 curated palettes. The key feature for bot developers is &lt;code&gt;MechGen.fromSeed(string)&lt;/code&gt; — pass in any string and get a deterministic, unique robot avatar.&lt;/p&gt;
&lt;h3 id=&quot;quick-manual-approach&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/discord-bot-pixel-avatars-guide/#quick-manual-approach&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Quick Manual Approach&lt;/h3&gt;
&lt;p&gt;If you just need a one-time avatar for your bot:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open the &lt;a href=&quot;https://mechgen.app/&quot;&gt;MechGen generator&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Find the Bot Mode card and enter your bot’s name as the seed&lt;/li&gt;
&lt;li&gt;Click Generate (or press Enter)&lt;/li&gt;
&lt;li&gt;Click the Discord export button in the social export card&lt;/li&gt;
&lt;li&gt;Upload the downloaded 512x512 PNG to the Discord Developer Portal under your bot’s settings&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This takes about 30 seconds and gives you a unique avatar tied to your bot’s identity.&lt;/p&gt;
&lt;h3 id=&quot;programmatic-approach-with-puppeteer&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/discord-bot-pixel-avatars-guide/#programmatic-approach-with-puppeteer&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Programmatic Approach with Puppeteer&lt;/h3&gt;
&lt;p&gt;For bots that need to generate avatars at runtime — or if you want to automate avatar generation as part of your CI/CD pipeline — you can drive MechGen from a headless browser.&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; puppeteer &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;puppeteer&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;generateBotAvatar&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;seed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; browser &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; puppeteer&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;launch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; page &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; browser&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;newPage&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;// Load MechGen (use the live site or a local copy)&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; page&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;goto&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;https://mechgen.app&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;// Generate a deterministic mech from the seed&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; dataUrl &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; page&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;evaluate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;s&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getImageDataURL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;512&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; seed&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; browser&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;// Convert data URL to Buffer&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; base64 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; dataUrl&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token regex&quot;&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-source language-regex&quot;&gt;^data:image&#92;/png;base64,&lt;/span&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; Buffer&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;base64&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;base64&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This function takes a seed string, loads MechGen in a headless Chromium instance, generates the mech, and returns a PNG buffer. The same seed always produces the same image.&lt;/p&gt;
&lt;h3 id=&quot;setting-the-avatar-with-discord.js&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/discord-bot-pixel-avatars-guide/#setting-the-avatar-with-discord.js&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Setting the Avatar with Discord.js&lt;/h3&gt;
&lt;p&gt;Once you have the PNG buffer, setting it as your bot’s avatar with Discord.js is straightforward:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; Client&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; GatewayIntentBits &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;discord.js&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; client &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Client&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;intents&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;GatewayIntentBits&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Guilds&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

client&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;once&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;ready&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;Logged in as &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;client&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;user&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;tag&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;// Generate avatar from bot&#39;s username&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; avatarBuffer &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;generateBotAvatar&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;client&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;user&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;username&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;// Set the avatar&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; client&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;user&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAvatar&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;avatarBuffer&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Avatar updated successfully&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

client&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;login&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;process&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;env&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;DISCORD_TOKEN&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A few important notes about &lt;code&gt;setAvatar()&lt;/code&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Rate limits&lt;/strong&gt;: Discord rate-limits avatar changes. You can only change a bot’s avatar twice per hour. Do not call this on every startup — check if an update is needed first.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Error handling&lt;/strong&gt;: Wrap the &lt;code&gt;setAvatar()&lt;/code&gt; call in a try/catch. If the rate limit is hit, Discord throws an error with a &lt;code&gt;retryAfter&lt;/code&gt; value.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;One-time setup&lt;/strong&gt;: For most bots, you generate the avatar once and never change it. Run the avatar generation as a separate script or a one-time setup command, not as part of your bot’s normal startup.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;caching-the-avatar-locally&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/discord-bot-pixel-avatars-guide/#caching-the-avatar-locally&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Caching the Avatar Locally&lt;/h3&gt;
&lt;p&gt;To avoid regenerating the avatar on every deployment, save it to disk:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; fs &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;fs&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; path &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;path&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;ensureAvatar&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;seed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; avatarPath &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; path&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;__dirname&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;avatar.png&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;// Use cached version if it exists&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;fs&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;existsSync&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;avatarPath&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; fs&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;readFileSync&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;avatarPath&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;// Generate and cache&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; buffer &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;generateBotAvatar&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;seed&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  fs&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;writeFileSync&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;avatarPath&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; buffer&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; buffer&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This way, Puppeteer only runs once. Subsequent deployments read the cached PNG.&lt;/p&gt;
&lt;h2 id=&quot;using-a-local-copy-of-mechgen&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/discord-bot-pixel-avatars-guide/#using-a-local-copy-of-mechgen&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Using a Local Copy of MechGen&lt;/h2&gt;
&lt;p&gt;Since MechGen is a single HTML file with no external dependencies (other than Google Fonts, which are not required for generation), you can bundle a local copy with your bot:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Point Puppeteer at a local file instead of the live site&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; page&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;goto&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;file://&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;path&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;__dirname&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;mechgen.html&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This eliminates the network dependency entirely. Your avatar generation works offline, in Docker containers, in CI environments — anywhere Puppeteer can run.&lt;/p&gt;
&lt;h2 id=&quot;generating-unique-avatars-per-server&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/discord-bot-pixel-avatars-guide/#generating-unique-avatars-per-server&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Generating Unique Avatars per Server&lt;/h2&gt;
&lt;p&gt;Some bots have different “personalities” per server. You can generate server-specific avatars by combining the bot name with the guild ID:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; seed &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;client&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;user&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;username&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;guild&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; avatarBuffer &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;generateBotAvatar&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;seed&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;While Discord does not support per-server bot avatars natively, you can use this approach to generate unique images for documentation, dashboards, or embed thumbnails that vary by server context.&lt;/p&gt;
&lt;h2 id=&quot;platform-export-sizes&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/discord-bot-pixel-avatars-guide/#platform-export-sizes&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Platform Export Sizes&lt;/h2&gt;
&lt;p&gt;MechGen includes built-in platform-aware export. If you are generating avatars for contexts beyond Discord, here are the supported platforms and their recommended sizes:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Platform&lt;/th&gt;
&lt;th&gt;Size&lt;/th&gt;
&lt;th&gt;MechGen Method&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Discord&lt;/td&gt;
&lt;td&gt;512px&lt;/td&gt;
&lt;td&gt;&lt;code&gt;exportForPlatform(&#39;discord&#39;)&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;X (Twitter)&lt;/td&gt;
&lt;td&gt;400px&lt;/td&gt;
&lt;td&gt;&lt;code&gt;exportForPlatform(&#39;x&#39;)&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GitHub&lt;/td&gt;
&lt;td&gt;460px&lt;/td&gt;
&lt;td&gt;&lt;code&gt;exportForPlatform(&#39;github&#39;)&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Steam&lt;/td&gt;
&lt;td&gt;184px&lt;/td&gt;
&lt;td&gt;&lt;code&gt;exportForPlatform(&#39;steam&#39;)&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;YouTube&lt;/td&gt;
&lt;td&gt;800px&lt;/td&gt;
&lt;td&gt;&lt;code&gt;exportForPlatform(&#39;youtube&#39;)&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Twitch&lt;/td&gt;
&lt;td&gt;256px&lt;/td&gt;
&lt;td&gt;&lt;code&gt;exportForPlatform(&#39;twitch&#39;)&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;In the Puppeteer context, you can call &lt;code&gt;MechGen.getImageDataURL(512)&lt;/code&gt; with any custom size, or use the platform helpers for standard dimensions.&lt;/p&gt;
&lt;h2 id=&quot;putting-it-all-together&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/discord-bot-pixel-avatars-guide/#putting-it-all-together&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Putting It All Together&lt;/h2&gt;
&lt;p&gt;Here is a minimal but complete script that generates a MechGen avatar and sets it on a Discord bot:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; puppeteer &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;puppeteer&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; Client&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; GatewayIntentBits &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;discord.js&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; fs &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;fs&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;generateAvatar&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;seed&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; size &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;512&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; browser &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; puppeteer&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;launch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; page &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; browser&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;newPage&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; page&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;goto&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;https://mechgen.app&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; dataUrl &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; page&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;evaluate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;s&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; sz&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;s&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getImageDataURL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;sz&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; seed&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; size&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; browser&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; base64 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; dataUrl&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token regex&quot;&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-source language-regex&quot;&gt;^data:image&#92;/png;base64,&lt;/span&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; Buffer&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;base64&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;base64&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; client &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Client&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;intents&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;GatewayIntentBits&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Guilds&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

client&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;once&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;ready&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; avatar &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;generateAvatar&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;client&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;user&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;username&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; client&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;user&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAvatar&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;avatar&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Bot avatar set successfully&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;err&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Failed to set avatar:&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; err&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;message&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

client&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;login&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;process&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;env&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;DISCORD_TOKEN&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That is roughly 25 lines of code to go from “bot with no avatar” to “bot with a unique, deterministic pixel-art mech avatar.” No design skills required, no API keys, no image hosting. Just a seed string and a few function calls.&lt;/p&gt;
&lt;p&gt;Your bot deserves better than the default gray icon. Give it a mech.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>10 Million Combinations: The Math Behind Procedural Pixel Art</title>
    <link href="https://mechgen.app/blog/procedural-pixel-art-ten-million-combinations/"/>
    <updated>2026-01-20T00:00:00Z</updated>
    <id>https://mechgen.app/blog/procedural-pixel-art-ten-million-combinations/</id>
    <content type="html">&lt;h2 id=&quot;10-million-combinations%3A-the-math-behind-procedural-pixel-art&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/procedural-pixel-art-ten-million-combinations/#10-million-combinations%3A-the-math-behind-procedural-pixel-art&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; 10 Million Combinations: The Math Behind Procedural Pixel Art&lt;/h2&gt;
&lt;p&gt;When you click “Randomize” on a procedural art generator, you probably don’t think about the math that makes each result feel unique. But behind every pixel mech, procedurally generated face, or random dungeon layout, there’s a combinatorial system quietly multiplying possibilities. In this post, we’ll break down exactly how procedural pixel art achieves massive variety from simple rules – and why determinism is the secret ingredient that makes it all practical.&lt;/p&gt;
&lt;h2 id=&quot;the-combinatorial-explosion&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/procedural-pixel-art-ten-million-combinations/#the-combinatorial-explosion&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The Combinatorial Explosion&lt;/h2&gt;
&lt;p&gt;The core math behind procedural avatar generators is straightforward multiplication. If you have a single category – say, head shape – with 10 options, you get 10 possible results. Add a second category (eyes) with 10 options, and you have 10 x 10 = 100 combinations. Each new category multiplies the total.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://mechgen.app/&quot;&gt;MechGen&lt;/a&gt; uses 7 independent part categories, each with 10 variations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Head&lt;/strong&gt;: Block, Dome, Visor, Horned, Flat, Round, Angular, Crown, Skull, Trapezoid&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Eyes&lt;/strong&gt;: Dots, Wide, Visor, Cyclops, X-Eyes, LED Strip, Slant, Pixel, Angry, Scanner&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Antenna&lt;/strong&gt;: None, Spike, Dual Rods, Dish, Blade, Orb, V-Shape, Radar, Halo, Periscope&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Body&lt;/strong&gt;: Standard, Tank, Slim, Barrel, Armored, V-Torso, Crate, Hex, Orb, Pillar&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Arms&lt;/strong&gt;: Standard, Claws, Cannons, Thin, Bulky, Blades, Tentacles, None, Drills, Shields&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Legs&lt;/strong&gt;: Standard, Treads, Digitigrade, Hover, Spider, Wheels, Stompers, Mono, Stilts, Pogo&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Accessory&lt;/strong&gt;: None, Jetpack, Shield, Chest Light, Shoulder Missiles, Back Vent, Energy Core, Wing Fins, Antenna Array, Tail&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The formula is simply:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;10 x 10 x 10 x 10 x 10 x 10 x 10 = 10^7 = 10,000,000
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ten million unique mechs from just 70 distinct parts. That’s the power of combinatorics – small inputs create enormous output spaces.&lt;/p&gt;
&lt;h3 id=&quot;color-palettes-push-it-further&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/procedural-pixel-art-ten-million-combinations/#color-palettes-push-it-further&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Color Palettes Push It Further&lt;/h3&gt;
&lt;p&gt;But part selection is only half the story. MechGen ships with 12 curated color palettes, each defining 5 color roles: primary body color, secondary detail color, accent highlights, eye color, and background. Each palette transforms the same mech silhouette into a completely different character.&lt;/p&gt;
&lt;p&gt;When you factor in palettes, the real design space becomes:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;10^7 parts x 12 palettes = 120,000,000 visually distinct mechs
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And since users can also pick custom colors for each role, the practical number of possible outputs is effectively unlimited. The 12 curated palettes exist to guarantee that randomly generated mechs always look cohesive – a constraint that actually increases the perceived quality of random results.&lt;/p&gt;
&lt;h2 id=&quot;why-determinism-matters&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/procedural-pixel-art-ten-million-combinations/#why-determinism-matters&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Why Determinism Matters&lt;/h2&gt;
&lt;p&gt;Random generation is easy. Deterministic generation is what makes procedural art actually useful.&lt;/p&gt;
&lt;p&gt;MechGen’s &lt;code&gt;fromSeed()&lt;/code&gt; function takes any string – a username, an email, a project name – and always produces the exact same mech. Call it on any browser, any device, any operating system, and the result is identical. This is what makes seed-based generation powerful for real applications:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;AI agents&lt;/strong&gt; can generate a consistent avatar from their name without storing image files&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multiplayer games&lt;/strong&gt; can derive player avatars from user IDs without a central image server&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Chat platforms&lt;/strong&gt; can display the same avatar everywhere without syncing assets&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;how-seeded-random-generation-works&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/procedural-pixel-art-ten-million-combinations/#how-seeded-random-generation-works&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; How Seeded Random Generation Works&lt;/h3&gt;
&lt;p&gt;The technical implementation uses two classic algorithms chained together:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 1: String Hashing.&lt;/strong&gt; The input string is converted to a numeric seed using a hash function. Each character’s code point is folded into an accumulator with bit shifts and additions, producing a single integer that represents the string.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 2: Linear Congruential Generator (LCG).&lt;/strong&gt; That integer seeds a pseudorandom number generator. An LCG is one of the oldest and simplest PRNGs – it uses the formula:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;next = (a * current + c) mod m
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Each call to the seeded random function advances the internal state and returns a value between 0 and 1. MechGen calls this function once per part category to select an index (0-9), and once more to select a palette (0-11).&lt;/p&gt;
&lt;p&gt;The key property of an LCG is that it’s entirely determined by its seed. Given the same starting integer, the sequence of “random” numbers is always identical. This means &lt;code&gt;fromSeed(&amp;quot;Atlas&amp;quot;)&lt;/code&gt; will always pick the same head, eyes, antenna, body, arms, legs, accessory, and palette – on every machine, every time.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Deterministic: always the same mech&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;my-bot-name&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Also deterministic: same seed, same result&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;my-bot-name&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// identical output&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;trade-offs-of-lcg&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/procedural-pixel-art-ten-million-combinations/#trade-offs-of-lcg&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Trade-offs of LCG&lt;/h3&gt;
&lt;p&gt;LCGs are not cryptographically secure. Their sequences are predictable, and the distribution isn’t perfectly uniform across all applications. But for avatar generation, these weaknesses don’t matter. You don’t need unpredictability – you need repeatability. An LCG is fast, simple to implement in any language, and produces sequences with enough variation to look random to human eyes across millions of combinations.&lt;/p&gt;
&lt;p&gt;More sophisticated PRNGs like Mersenne Twister or xorshift128+ offer better statistical properties, but they add complexity without meaningful benefit for this use case. The simplicity of an LCG also means it’s trivial to re-implement in other languages if you want to reproduce the same mech generation in a backend service or mobile app.&lt;/p&gt;
&lt;h2 id=&quot;how-this-compares-to-other-procedural-art-systems&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/procedural-pixel-art-ten-million-combinations/#how-this-compares-to-other-procedural-art-systems&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; How This Compares to Other Procedural Art Systems&lt;/h2&gt;
&lt;p&gt;Procedural generation has a long history across different domains:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Identicons&lt;/strong&gt; (used by GitHub and Gravatar) use hash-based generation but with much simpler visual output – typically symmetric geometric patterns. The design space is large but the visual variety feels limited because the structural rules are so constrained.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;NFT avatar projects&lt;/strong&gt; like CryptoPunks use a similar layered-parts approach, but with rarity weighting – some traits are deliberately scarce. MechGen uses uniform distribution, so every combination is equally likely.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Roguelike terrain generation&lt;/strong&gt; uses cellular automata or Perlin noise, which are continuous rather than categorical. These systems produce smooth, organic variation rather than discrete part selection.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Generative face tools&lt;/strong&gt; (like the square face generators that inspired MechGen) prove that the layered-parts model works well for character avatars specifically, because humans naturally parse faces and characters as compositions of distinct features.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The layered-parts approach hits a sweet spot for avatars: it’s simple enough to run client-side with zero dependencies, deterministic enough for distributed systems, and expressive enough that 10 million combinations genuinely feel distinct.&lt;/p&gt;
&lt;h2 id=&quot;the-design-challenge%3A-making-every-combination-look-good&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/procedural-pixel-art-ten-million-combinations/#the-design-challenge%3A-making-every-combination-look-good&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The Design Challenge: Making Every Combination Look Good&lt;/h2&gt;
&lt;p&gt;The hardest part of procedural art isn’t generating variety – it’s ensuring quality across all possible outputs. With 10 million combinations, you can’t manually review each one. The system has to be designed so that every combination is at least acceptable.&lt;/p&gt;
&lt;p&gt;MechGen handles this through several constraints:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Fixed canvas grid&lt;/strong&gt;: All parts are drawn on a 64x64 pixel canvas with a consistent coordinate system. Parts are designed to occupy specific regions, so a head always sits above a body regardless of which specific head and body are selected.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Layered draw order&lt;/strong&gt;: Parts are rendered back-to-front (accessory, legs, body, arms, head, antenna, eyes), ensuring that foreground elements correctly overlap background elements for every combination.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Curated palettes&lt;/strong&gt;: The 12 built-in palettes ensure that randomly generated mechs have harmonious colors. Every palette is tested against multiple part combinations to verify readability.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Shading from single values&lt;/strong&gt;: The &lt;code&gt;darken()&lt;/code&gt; and &lt;code&gt;lighten()&lt;/code&gt; helper functions derive shadow and highlight colors from each base hex value, so depth and dimension are consistent regardless of the palette.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These constraints reduce the raw freedom of the system, but that’s the point. Good procedural generation is about defining a possibility space where every point is a valid, appealing result – not about maximizing randomness for its own sake.&lt;/p&gt;
&lt;h2 id=&quot;try-it-yourself&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/procedural-pixel-art-ten-million-combinations/#try-it-yourself&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Try It Yourself&lt;/h2&gt;
&lt;p&gt;Head to the &lt;a href=&quot;https://mechgen.app/&quot;&gt;MechGen generator&lt;/a&gt; and click Randomize a few times. Each click samples one point from that 10-million-combination space. Or type a seed string into the bot mode input and watch the same string always produce the same mech. That consistency across chaos is what makes procedural generation such a powerful tool for developers, designers, and anyone who needs unique visual identity at scale.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Integrating MechGen&#39;s JavaScript API into Your Bot</title>
    <link href="https://mechgen.app/blog/javascript-avatar-api-bot-integration/"/>
    <updated>2026-01-19T00:00:00Z</updated>
    <id>https://mechgen.app/blog/javascript-avatar-api-bot-integration/</id>
    <content type="html">&lt;p&gt;MechGen exposes a global &lt;code&gt;MechGen&lt;/code&gt; object with a clean JavaScript API designed for programmatic use. Whether you are building a Discord bot, a web dashboard with user avatars, or an AI agent framework with visual identity, this guide covers every method you need and the patterns that work best in production.&lt;/p&gt;
&lt;h2 id=&quot;the-mechgen-global-object&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/javascript-avatar-api-bot-integration/#the-mechgen-global-object&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The MechGen Global Object&lt;/h2&gt;
&lt;p&gt;When you load &lt;a href=&quot;https://mechgen.app/&quot;&gt;mechgen.app&lt;/a&gt; in a browser (or a headless browser like Puppeteer), the &lt;code&gt;MechGen&lt;/code&gt; object is available on &lt;code&gt;window&lt;/code&gt;. It provides eight methods that cover the full lifecycle: generation, state management, and export.&lt;/p&gt;
&lt;p&gt;Let us walk through each one.&lt;/p&gt;
&lt;h2 id=&quot;core-methods&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/javascript-avatar-api-bot-integration/#core-methods&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Core Methods&lt;/h2&gt;
&lt;h3 id=&quot;mechgen.fromseed(string)&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/javascript-avatar-api-bot-integration/#mechgen.fromseed(string)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; &lt;code&gt;MechGen.fromSeed(string)&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The workhorse for deterministic generation. Pass any string and get the same mech every time:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;my-discord-bot&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// Canvas now shows a specific mech that will never change for this seed&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is the method you want when identity consistency matters. Agent names, user IDs, email addresses, UUIDs — any string works as a seed. The internal hashing ensures even similar strings like &lt;code&gt;&amp;quot;bot-1&amp;quot;&lt;/code&gt; and &lt;code&gt;&amp;quot;bot-2&amp;quot;&lt;/code&gt; produce visually distinct results.&lt;/p&gt;
&lt;h3 id=&quot;mechgen.randomize()&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/javascript-avatar-api-bot-integration/#mechgen.randomize()&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; &lt;code&gt;MechGen.randomize()&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;Generates a completely random mech with a random color palette:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;randomize&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// Every call produces a different mech&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Use this when you want variety without caring about reproducibility. Good for “show me something new” buttons, random avatar assignment on first visit, or just exploring what the generator can produce.&lt;/p&gt;
&lt;h3 id=&quot;mechgen.getstate()&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/javascript-avatar-api-bot-integration/#mechgen.getstate()&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; &lt;code&gt;MechGen.getState()&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;Returns a plain JavaScript object describing the current mech. This is your serialization method:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; state &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getState&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;state&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// {&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;//   head: 2,&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;//   eyes: 5,&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;//   antenna: 1,&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;//   body: 0,&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;//   arms: 3,&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;//   legs: 4,&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;//   accessory: 7,&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;//   primaryColor: &quot;#00e5ff&quot;,&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;//   secondaryColor: &quot;#1a237e&quot;,&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;//   accentColor: &quot;#ff4081&quot;,&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;//   bgColor: &quot;#0a0a2e&quot;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// }&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Each part is an index (0-9) selecting from ten possible variants. Colors are hex strings. This state object is everything you need to recreate a mech exactly.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Practical use&lt;/strong&gt;: Store this object in a database alongside a user or agent record. It is small (under 200 bytes as JSON) and fully describes the avatar.&lt;/p&gt;
&lt;h3 id=&quot;mechgen.setstate(object)&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/javascript-avatar-api-bot-integration/#mechgen.setstate(object)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; &lt;code&gt;MechGen.setState(object)&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The inverse of &lt;code&gt;getState()&lt;/code&gt;. Pass a partial or complete state object to update the mech:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Change just the head and eyes, keep everything else&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setState&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;eyes&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Set a full state from a database record&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setState&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;eyes&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;antenna&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;arms&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;legs&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;accessory&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;primaryColor&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;#00e5ff&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;secondaryColor&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;#1a237e&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;accentColor&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;#ff4081&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;bgColor&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;#0a0a2e&quot;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The method merges your input with the current state, so partial updates work. This is how you restore saved mechs or build custom editors on top of MechGen.&lt;/p&gt;
&lt;h3 id=&quot;mechgen.getimagedataurl(size%3F)&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/javascript-avatar-api-bot-integration/#mechgen.getimagedataurl(size%3F)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; &lt;code&gt;MechGen.getImageDataURL(size?)&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;Returns the current mech as a base64-encoded PNG data URL. The optional &lt;code&gt;size&lt;/code&gt; parameter controls the output resolution in pixels (default is 512):&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; dataURL &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getImageDataURL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;      &lt;span class=&quot;token comment&quot;&gt;// 512x512&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; small &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getImageDataURL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;128&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;      &lt;span class=&quot;token comment&quot;&gt;// 128x128&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; large &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getImageDataURL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1024&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;     &lt;span class=&quot;token comment&quot;&gt;// 1024x1024&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Use it directly in an &amp;lt;img&gt; tag&lt;/span&gt;
document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;img&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;src &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; dataURL&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is the primary method for extracting the avatar image programmatically. The data URL is a self-contained PNG that you can embed in HTML, send over an API, or write to a file.&lt;/p&gt;
&lt;h3 id=&quot;mechgen.exportpng()&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/javascript-avatar-api-bot-integration/#mechgen.exportpng()&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; &lt;code&gt;MechGen.exportPNG()&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;Triggers a browser download of the current mech as a 512x512 PNG:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;exportPNG&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// Browser downloads &quot;mech-avatar.png&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is a convenience method for user-facing “Download” buttons. For programmatic use, &lt;code&gt;getImageDataURL()&lt;/code&gt; gives you more flexibility.&lt;/p&gt;
&lt;h3 id=&quot;mechgen.exportforplatform(platform)&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/javascript-avatar-api-bot-integration/#mechgen.exportforplatform(platform)&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; &lt;code&gt;MechGen.exportForPlatform(platform)&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;Downloads a PNG at the optimal resolution for a specific platform:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;exportForPlatform&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;discord&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// 512x512&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;exportForPlatform&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;x&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;        &lt;span class=&quot;token comment&quot;&gt;// 400x400&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;exportForPlatform&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;github&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;   &lt;span class=&quot;token comment&quot;&gt;// 460x460&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;exportForPlatform&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;steam&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;    &lt;span class=&quot;token comment&quot;&gt;// 184x184&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;exportForPlatform&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;youtube&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;token comment&quot;&gt;// 800x800&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;exportForPlatform&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;twitch&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;   &lt;span class=&quot;token comment&quot;&gt;// 256x256&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Each platform has different avatar size requirements. This method handles the sizing so you do not have to look up specs yourself.&lt;/p&gt;
&lt;h2 id=&quot;integration-patterns&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/javascript-avatar-api-bot-integration/#integration-patterns&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Integration Patterns&lt;/h2&gt;
&lt;h3 id=&quot;pattern-1%3A-discord-bot-avatar&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/javascript-avatar-api-bot-integration/#pattern-1%3A-discord-bot-avatar&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Pattern 1: Discord Bot Avatar&lt;/h3&gt;
&lt;p&gt;A Discord bot that generates unique avatars for users based on their user ID:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// In your Discord bot command handler&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; Client&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; AttachmentBuilder &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;discord.js&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Using Puppeteer to access MechGen&#39;s API&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getAvatarForUser&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;userId&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; page &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; browser&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;newPage&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; page&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;goto&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;https://mechgen.app&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; dataURL &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; page&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;evaluate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;id&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getImageDataURL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;512&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; userId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; page&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;// Convert data URL to Buffer for Discord&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; base64Data &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; dataURL&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token regex&quot;&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-source language-regex&quot;&gt;^data:image&#92;/png;base64,&lt;/span&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; Buffer&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;base64Data&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;base64&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

client&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;messageCreate&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;message&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;content &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;!mech&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; imageBuffer &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getAvatarForUser&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;message&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;author&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; attachment &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;AttachmentBuilder&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;imageBuffer&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;mech-avatar.png&quot;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    message&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;files&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;attachment&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Every user gets a unique mech based on their Discord ID, and it is the same mech every time they run the command.&lt;/p&gt;
&lt;h3 id=&quot;pattern-2%3A-web-dashboard-with-agent-avatars&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/javascript-avatar-api-bot-integration/#pattern-2%3A-web-dashboard-with-agent-avatars&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Pattern 2: Web Dashboard with Agent Avatars&lt;/h3&gt;
&lt;p&gt;For a web app that displays multiple AI agents, you can generate avatars client-side without any server round trips:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;script&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token script&quot;&gt;&lt;span class=&quot;token language-javascript&quot;&gt;
&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;loadAgentAvatars&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;agents&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// Load MechGen in a hidden iframe&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; iframe &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;iframe&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  iframe&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;src &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;https://mechgen.app&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  iframe&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;style&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;display &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;none&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;body&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;appendChild&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;iframe&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Promise&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;resolve&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; iframe&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;onload &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; resolve&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;MG&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; iframe&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;contentWindow&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;MechGen&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  agents&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;agent&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token constant&quot;&gt;MG&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;agent&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; img &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getElementById&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;avatar-&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;agent&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    img&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;src &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;MG&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getImageDataURL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;128&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;loadAgentAvatars&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;analyst&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Data Analyst&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;writer&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Content Writer&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;reviewer&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Code Reviewer&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;script&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;pattern-3%3A-server-side-generation-with-playwright&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/javascript-avatar-api-bot-integration/#pattern-3%3A-server-side-generation-with-playwright&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Pattern 3: Server-Side Generation with Playwright&lt;/h3&gt;
&lt;p&gt;For backends that need to generate avatars without a client browser, Playwright offers a clean approach:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; chromium &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;playwright&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;MechAvatarService&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;browser &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; chromium&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;launch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;context &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;browser&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;newContext&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;page &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;context&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;newPage&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;page&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;goto&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;https://mechgen.app&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;generateAvatar&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;seed&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; size &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;512&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;page&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;evaluate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; s&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; sz &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;s&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getImageDataURL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;sz&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; seed&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;sz&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; size &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;generateCustomAvatar&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;page&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;evaluate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;st&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setState&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;st&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getImageDataURL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;512&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; state&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;browser&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Usage&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; service &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;MechAvatarService&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; service&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; avatar &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; service&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;generateAvatar&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;my-bot&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; custom &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; service&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;generateCustomAvatar&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;eyes&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;primaryColor&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;#ff6600&quot;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;By keeping a single browser instance alive, you avoid the overhead of launching a new browser for each avatar. This pattern works well for API servers that generate avatars on demand.&lt;/p&gt;
&lt;h3 id=&quot;pattern-4%3A-slack-bot-with-dynamic-avatars&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/javascript-avatar-api-bot-integration/#pattern-4%3A-slack-bot-with-dynamic-avatars&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Pattern 4: Slack Bot with Dynamic Avatars&lt;/h3&gt;
&lt;p&gt;Slack’s &lt;code&gt;chat.postMessage&lt;/code&gt; API accepts an &lt;code&gt;icon_url&lt;/code&gt; parameter. Combine this with a simple avatar endpoint:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Express endpoint that serves mech avatars&lt;/span&gt;
app&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/avatar/:seed.png&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;req&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; res&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; dataURL &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; mechService&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;generateAvatar&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;req&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;params&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;seed&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; buffer &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Buffer&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    dataURL&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token regex&quot;&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-source language-regex&quot;&gt;^data:image&#92;/png;base64,&lt;/span&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token string&quot;&gt;&quot;base64&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  res&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;png&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;send&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;buffer&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// When posting to Slack&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; slack&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;chat&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;postMessage&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;channel&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;#general&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Analysis complete. Here are the results...&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;username&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Data Analyst Bot&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;icon_url&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;https://your-server.com/avatar/data-analyst.png&quot;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;state-persistence&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/javascript-avatar-api-bot-integration/#state-persistence&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; State Persistence&lt;/h2&gt;
&lt;p&gt;If you want users to customize their mech and save it, the state object is your friend:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Save to localStorage&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;randomize&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// or let user customize&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; state &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getState&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
localStorage&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setItem&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;myMech&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;stringify&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;state&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Restore later&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; saved &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;parse&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;localStorage&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getItem&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;myMech&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setState&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;saved&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The state object is small enough to store in a database column, a cookie, a URL parameter, or even a QR code. It is a complete, portable description of any mech.&lt;/p&gt;
&lt;h2 id=&quot;transparent-backgrounds&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/javascript-avatar-api-bot-integration/#transparent-backgrounds&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Transparent Backgrounds&lt;/h2&gt;
&lt;p&gt;For overlaying mechs on custom backgrounds, set the background color to transparent:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;overlay-bot&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setColor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;bgColor&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;transparent&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; transparentPNG &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getImageDataURL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;512&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The exported PNG will have a transparent background, ready for compositing in any design tool or UI.&lt;/p&gt;
&lt;h2 id=&quot;what-to-build-next&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/javascript-avatar-api-bot-integration/#what-to-build-next&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; What to Build Next&lt;/h2&gt;
&lt;p&gt;With these methods, you can add unique visual identity to any bot or agent system in minutes. The deterministic seed generation means you never have to store images — just store the seed string and regenerate on demand.&lt;/p&gt;
&lt;p&gt;Explore the full &lt;a href=&quot;https://mechgen.app/&quot;&gt;MechGen generator&lt;/a&gt; to see what 10 million combinations look like, or start coding with the API right away.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Give Your AI Agent a Face: Deterministic Avatars from Seed Strings</title>
    <link href="https://mechgen.app/blog/ai-agent-avatars-deterministic-seeds/"/>
    <updated>2026-01-15T00:00:00Z</updated>
    <id>https://mechgen.app/blog/ai-agent-avatars-deterministic-seeds/</id>
    <content type="html">&lt;p&gt;Your AI agent has a name, a personality, maybe even a system prompt longer than most novels. But when it shows up in a chat window, a dashboard, or a multi-agent workflow, what does it look like? A generic circle with initials? A placeholder silhouette?&lt;/p&gt;
&lt;p&gt;That is a missed opportunity. Visual identity matters, and for AI agents, it matters more than most developers realize. A consistent, recognizable avatar turns an abstract process into something users can identify, remember, and trust.&lt;/p&gt;
&lt;p&gt;The challenge is that avatars for agents need to be &lt;strong&gt;deterministic&lt;/strong&gt;. You cannot have an agent’s face change every time your server restarts. The same agent should always look the same, across every session, every deployment, every environment.&lt;/p&gt;
&lt;p&gt;That is exactly what seed-based generation solves.&lt;/p&gt;
&lt;h2 id=&quot;how-deterministic-seed-generation-works&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-avatars-deterministic-seeds/#how-deterministic-seed-generation-works&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; How Deterministic Seed Generation Works&lt;/h2&gt;
&lt;p&gt;The concept is straightforward: feed in a string, get back the same avatar every time. In &lt;a href=&quot;https://mechgen.app/&quot;&gt;MechGen&lt;/a&gt;, a single function call handles this:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;research-assistant-v2&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Call this today, tomorrow, or six months from now, and you will get the identical pixel mech. Same head shape, same eye style, same color palette, same everything.&lt;/p&gt;
&lt;p&gt;Under the hood, the process follows a well-established pattern:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;String hashing&lt;/strong&gt;: The seed string is converted into a numeric hash. Each character’s code point is folded into an accumulator using bitwise operations, producing a single integer from any arbitrary input.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Seeded PRNG&lt;/strong&gt;: That hash initializes a Linear Congruential Generator (LCG), a classic pseudorandom number generator. The LCG produces a sequence of numbers that appears random but is entirely determined by the initial seed value.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Part selection&lt;/strong&gt;: The PRNG sequence is consumed to select each mech component: head style (10 options), eye type (10 options), antenna, body, arms, legs, accessory, and a color palette from 12 curated options.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Rendering&lt;/strong&gt;: The selected parts are drawn to a 64x64 pixel canvas in a specific layer order, then upscaled with crisp pixel rendering.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Because every step is purely functional with no external randomness involved, the same seed always walks the same path through the same decision tree, producing the same result.&lt;/p&gt;
&lt;h2 id=&quot;why-deterministic-avatars-matter-for-ai-agents&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-avatars-deterministic-seeds/#why-deterministic-avatars-matter-for-ai-agents&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Why Deterministic Avatars Matter for AI Agents&lt;/h2&gt;
&lt;h3 id=&quot;consistency-across-sessions&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-avatars-deterministic-seeds/#consistency-across-sessions&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Consistency Across Sessions&lt;/h3&gt;
&lt;p&gt;Users who interact with an agent repeatedly develop a mental model of that agent. A visual anchor reinforces that model. If your “Data Analyst” agent always appears as the same teal mech with a dome head and scanner eyes, users build a subconscious association. They know who they are talking to before reading a single word.&lt;/p&gt;
&lt;h3 id=&quot;recognition-in-multi-agent-systems&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-avatars-deterministic-seeds/#recognition-in-multi-agent-systems&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Recognition in Multi-Agent Systems&lt;/h3&gt;
&lt;p&gt;Frameworks like CrewAI, AutoGen, and LangGraph make it easy to orchestrate multiple agents working together. In a typical setup, you might have a researcher, a writer, a reviewer, and a coordinator, all passing messages in a shared workspace.&lt;/p&gt;
&lt;p&gt;Without visual differentiation, following the conversation becomes tedious. Users must read agent names on every message. With distinct avatars, they can scan visually:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Each agent in your multi-agent system gets a unique, stable face&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;crew-researcher&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;crew-writer&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;crew-reviewer&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;crew-coordinator&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Four different seeds produce four visually distinct mechs, and they stay consistent every time the system runs.&lt;/p&gt;
&lt;h3 id=&quot;identity-without-infrastructure&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-avatars-deterministic-seeds/#identity-without-infrastructure&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Identity Without Infrastructure&lt;/h3&gt;
&lt;p&gt;Traditionally, giving agents avatars means storing images somewhere: a CDN, a database, an asset folder. With seed-based generation, the identity lives in the seed string itself. You do not need to store, serve, or manage image files. The avatar is reconstructed on demand from the name alone.&lt;/p&gt;
&lt;h2 id=&quot;practical-integration-patterns&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-avatars-deterministic-seeds/#practical-integration-patterns&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Practical Integration Patterns&lt;/h2&gt;
&lt;h3 id=&quot;pattern-1%3A-agent-name-as-seed&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-avatars-deterministic-seeds/#pattern-1%3A-agent-name-as-seed&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Pattern 1: Agent Name as Seed&lt;/h3&gt;
&lt;p&gt;The simplest approach. Use whatever string already identifies your agent:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Your agent config probably already has a name&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; agentName &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;finance-analyst&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// That name IS the avatar&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;agentName&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; avatarDataURL &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getImageDataURL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;256&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// avatarDataURL is a base64 PNG you can use anywhere&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// &amp;lt;img src={avatarDataURL} /&gt; in your UI&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;pattern-2%3A-namespaced-seeds-for-versioning&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-avatars-deterministic-seeds/#pattern-2%3A-namespaced-seeds-for-versioning&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Pattern 2: Namespaced Seeds for Versioning&lt;/h3&gt;
&lt;p&gt;When you update an agent significantly and want its appearance to reflect the change, namespace the seed:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Version 1 of your agent&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;support-bot:v1&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Major update? New look.&lt;/span&gt;
MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;support-bot:v2&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Same agent, visually evolved&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;pattern-3%3A-team-based-seeds-for-multi-agent-dashboards&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-avatars-deterministic-seeds/#pattern-3%3A-team-based-seeds-for-multi-agent-dashboards&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Pattern 3: Team-Based Seeds for Multi-Agent Dashboards&lt;/h3&gt;
&lt;p&gt;For dashboards that display many agents, generate all avatars from a predictable naming convention:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; agents &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;planner&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;executor&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;critic&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;summarizer&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; avatars &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; agents&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;team-alpha:&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;name&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    name&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;avatar&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getImageDataURL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;128&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Each agent now has a stable avatar, no storage needed&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;pattern-4%3A-headless-generation-with-puppeteer&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-avatars-deterministic-seeds/#pattern-4%3A-headless-generation-with-puppeteer&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Pattern 4: Headless Generation with Puppeteer&lt;/h3&gt;
&lt;p&gt;If you need avatars on the server side (for Slack messages, email notifications, or API responses), you can use a headless browser:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; puppeteer &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;puppeteer&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;generateAgentAvatar&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;seed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; browser &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; puppeteer&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;launch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; page &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; browser&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;newPage&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; page&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;goto&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;https://mechgen.app&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; dataURL &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; page&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;evaluate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;s&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getImageDataURL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;512&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; seed&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; browser&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; dataURL&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// base64 PNG string&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This approach works anywhere Node.js runs: CI pipelines, serverless functions, background workers.&lt;/p&gt;
&lt;h2 id=&quot;choosing-good-seed-strings&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-avatars-deterministic-seeds/#choosing-good-seed-strings&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Choosing Good Seed Strings&lt;/h2&gt;
&lt;p&gt;Not all seeds are created equal in terms of the visual variety they produce. A few tips:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Use descriptive names&lt;/strong&gt;: &lt;code&gt;&amp;quot;research-agent&amp;quot;&lt;/code&gt; is better than &lt;code&gt;&amp;quot;agent-1&amp;quot;&lt;/code&gt; because it is more memorable and maps to the agent’s purpose.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Include namespaces&lt;/strong&gt;: &lt;code&gt;&amp;quot;myapp:analyst&amp;quot;&lt;/code&gt; avoids collisions if multiple projects use MechGen.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Avoid sequential numbers alone&lt;/strong&gt;: &lt;code&gt;&amp;quot;1&amp;quot;&lt;/code&gt;, &lt;code&gt;&amp;quot;2&amp;quot;&lt;/code&gt;, &lt;code&gt;&amp;quot;3&amp;quot;&lt;/code&gt; will produce valid mechs, but names like &lt;code&gt;&amp;quot;atlas&amp;quot;&lt;/code&gt;, &lt;code&gt;&amp;quot;cipher&amp;quot;&lt;/code&gt;, &lt;code&gt;&amp;quot;nova&amp;quot;&lt;/code&gt; are more meaningful and produce more varied-looking results due to longer, more diverse character sequences feeding into the hash.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;beyond-single-agents&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/ai-agent-avatars-deterministic-seeds/#beyond-single-agents&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Beyond Single Agents&lt;/h2&gt;
&lt;p&gt;Seed-based generation scales naturally. Whether you have 3 agents or 300, each one gets a unique visual identity derived from its name, with zero additional infrastructure. No image uploads, no asset management, no storage costs.&lt;/p&gt;
&lt;p&gt;For AI agent developers building conversational interfaces, multi-agent orchestration tools, or agent marketplaces, deterministic avatars solve a real UX problem with a single line of code.&lt;/p&gt;
&lt;p&gt;Your agents already have names. Now give them faces.&lt;/p&gt;
&lt;p&gt;Try the &lt;a href=&quot;https://mechgen.app/&quot;&gt;MechGen generator&lt;/a&gt; to see seed-based generation in action, or read the &lt;a href=&quot;https://mechgen.app/blog/javascript-avatar-api-bot-integration/&quot;&gt;API integration guide&lt;/a&gt; to start building.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <title>Hackathon Projects Need Avatars: Ship Faster with MechGen</title>
    <link href="https://mechgen.app/blog/hackathon-avatars-ship-faster/"/>
    <updated>2026-01-10T00:00:00Z</updated>
    <id>https://mechgen.app/blog/hackathon-avatars-ship-faster/</id>
    <content type="html">&lt;p&gt;It is 2 AM at a hackathon. Your team’s app is coming together. The backend works, the frontend is functional, and the demo is in six hours. But every user in your dashboard is a gray circle or a broken image link. The AI agents in your multi-agent system are indistinguishable. Your team page shows names but no faces.&lt;/p&gt;
&lt;p&gt;You do not have time to make avatars. You do not have time to find a free icon set, read its license, figure out its naming convention, and wire it into your rendering pipeline. You need unique images tied to unique identifiers, and you need them five minutes ago.&lt;/p&gt;
&lt;p&gt;This is the exact problem MechGen was built to solve.&lt;/p&gt;
&lt;h2 id=&quot;the-30-second-workflow&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/hackathon-avatars-ship-faster/#the-30-second-workflow&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The 30-Second Workflow&lt;/h2&gt;
&lt;p&gt;If all you need is a few avatar images — team member pictures for a landing page, a profile image for a bot, placeholder content for a mockup — the fastest path is:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open &lt;a href=&quot;https://mechgen.app/&quot;&gt;mechgen.app&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Type a name or identifier into the Bot Mode seed input&lt;/li&gt;
&lt;li&gt;Press Enter&lt;/li&gt;
&lt;li&gt;Click the export button&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;That gives you a 512x512 PNG of a unique pixel-art robot, deterministically generated from your input string. The same string always produces the same mech. “Alice” always looks like Alice. “agent-07” always looks like agent-07.&lt;/p&gt;
&lt;p&gt;Need a different size? The social export buttons produce platform-specific dimensions: 400px for X, 512px for Discord, 460px for GitHub, and so on.&lt;/p&gt;
&lt;p&gt;No account creation. No API key. No sign-up form. Just open the page and generate.&lt;/p&gt;
&lt;h2 id=&quot;the-developer-workflow&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/hackathon-avatars-ship-faster/#the-developer-workflow&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The Developer Workflow&lt;/h2&gt;
&lt;p&gt;For hackathon projects that generate avatars in code — user dashboards, chat apps, multi-agent systems — MechGen exposes a JavaScript API on the global &lt;code&gt;MechGen&lt;/code&gt; object.&lt;/p&gt;
&lt;h3 id=&quot;generating-avatars-from-user-ids&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/hackathon-avatars-ship-faster/#generating-avatars-from-user-ids&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Generating Avatars from User IDs&lt;/h3&gt;
&lt;p&gt;The most common hackathon use case is: given a user ID or username, produce a unique avatar. One line of code handles this:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;userId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; avatarDataUrl &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getImageDataURL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;256&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;fromSeed()&lt;/code&gt; takes any string, hashes it, and uses the hash to deterministically select parts and colors. &lt;code&gt;getImageDataURL()&lt;/code&gt; returns a base64-encoded PNG data URL that you can drop directly into an &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; tag:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;${avatarDataUrl}&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;User avatar&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;64&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;64&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;No image hosting. No file storage. No CDN. The avatar exists as a data URL in memory, generated on demand.&lt;/p&gt;
&lt;h3 id=&quot;batch-generation-for-dashboards&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/hackathon-avatars-ship-faster/#batch-generation-for-dashboards&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Batch Generation for Dashboards&lt;/h3&gt;
&lt;p&gt;If your app displays a list of users, agents, or entities, you can generate all their avatars in a loop:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; users &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;alice&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;bob&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;charlie&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;agent-001&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;agent-002&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; avatars &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; users&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;user&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;user&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;avatar&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getImageDataURL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;128&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Each call to &lt;code&gt;fromSeed()&lt;/code&gt; reconfigures the generator and &lt;code&gt;getImageDataURL()&lt;/code&gt; renders the current state to a PNG. The entire loop runs in milliseconds since all rendering happens on a canvas element — no network requests, no server roundtrips.&lt;/p&gt;
&lt;h3 id=&quot;getting-the-current-state&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/hackathon-avatars-ship-faster/#getting-the-current-state&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Getting the Current State&lt;/h3&gt;
&lt;p&gt;If you want to store which parts and colors a mech uses (for a database, for debugging, for display), call &lt;code&gt;getState()&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;hackathon-bot&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; state &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getState&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// { head: 3, eyes: 7, antenna: 1, body: 5, arms: 2, legs: 8, accessory: 0,&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;//   primaryColor: &#39;#1a1a2e&#39;, secondaryColor: &#39;#16213e&#39;, ... }&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This returns the full part indices and color values. You can store this object and later restore it with &lt;code&gt;setState()&lt;/code&gt; to recreate the exact same mech without needing the seed.&lt;/p&gt;
&lt;h2 id=&quot;hackathon-use-cases&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/hackathon-avatars-ship-faster/#hackathon-use-cases&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Hackathon Use Cases&lt;/h2&gt;
&lt;h3 id=&quot;user-profile-pictures&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/hackathon-avatars-ship-faster/#user-profile-pictures&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; User Profile Pictures&lt;/h3&gt;
&lt;p&gt;Every app with user accounts needs profile pictures. During a hackathon, nobody is going to upload a photo. Default gray circles make the app look unfinished. Generate a unique mech from each user’s ID or email and the profile grid immediately looks alive:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getProfileAvatar&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;email&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;email&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getImageDataURL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;256&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Your judges see a polished dashboard with unique avatars for every user. They do not need to know it took three lines of code.&lt;/p&gt;
&lt;h3 id=&quot;ai-agent-faces&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/hackathon-avatars-ship-faster/#ai-agent-faces&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; AI Agent Faces&lt;/h3&gt;
&lt;p&gt;Multi-agent systems and LLM orchestration projects are popular hackathon categories. When your demo shows three agents collaborating — a planner, a coder, and a reviewer — giving each one a distinct visual identity makes the interaction dramatically easier to follow.&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; agents &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;planner&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;agent-planner-v1&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;coder&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;agent-coder-v1&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;reviewer&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;agent-reviewer-v1&#39;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

Object&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;entries&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;agents&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;role&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; seed&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;seed&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getElementById&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;role&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;-avatar&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;src &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getImageDataURL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;128&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now each agent has a unique pixel-art mech face. The planner looks different from the coder, which looks different from the reviewer. Every time you run the demo, they look the same — because generation is deterministic.&lt;/p&gt;
&lt;h3 id=&quot;placeholder-content&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/hackathon-avatars-ship-faster/#placeholder-content&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Placeholder Content&lt;/h3&gt;
&lt;p&gt;Building a social feed? A messaging app? A marketplace? You need placeholder content that looks real. Instead of “User 1, User 2, User 3” with identical default icons, generate mechs from sequential seeds:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;demo-user-&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;i&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; avatar &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getImageDataURL&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;64&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;addFeedItem&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; avatar&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;User &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;i&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Sample post content...&#39;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Twenty unique avatars in a loop. Your prototype feed looks populated and varied.&lt;/p&gt;
&lt;h3 id=&quot;team-page&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/hackathon-avatars-ship-faster/#team-page&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Team Page&lt;/h3&gt;
&lt;p&gt;Every hackathon submission needs a team page or an “about” section. Generate a mech for each team member from their name:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; team &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Andrei&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Sarah&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Marcus&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Priya&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
team&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  MechGen&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fromSeed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// Render to team grid...&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It is playful, on-brand for a tech project, and takes less time than finding stock photos.&lt;/p&gt;
&lt;h2 id=&quot;why-mechgen-is-built-for-hackathon-speed&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/hackathon-avatars-ship-faster/#why-mechgen-is-built-for-hackathon-speed&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Why MechGen Is Built for Hackathon Speed&lt;/h2&gt;
&lt;p&gt;Several properties of MechGen align specifically with the constraints of hackathon development:&lt;/p&gt;
&lt;h3 id=&quot;zero-setup&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/hackathon-avatars-ship-faster/#zero-setup&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Zero Setup&lt;/h3&gt;
&lt;p&gt;There is no npm package to install, no build step to configure, no API key to register for. MechGen is a single HTML file. You can link to the hosted version at mechgen.app or download the file and serve it locally. Either way, you go from zero to generating avatars in under a minute.&lt;/p&gt;
&lt;h3 id=&quot;no-accounts%2C-no-keys&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/hackathon-avatars-ship-faster/#no-accounts%2C-no-keys&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; No Accounts, No Keys&lt;/h3&gt;
&lt;p&gt;Every minute spent on account creation, email verification, API key management, and documentation reading is a minute not spent building your project. MechGen has no accounts. There is nothing to sign up for.&lt;/p&gt;
&lt;h3 id=&quot;works-offline&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/hackathon-avatars-ship-faster/#works-offline&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Works Offline&lt;/h3&gt;
&lt;p&gt;Hackathon wifi is notoriously unreliable. MechGen runs entirely in the browser with zero server calls. Once the page is loaded, it works without any network connection. If you download the HTML file, it works with no network at all. All 10 million possible combinations are generated client-side from code — no assets to fetch, no API to call.&lt;/p&gt;
&lt;h3 id=&quot;deterministic-by-default&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/hackathon-avatars-ship-faster/#deterministic-by-default&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Deterministic by Default&lt;/h3&gt;
&lt;p&gt;In a hackathon demo, reproducibility matters. You want your demo to look the same every time you run it. MechGen’s seed-based generation guarantees this. &lt;code&gt;fromSeed(&#39;alice&#39;)&lt;/code&gt; produces the exact same mech on your laptop, on the demo projector, and on the judge’s phone. No randomness, no variation, no surprises.&lt;/p&gt;
&lt;h3 id=&quot;lightweight&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/hackathon-avatars-ship-faster/#lightweight&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; Lightweight&lt;/h3&gt;
&lt;p&gt;MechGen adds no dependencies to your project. It does not pull in React, Canvas libraries, or image processing packages. It is vanilla JavaScript rendering to an HTML canvas. In a hackathon context where your &lt;code&gt;node_modules&lt;/code&gt; is already groaning under the weight of your actual dependencies, this matters.&lt;/p&gt;
&lt;h2 id=&quot;the-competitive-edge&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://mechgen.app/blog/hackathon-avatars-ship-faster/#the-competitive-edge&quot; aria-hidden=&quot;true&quot;&gt;#&lt;/a&gt; The Competitive Edge&lt;/h2&gt;
&lt;p&gt;Hackathon judges evaluate polish alongside functionality. Two projects with identical features will be judged differently if one has a clean UI with unique avatars and the other shows gray circles and placeholder text. Visual identity communicates completeness.&lt;/p&gt;
&lt;p&gt;MechGen lets you add that visual layer in minutes instead of hours. The robots are distinctive, the pixel art style is charming, and the deterministic generation means your demo is consistent across runs.&lt;/p&gt;
&lt;p&gt;Your hackathon project needs avatars. You do not have time to make them. &lt;a href=&quot;https://mechgen.app/&quot;&gt;MechGen&lt;/a&gt; makes them for you.&lt;/p&gt;
</content>
  </entry>
  
</feed>
