Exporting
The export statement saves the current state of the grid as an
image file.
Syntax
export "<filename>" in <format> [scale <factor>] filename— the output file name without extension.format— the image format:png,svg,webp, orgif.scale— optional scaling factor (default: 1).
Formats
png— lossless raster image with transparency.svg— vector format. Each pixel becomes a<rect>element. Scales without loss of quality.webp— compact raster format for the web.gif— animated format. Collects allframekeyframes into an animation.
export "art" in png
export "art" in svg
export "art" in webp
export "animation" in gif Scale
The scale factor determines how many image pixels each grid pixel becomes.
With scale 1, a 16-by-16 grid produces a 16-by-16 image. With
scale 8, the same grid produces a 128-by-128 image.
export "small" in png // 1:1, each grid pixel is one image pixel
export "medium" in png scale 4 // each grid pixel becomes a 4x4 block
export "large" in png scale 16 // each grid pixel becomes a 16x16 block
The output resolution is width * scale by
height * scale. For SVG, scale controls the size of each
<rect> element.
Multiple exports
A program can contain multiple export statements. Each one
captures the grid in its current state, so you can export intermediate steps
or the same image in different formats.
grid 9 by 9
circle (4, 4) radius 3 with #e84a00
export "step1" in png scale 8
circle (4, 4) radius 1 with #e8ddd0
export "step2" in png scale 8
This produces two files: step1.png with just the circle,
and step2.png with a smaller disc in its center.
Transparency
Pixels that have not been drawn (or that have been erased) are fully
transparent in the output. In PNG and WebP, they become transparent pixels.
In SVG, no <rect> is emitted for empty pixels.
Output
The file is written to the current working directory with the format
extension appended to the filename. For example,
export "art" in svg produces art.svg.