Exporting and saving
Saving images and data, vector PDF, 3D OBJ, and risograph print separations.
Saving images
saveFrame(); // auto-numbered screenshot
saveFrame("line.png"); // a named PNG (.bmp = fast/uncompressed)
saveImage(img, sketchPath() + "out.png"); // save a PImage to disk
sketchPath() is the folder the sketch runs from. Use nf() / nfs() to zero-pad frame
numbers into tidy filenames:
saveImage(img, sketchPath() + "frame-" + nfs(frameCount, 4) + ".png"); // frame-0042.png
A native folder picker:
std::string dir = selectFolder("Choose a folder");
if (!dir.empty()) {
saveFrame(dir + "shot.bmp");
}
Exporting an image sequence
Record one file per frame from inside draw(), then assemble them into a movie with an external
tool (for example ffmpeg):
void draw() {
background(216);
// ... animate ...
if (recording) {
saveFrame(sketchPath() + "seq/frame-" + nfs(frameCount, 5) + ".png");
}
}
Saving PDF files
beginRecord(PDF, …) captures everything drawn until endRecord() as a vector PDF — ideal for
print. Wrap just the drawing you want to keep:
void draw() {
background(216);
if (isKeyPressed && key == ' ') {
beginRecord(PDF, to_string("frame-", frameCount, ".pdf"));
}
// ... shapes here are written to the PDF ...
if (isKeyPressed && key == ' ') {
endRecord();
}
}
Exporting 3D files (OBJ)
The same record/replay pattern exports geometry as a Wavefront OBJ mesh:
beginRecord(OBJ, to_string("model-", frameCount, ".obj"));
box(200);
sphere(120);
endRecord();
Exporting risograph separations
The optional riso library
provides risograph ink channels, dithering, halftones, color separation, realistic multiply
compositing, and per-channel PNG export. Draw into one Riso canvas per ink, composite with
drawRiso(), then call exportRiso() to save the print separations.
riso requires the desktop OpenGL 3.3 Core renderer and carries the original p5.riso
Anti-Capitalist License. Consult the library guide for CMake setup, supported ink names, and
examples before distributing work made with it.
Saving text
std::vector<std::string> lines;
lines.push_back("x,y");
lines.push_back(to_string(mouseX) + "," + to_string(mouseY));
saveStrings("points.csv", lines);
Saving binary data
saveBytes() writes a byte vector to a file. Pass true to append instead of replacing the
file:
std::vector<uint8_t> bytes = {0x55, 0x4D, 0x46, 0x45, 0x4C, 0x44};
saveBytes(sketchPath() + "data.bin", bytes);
saveBytes(sketchPath() + "data.bin", more_bytes, true); // append
Exporting a standalone application
A compiled Umfeld sketch already is a native executable — there is no separate “export”
step. To ship it (bundling assets, icons, and platform packaging), see the
Advanced/application-bundle-macOS example in the repository.