Chapter 01 · Java + TeaVM
Retained graphics, element by element.
Create namespaced SVG shapes, groups, text, arcs, and Bézier paths from Java. The result remains ordinary inspectable DOM.
Starting the TeaVM application…
How it works
SvgGraphics implements the shared Graphics2D interface and also exposes its root Element. Groups can have SVG transforms; clear() rebuilds a scene without replacing the root.
SvgGraphics svg = new SvgGraphics(container, 960, 540);
svg.beginGroup("translate(480 300)");
svg.circle(0, 0, 48, Paint.fill("#ffcb6b"));
svg.path(new Path2D().moveTo(0, 0)
.bezierCurveTo(20, -80, 100, -80, 120, 0),
Paint.stroke("#61d6c5", 3));
svg.endGroup();