Back to Syllabus
Chapter 08Creative Silicon - Verified

Procedural Image Creation & 2D Canvas

Synthesize 2D raster buffers and export standard Netpbm PPM ASCII images and SVGs directly from pure code.

This lesson uses the verified core subset and links to a checked-in regression program. Its output is covered by the repository test harness. This does not imply support for features outside the lesson; see known limitations.

What you'll learn

✓Allocate an immutable 2D canvas buffer
✓Draw geometric primitives using Euclidean distance
✓Export Netpbm P2 PPM ASCII images
✓Eliminate heavyweight image dependencies like Pillow/OpenCV

Generative Media in Pure AAYU

Create pixel-perfect images with std/media.aayu without any external C-bindings or imaging tools.

aayu
import "std/media.aayu"
import "std/fs.aayu"

let canvas = create_canvas(16, 16)
canvas = canvas_draw_circle(canvas, 8, 8, 5, 255)
let ppm_data = export_ppm_p2(canvas)
write_text("circle.ppm", ppm_data)

The output file 'circle.ppm' can be opened immediately by Photoshop, GIMP, or any standard image viewer.

Try It Yourself! 🚀

Modify the circle radius from 5 to 7 on a 24x24 canvas. Export the image and verify the increased pixel dimensions.