nanovg-openfl is an OpenFL extension that adds NanoVG-backed display objects and overlays to the openfl.* package tree on native desktop targets.
The primary public API now lives under real openfl.* packages, so it reads like a normal OpenFL extension instead of a parallel mini-framework:
openfl.display.NVGShapeopenfl.display.NVGCacheModeopenfl.display.NVGOverlayopenfl.render.NVGDrawContext
This is an early library pass focused on a small but useful compatibility layer.
Currently supported by the NanoVG replay path:
- solid fills
beginBitmapFillbeginGradientFill- line styles
lineBitmapStylelineGradientStylemoveTo,lineTocurveTo,cubicCurveTodrawRect,drawRoundRectdrawCircle,drawEllipse
Commands outside that subset fall back to normal OpenFL rendering.
Gradient notes:
- linear gradients support
PAD,REFLECT, andREPEAT - radial gradients support focal points and
PAD - radial
REFLECTandREPEATare approximated with an extended texture domain, which is close in practice but not mathematically identical to Flash/AIR for arbitrarily large shapes
Bitmap notes:
- bitmap fills and strokes support
matrix,repeat, andsmooth - non-repeating bitmap fills clamp to the edge pixels, matching the Flash/AIR-style padded behavior
- bitmap replay currently requires readable
BitmapDataso the pixels can be uploaded into NanoVG
haxelib dev nanovg-openfl .For a published package later:
haxelib install nanovg-openflinclude.xml is included at the library root for OpenFL extension metadata.
Native NanoVG bridge sources are compiled from the haxelib folder path
(project/nanovg and dependencies/nanovg/src) and are not copied into Lime.
The upstream NanoVG source is tracked as a git submodule at dependencies/nanovg.
Clone with submodules:
git clone --recurse-submodules https://github.com/Dimensionscape/haxe-nanovg.gitIf you already cloned the repo without them:
git submodule update --init --recursiveThe haxe --run Run package command bundles the checked-out submodule contents into the haxelib zip, so release packaging still works as long as the submodule is initialized locally.
import openfl.display.NVGShape;
var shape = new NVGShape();
addChild(shape);
shape.graphics.lineStyle(4, 0x1E120C);
shape.graphics.beginFill(0xE98624);
shape.graphics.drawCircle(0, 0, 80);
shape.graphics.endFill();You can disable the NanoVG path per object:
shape.useNVG = false;Overlay example:
import openfl.display.NVGOverlay;
var overlay = NVGOverlay.attach(stage);
overlay.onDraw = function(ctx) {
ctx.beginPath();
ctx.circle(80, 80, 30);
ctx.fillRGBA(255, 80, 40, 220);
ctx.fill();
};Generated API docs are written to docs/.
The main pages to care about are:
docs/openfl/display/NVGShape.htmldocs/openfl/display/NVGOverlay.htmldocs/openfl/display/NVGCacheMode.htmldocs/openfl/render/NVGDrawContext.htmldocs/nanovg/NanoVGDrawContext.html
Rebuild them with:
haxe --run Run docsIf this checkout is registered with haxelib dev, you can also run:
haxelib run nanovg-openfl docsThe doc build now filters the output down to the library's own public API instead of mirroring the entire std/OpenFL surface.
Create a clean release archive for haxelib with:
haxe --run Run packageThat writes dist/nanovg-openfl-<version>.zip, containing the library sources, native bridge files, and sample project without generated Export/ output or repo-only tooling. Submit that zip with:
haxelib submit dist/nanovg-openfl-<version>.zipcppdesktop:NVGShapecan render through NanoVG.- AIR and other non-desktop targets: the class falls back to ordinary OpenFL
Shapebehavior.
The repo root project uses the side-by-side OpenFL vs NVGShape sample in samples/openfl-comparison/Source/Main.hx.
There is also a standalone sample project at samples/openfl-comparison/project.xml.
Run it with:
openfl test windows -debugOr run the sample project directly:
openfl test samples/openfl-comparison/project.xml windows -debug