A Java and TeaVM demo book

Draw the web.
One chapter at a time.

Eight focused pages explore SVG, HTML Canvas, reusable charts, animation, and LMCode host functions. Every chapter is a separate page: the page is the selection.

  1. SVG drawing

    Create namespaced SVG shapes, groups, text, arcs, and Bézier paths from Java. The result remains ordinary inspectable DOM.

  2. Canvas drawing

    Use the same drawing primitives on an HTML Canvas, or drop down to TeaVM's CanvasRenderingContext2D for gradients and other native operations.

  3. Bar charts

    A band scale maps categories to evenly spaced bars. A linear scale, nice ticks, grid lines, and a zero baseline complete this small chart primitive.

  4. Line charts

    Multiple named series share Cartesian scales and axes. Each series becomes a path with point markers and a generated legend.

  5. Scatter plots

    Fifty-six samples in two series demonstrate that chart layout is independent of the output backend. Circles are immediate Canvas operations here.

  6. Pie charts

    Non-negative slices are normalized into arc wedges with percentage labels, separators, and a legend. Path2D translates center-parameterized arcs for SVG.

  7. Animation and events

    TeaVM schedules requestAnimationFrame callbacks. Pointer movement updates Java fields, and the pause button demonstrates ordinary browser event handling.

  8. LMCode charts

    LMCode supplies chart data through typed host functions. Java owns the Bar records and replaces the chart only after the handler completes successfully.