ofxVectorEditor packages a small, generic ImVectorEditor path editor
widget for openFrameworks projects. The core widget follows the ImPlot /
ImNodes / ImGuizmo style: reusable immediate-mode types live in the
ImVectorEditor namespace.
Two layers, one addon:
ImGuiVectorEditor.h/.cpp— the pure ImGui widget. No hard OF dependency: drop the two files into any ImGui project. Inside an OF project it automatically gainsofPathconversion (Path::loadOfPath/Path::toOfPath, arcs imported as cubics).ofxVectorEditor.h/.cpp— the OF conveniences:PathEditor(bind anofPath, edit it in a self-contained pan/zoom/ruler panel),PathDocument(ofPath layers + ImGui layers panel), and header-only SVG import (ofxVectorEditorSvg.h, needs ofxSvg).
Everything is instantiable — plain classes, no singletons or global state.
#include "ofxImGui.h"
#include "ofxVectorEditor.h"
ofxImGui::Gui gui;
ImVectorEditor::Editor editor;
ImVectorEditor::Path path;
ImVectorEditor::Config config;
void ofApp::draw() {
gui.begin();
ImGui::Begin("Vector Editor");
config.tool = ImVectorEditor::Tool::Pen;
config.canvasSize = ImVec2(800, 500);
auto result = editor.Draw("##editor", path, config);
if (result.changed) {
// Convert or consume `path` in your host application.
}
ImGui::End();
gui.end();
}#include "ofxVectorEditor.h"
ofPath myPath; // your existing ofPath
ImVectorEditor::PathEditor pathEditor;
void ofApp::setup() {
pathEditor.bind(myPath); // edits write back automatically
}
void ofApp::draw() {
myPath.draw(); // native rendering, always current
gui.begin();
ImGui::Begin("Editor");
pathEditor.draw("##editor"); // pan: middle-drag, zoom: wheel
ImGui::End();
gui.end();
}Any ofPath imports: lines and cubics map 1:1, quads are promoted to cubics,
arcs are approximated with cubic segments. PathDocument adds ordered layers
(visibility, lock, color, rename, drag-reorder) with drawImGuiPanel(), and
ofxVectorEditorSvg.h loads each SVG path into a layer.
Path anchors are stored in local path space. Config::transform maps that local
space into the ImGui canvas:
- Apply
objectScale. - Apply
objectRotationRadians. - Apply
objectTranslation. - Apply canvas
zoom. - Apply canvas
pan.
Object transforms belong to the host application, while anchor and handle edits belong to the vector editor.
The widget does not depend on ImGuizmo, but it is designed to compose with it.
Use ImGuizmo for object transforms and feed the resulting values into
Config::transform. Use the capture flags to decide who receives pointer input:
auto result = editor.Draw("##editor", path, config);
if (!editor.WantsMouseCapture()) {
// Safe for the host to route mouse input to ImGuizmo.
}