Exporting and saving
Saving frames and images, vector PDF, 3D OBJ files, text, and raw binary data.
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();
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
Umfeld has no saveBytes() — use the C++ standard library, which is always available:
#include <fstream>
std::ofstream out(sketchPath() + "data.bin", std::ios::binary);
out.write(reinterpret_cast<const char*>(buffer), byte_count);
out.close();
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.