ofxOceanodeVectorGraphics is an openFrameworks addon for rendering vector graphics using the OpenGL graphics library.
Branches ahead of master
These branches have commits not yet on master — could be unmerged fixes or work in progress worth a look.
README
ofxOceanodeVectorGraphics
Border Boundary
Available under Vector Graphics → Border Boundary. Pushes XY vertices toward the viewport centre to keep them inside an inset rounded square in normalized 0–1 space. It preserves vertex order, point count, repeated closing vertices and
-1 path separators. Straight segments between output vertices also stay inside the convex boundary.| Parameter | Meaning |
|---|---|
X, Y | Coordinate vectors, including points outside 0–1. Send Y before X: only an X event calculates and publishes outputs. |
| Border | Section separator. |
Border distance | Inset from each viewport side, 0–0.5; default 0.05. At 0.5 all vertices collapse to the centre. |
Falloff | Width of the inward feather in normalized coordinate units, measured along rays from the centre; default 0.05. Zero gives a hard radial clamp. |
Curve | Power of the attenuation ramp, 0.1–8; default 1. Larger values give a firmer edge, smaller values a softer compression. |
Roundness | 0 gives a square, 1 a circle; default 0. Intermediate values round its corners while keeping the same side bounds. |
| Outputs | Section separator. |
Out.X, Out.Y | Constrained coordinates. Both are staged before events; Y is notified before X. |
Control edits are sampled on the next X event. Unequal vector lengths skip calculation and retain the last complete output pair. Equal empty inputs clear both outputs. A
-1 on either axis, or a nonfinite coordinate, produces a paired -1 break at that index. Send the original upstream geometry on each update: repeatedly feeding the softened output back into the input compounds compression.Processing is O(vertices), with reusable output buffers, no per-path allocation, and no trigonometry or neighbour searches. Interior points take a fast pass;
pow is used only within the feather, with multiplication shortcuts for Curve 1 and 2. Run python3 tests/border_boundary_regression.py for standalone geometry, real OF event checks under ASan/UBSan, and full addon registration syntax checks. Add --core-only to omit OF dependencies or --benchmark for optimized core timings at 500 and 3,000 vertices. Timings exclude parameter publication/rendering; visual verification requires rebuilding the host app.Body Repulsion
Available under Vector Graphics → Body Repulsion. Body points retain their positions and velocities as Force points push them away, with smooth repulsion inside each point's fear radius. A spring pulls each point toward its current incoming Body position, and damping settles the motion. All inputs and controls are sampled on every node update, so momentum continues without input changes.
| Parameter | Meaning |
|---|---|
Body_X, Body_Y | Paired vectors of moving spring rest positions. |
Force_X, Force_Y | Paired vectors of repeller positions; each Body point reacts to all of them. |
Strength | Per-Force repulsion multiplier, default 1. Zero disables a repeller, 0.5 halves its force, and values above 1 amplify it. One value broadcasts; shorter vectors repeat their last value, excluding Force separators. Empty, negative or nonfinite values disable the corresponding repulsion. |
FearDistance | Radius in coordinate units; default 0.15. One value broadcasts. Multiple values map to Body points, excluding separators; a shorter vector repeats its last value. Empty, negative or nonfinite fear values disable repulsion for the corresponding points. |
Repulsion Strength | Per-Body push strength, default 40. Higher values produce a faster escape. |
Return Strength | Per-Body spring stiffness, default 8. Lower values give a looser shape; zero allows free drift. |
Damping | Per-Body momentum decay, default 3. Lower values allow longer drifting and more spring oscillation; zero removes drag. |
Reset | Restore current Body coordinates and clear momentum on the next update. |
Out_X, Out_Y | Paired simulated positions, with no canvas clamping. |
For a gentle floating response, start with Repulsion Strength 40, Return Strength 4 and Damping 2. For a quicker, calmer recovery, try Return Strength 12 and Damping 7. Both coordinate sets must use the same space. With normalized 0–1 coordinates, FearDistance 0.15 is 15% of one coordinate axis; use equally scaled X and Y coordinates for circular influence in the rendered image.
Repulsion is evaluated at the simulated position, with a squared falloff to zero at the fear boundary. Each contribution is multiplied by its Force point's Strength and the Body point's Repulsion Strength. Control changes take effect on the next update, preserving existing momentum. Multiple forces add; opposing contributions can cancel. Points have unit mass and move independently; this does not implement point-to-point collisions or a connected soft-body mesh. Incoming Body changes move the spring targets smoothly rather than overwriting simulated positions. At exact overlap a deterministic escape direction avoids undefined normalization; identical points with identical fear values remain together.
Paired
-1 values are preserved as path separators and never simulated. The coordinate value -1 is reserved by the addon's path protocol. Empty, mismatched, nonfinite, or incorrectly separated Body input clears outputs and simulation state. Mismatched Force vectors provide no repulsion; invalid Force points are ignored while spring motion and inertia continue. State is tracked by input index. A point count or separator-layout change resets the whole simulation; reordering equally sized vectors changes the spring targets at those indices. Loading presets and resetting Oceanode's global phase also reset momentum.The CPU implementation uses fixed 1/240-second substeps and processes at most 0.1 seconds of host time per update, dropping excess time after a long stall. It checks every Body/Force pair per substep; large point sets may need a future spatial index or GPU backend. Only controls and inputs persist in presets, not simulated velocities. When either coordinate output changes, both vectors are staged before events and Y is notified before X.
Run
python3 tests/body_repulsion_regression.py on macOS with compiled sibling openFrameworks libraries, or add --core-only for standalone physics checks. The runtime adapter uses real OF parameters/events and Oceanode float-to-vector connections, with a supplied frame clock, simulated node registration and unused GUI teardown. Visual tuning still needs a rebuilt host app.TwoBody Repulsion
Available under Vector Graphics → TwoBody Repulsion. Two bodies, A and B, repel each other with the same inertial spring model as Body Repulsion, each being the other's repeller. Every point is a disk of its body's Radius, and the gap between disk surfaces drives the push, so with Radius 0 and a passive B the node reproduces Body Repulsion with B's points as Force points exactly. A border wall keeps the points of both bodies inside the 0–1 canvas.
| Parameter | Meaning |
|---|---|
Bypass | Default off. Copies all four body coordinate inputs directly to their outputs, skipping simulation and border calculations. Turning it off restarts from the current inputs with no momentum. |
A Body_X, A Body_Y, B Body_X, B Body_Y | Paired vectors of moving spring rest positions, one pair per body, with -1 path separators. |
A Radius, B Radius | Disk radius of each point, default 0. The interaction distance is measured between disk surfaces. The border ignores it. |
A Strength, B Strength | How strongly this body pushes the other, default 1. Zero makes the body invisible to the other; 0.5 halves its push. |
A FearDistance, B FearDistance | Surface gap at which this body starts fleeing, default 0.15. Zero disables the response, even inside an overlap. |
A Repulsion Strength, B Repulsion Strength | Per-point push response, default 40. Also scales that body's border push. |
A Return Strength, B Return Strength | Spring stiffness toward the incoming coordinates, default 8; zero allows free drift. |
A Damping, B Damping | Momentum decay, default 3; zero removes drag. |
Border Margin | Distance from the canvas edge that no point may cross, default 0. A hard limit: positions are clamped and momentum into the wall is dropped. |
Border Feather | Width of a soft push inside the margin, default 0. The push ramps with a squared falloff over the feather width and is full strength past the margin. |
Reset | Restore both bodies to their current coordinates and clear momentum on the next update. |
Clamp 0/1 | Default off. Hard wall at the canvas edge: every point stays inside 0–1 on both axes and momentum into the edge is dropped, whatever the border settings. Bypass ignores it. |
A Out_X, A Out_Y, B Out_X, B Out_Y | Paired simulated positions per body. |
A Repulsion Strength × B Strength × A FearDistance × falloff² while the gap is inside A FearDistance, and B does the same with its own fear and strength roles swapped. Inside an overlap the push is constant, and exactly coincident points part in opposite directions. Each body keeps its own identity: a point count or separator layout change resets that body only, and an empty or invalid body clears its own output while the other keeps simulating.The border is active when
Clamp 0/1 is on or Border Margin or Border Feather is above zero, and assumes normalized 0–1 coordinates; with all three off the output is unclamped, like Body Repulsion. Clamp 0/1 alone is a hard wall at 0 and 1; a margin moves that wall inward and a feather adds the soft push. The wall acts on point positions and ignores Radius, so a contour body with a large Radius is not squeezed toward the centre; a margin past the canvas centre holds points at 0.5.Both bodies share one clock with fixed 1/240-second substeps and at most 0.1 seconds of host time per update. Every A/B pair is evaluated once per substep and pushes both sides, pairs outside the largest reach skip the square root, and bodies whose expanded bounding boxes do not overlap skip the pair loop entirely. On an Apple Silicon laptop two bodies of 300 points cost about 0.8 ms per 60 fps frame while overlapping and under 0.03 ms while apart; 1000 points per body cost about 8 ms while overlapping, so a spatial index would only pay off beyond roughly 500 points per body.
Run
python3 tests/two_body_repulsion_regression.py on macOS with compiled sibling openFrameworks libraries, or add --core-only for standalone physics checks. The node tests share tests/support/oceanodeHeadlessStubs.h with Body Repulsion, which stands in for the GUI scope, scheduling and dropdown graph dependencies of core parameters.Trim Paths Pro
Available under Vector Graphics → Trim Paths Pro. Combines local edge trimming, per-path reveals, whole-input sequencing and overlapping visual groups. Start, End and Origin map independently; Origin shifts the trim with wrapping, and progress can use edge count or distance. Existing trim nodes remain available for older patches.
See Trim Paths Pro usage and vector mapping for examples, output formats, group editing and legacy equivalents. Run
python3 tests/trim_paths_pro_regression.py on macOS with compiled sibling OF libraries, or add --core-only for the standalone geometry regressions.SVG Polyline Loader
Available under Vector Graphics → SVG Polyline Loader. The existing SVG Modulator remains available for older patches.
- Load SVG opens the native file picker in the application's
datafolder.
- File accepts an absolute path or a path relative to
data, and is saved in
- Curve Resolution (default 32, range 2–1024) sets the number of segments per
- Normalize defaults to on: divide X by the SVG viewport width and Y by its
- Rotate90º rotates clockwise by 90° per click; four clicks restore the original
- FlipX mirrors horizontally and FlipY vertically about the same center,
- Scale uses 0–1, default 1 (original size); 0 collapses every contour to the
- Rotate uses 0…1 for 0°…360°, default 0. Rotation turns clockwise
- MoveX / MoveY use −1…1, default 0. Values are fractions of the full canvas
- All transform controls persist in presets and are reapplied after file reloads
- Vertex_Y, then Vertex_X, contain equally sized float vectors. Y is
-1 in both vectors, including the last contour. Closed contours repeat their first vertex before that separator. The -1 value is reserved by this coordinate protocol.The loader uses the existing
ofxSvg dependency and its supported SVG subset. It preserves open subpaths and fill-only outlines, flattens Beziers, handles transforms and viewBox-only exports, and keeps the parser's path order. Text, embedded images, clipping, CSS and other advanced SVG features are limited by ofxSvg; convert text to outlines when exporting. Color output is not included. Invalid or missing files clear the coordinates and show an error on the node.Run
python3 tests/svg_polyline_loader_regression.py on macOS with compiled sibling openFrameworks libraries. It syntax-checks the addon and runs real SVG parsing/geometry tests with ASan/UBSan; node registration and the native dialog are simulated in the runtime fixture. The native UI still needs a host-app check.Wave It
Available under Vector Graphics → Wave It. Deforms any XY contour along its local perpendicular, including MetaballsV3, SVG outlines and generated paths.
| Parameter | Meaning |
|---|---|
In.X, In.Y | Equally sized coordinate vectors, with paired -1 path separators. |
Wave In | Normalized waveform. 0.5 is neutral, 0 gives negative Amount and 1 gives positive Amount. Default [0.5]; a singleton applies a constant offset. |
Amount | Vector of target displacement amplitudes in coordinate units, default [0.05], range −1…1. Negative values invert the wave locally; zero targets the original contour. |
Response | Direct (default) follows the target immediately. Spring follows with inertia and mild, decaying overshoot. |
Stiffness | Vector of spring strengths, default [40], range 0–1000. Higher values respond faster; lower values move more softly. Zero holds the current normal offset and clears its velocity. Ignored in Direct mode. |
Motion Influence | Vector of input-motion coupling strengths, default [0], range 0–1. Zero preserves the original wave-only behaviour; one gives full normal-direction coupling. Active only in Spring with positive Stiffness. |
Out.X, Out.Y | Deformed coordinates with the same vertex count, ordering, separators and closure as the input. No canvas clamping. |
Closed paths are detected by an exactly repeated first/last coordinate. They sample Wave In as a periodic buffer, including interpolation from the final sample back to the first. Supply periodic samples without duplicating the wave endpoint (e.g.
0.5 + 0.5sin(2pi3i/1000), for i=0…999). The repeated geometry endpoint always gets exactly the first point's deformed position. Positive displacement points outward for simple closed shapes, independent of winding. Each hole is handled independently, so positive displacement enlarges its outline too.Open paths retain open endpoints and use the first/last wave samples at their start/end. Their positive normal is
(-tangent.y, tangent.x); reversing the path reverses that side. Normals use the average of adjacent unit edge directions, with one-sided normals at open endpoints. Adjacent duplicate vertices share one position and normal. Isolated points and zero-length paths remain unchanged; reversing cusps use the outgoing direction. Self-intersecting loops have no unambiguous inside/outside, and large offsets may create intersections. Wave It does not repair or recompute contour topology.Empty Wave In or Amount targets zero deformation. Wave samples are clamped to 0–1; nonfinite samples act as 0.5. Empty/nonfinite Amount, Stiffness and Motion Influ
ofxAddons