X PixMap

Code editor

Live output

Viewer

The plaid demo is the example from the XPM manual.

Why this exists

Serializable pixel art

XPM stores pixel art as plain text, making every image readable, diffable, and easy to embed in source code. This workbench brings the X PixMap specification.

XPM format—used for icons and interface graphics in the X Window System, with images stored as plain text that could even be embedded directly in C source code. I thought that was really cool.

Edit an XPM directly, inspect the live output, and export the result without sending the source anywhere.

Format basics

Quick XPM tutorial

1

Start with ! XPM2. Lines beginning with ! are comments.

2

Define the image with width height colors chars-per-pixel. For example, 10 10 3 1.

3

Add exactly that many color lines, such as X c black or . c None.

4

Write one pixel row per image row. Each row must contain width × chars-per-pixel characters.

Adding a color? Add its definition, increase the header’s color count, then use its symbol in the pixel rows. In this editor, documents with ! colors and ! pixels markers are kept in sync automatically.

For a spherical 2.5D asset, add ! xpm-workbench primitive sphere. The opaque XPM mask supplies the sphere’s material, cached concentric slices build its volume, and the Depth control sets its Z diameter.

The Impostor (2 XPM) sphere packs two orthogonal views into one XPM atlas. In 2.5D mode, the renderer reconstructs both slice stacks and favors the one that is most face-on, avoiding the single stack’s edge-on failure. The thickness control changes the shared Z extent: it expands the first stack through its slices and the rotated stack across its in-plane Z axis. Both views keep the same camera-space shading throughout a full orbit.

Import STL accepts binary or ASCII meshes, including OpenSCAD exports. It slices the solid locally in your browser and packs the cross-sections into a portable XPM atlas; the slice-size, slice-count, and slice-layout comments reconstruct its 2.5D volume.