← Back

ofxOceanodeVectorGraphics

github.com/PlaymodesStudio/ofxOceanodeVectorGraphics · @PlaymodesStudio
OF 0.12 Graphics

ofxOceanodeVectorGraphics is an openFrameworks addon for rendering vector graphics using the OpenGL graphics library.

0 0 Last commit 19d ago Created 5y ago

Branches ahead of master

These branches have commits not yet on master — could be unmerged fixes or work in progress worth a look.

Espills 1 commit ahead · last commit 5y ago

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.

ParameterMeaning
X, YCoordinate vectors, including points outside 0–1. Send Y before X: only an X event calculates and publishes outputs.
BorderSection separator.
Border distanceInset from each viewport side, 0–0.5; default 0.05. At 0.5 all vertices collapse to the centre.
FalloffWidth of the inward feather in normalized coordinate units, measured along rays from the centre; default 0.05. Zero gives a hard radial clamp.
CurvePower of the attenuation ramp, 0.1–8; default 1. Larger values give a firmer edge, smaller values a softer compression.
Roundness0 gives a square, 1 a circle; default 0. Intermediate values round its corners while keeping the same side bounds.
OutputsSection separator.
Out.X, Out.YConstrained coordinates. Both are staged before events; Y is notified before X.
The unchanged interior ends one Falloff distance before the boundary along each centre ray. The soft transition slows outward motion smoothly to zero; all output points remain within the hard boundary, including for far-outside inputs. The transition spans some input positions outside the boundary so it can join the unchanged interior and hard cap without a jump or a fold. For example, on the right centre ray with Border distance 0.1, Falloff 0.1 and Curve 1, input X = 0.8 stays 0.8, input X = 0.9 becomes 0.875, and input X ≥ 1 becomes 0.9. This deforms vertices radially; it does not translate each shape as a rigid body or insert clipping vertices. Falloff is limited to the available ray length.

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.

ParameterMeaning
Body_X, Body_YPaired vectors of moving spring rest positions.
Force_X, Force_YPaired vectors of repeller positions; each Body point reacts to all of them.
StrengthPer-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.
FearDistanceRadius 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 StrengthPer-Body push strength, default 40. Higher values produce a faster escape.
Return StrengthPer-Body spring stiffness, default 8. Lower values give a looser shape; zero allows free drift.
DampingPer-Body momentum decay, default 3. Lower values allow longer drifting and more spring oscillation; zero removes drag.
ResetRestore current Body coordinates and clear momentum on the next update.
Out_X, Out_YPaired simulated positions, with no canvas clamping.
All vector controls accept a float connection or a one-value vector: that value applies to every corresponding point, preserving the original scalar behavior. FearDistance, Repulsion Strength, Return Strength and Damping map to Body points; Strength maps to Force points. Path separators do not consume control values. Shorter control vectors repeat their last value; excess values are ignored. Empty, negative or nonfinite control values act as zero. Repulsion Strength and Return Strength are bounded to 0–1000 per point, and Damping to 0–100. Changing any of these vectors during motion preserves existing positions and velocities.

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.

ParameterMeaning
BypassDefault 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_YPaired vectors of moving spring rest positions, one pair per body, with -1 path separators.
A Radius, B RadiusDisk radius of each point, default 0. The interaction distance is measured between disk surfaces. The border ignores it.
A Strength, B StrengthHow strongly this body pushes the other, default 1. Zero makes the body invisible to the other; 0.5 halves its push.
A FearDistance, B FearDistanceSurface gap at which this body starts fleeing, default 0.15. Zero disables the response, even inside an overlap.
A Repulsion Strength, B Repulsion StrengthPer-point push response, default 40. Also scales that body's border push.
A Return Strength, B Return StrengthSpring stiffness toward the incoming coordinates, default 8; zero allows free drift.
A Damping, B DampingMomentum decay, default 3; zero removes drag.
Border MarginDistance 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 FeatherWidth 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.
ResetRestore both bodies to their current coordinates and clear momentum on the next update.
Clamp 0/1Default 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_YPaired simulated positions per body.
All per-body controls map to that body's points, excluding separators; one value broadcasts, shorter vectors repeat their last value, and float connections work as single values. Empty, negative or nonfinite control values act as zero. For each A/B pair the surface gap is the centre distance minus both radii; A accelerates away by 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.

Cancelling leaves the current file unchanged; selecting the same file reloads it. presets. The SVG is referenced externally, not embedded in the preset. Bezier curve. Increasing it improves curved outlines. Straight segments retain their vertices; this is not uniform distance resampling. height. Disable it for original viewport coordinates. Coordinates outside the viewport remain outside 0–1, and the Y axis follows SVG (downwards). orientation. Rotation is around (0.5, 0.5) when normalized, or the SVG viewport center otherwise. The viewport stays fixed, so rotating a non-square SVG in original coordinates can put vertices outside its original viewport. after rotation. Separators are never transformed. These settings survive file reloads and sampling changes; flips and the Inspector's Quarter Turns value are saved in presets. Set Quarter Turns to 0 to reset rotation. canvas center. Scaling is uniform about the same center as rotation. (0.25 = 90°, 0.5 = 180°, 0.75 = 270°, 1 = a full turn). This angle adds to the rotation applied with Rotate90º. width/height; positive moves right/down. With Normalize off, those offsets are multiplied by the SVG width/height. Translation is applied after rotation, flipping and scaling. Outputs are not clamped to the canvas. and sampling changes. published before X, matching SVG Modulator, Points Resampler and Shape Transform. Each nonempty contour ends in -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.

ParameterMeaning
In.X, In.YEqually sized coordinate vectors, with paired -1 path separators.
Wave InNormalized waveform. 0.5 is neutral, 0 gives negative Amount and 1 gives positive Amount. Default [0.5]; a singleton applies a constant offset.
AmountVector of target displacement amplitudes in coordinate units, default [0.05], range −1…1. Negative values invert the wave locally; zero targets the original contour.
ResponseDirect (default) follows the target immediately. Spring follows with inertia and mild, decaying overshoot.
StiffnessVector 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 InfluenceVector 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.YDeformed coordinates with the same vertex count, ordering, separators and closure as the input. No canvas clamping.
Wave In, Amount, Stiffness and Motion Influence each restart their entire vector for every separate path, including holes. Each vector may have a different length; single values broadcast everywhere, and float connections work as single-value vectors. Samples are linearly interpolated by normalized distance along the original contour; uneven vertex spacing therefore does not compress or stretch local wave cycles. The geometry itself is not resampled. A 1000-sample sine buffer containing three cycles produces three ripples around each closed shape, evaluated at its existing vertices. Use enough input vertices to resolve the waveform; this node does not add detail beyond the input geometry.

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

Get this addon

HTTPS
SSH