TeaVM + LMCode

LMCode in the browser

TeaVM compiles Java browser events to JavaScript. LMCode handlers use typed host functions to update the DOM, draw, and animate. Options map to LMCode annotations; both data modes share @data and differ only by JSON file.

Initializing LMCode…

Hydrated static HTML

TeaVM finds these static code blocks at startup and adds working copy buttons.

@canvas
fn draw() -> void implements DemoHandler {
  canvas_fill_text("diagram-canvas", "Hello", 320, 130, "#edf2ff", "20px sans-serif");
}

JSON draw DSL

Each document has a title and commands. Rectangles use w/h for size, lines for their end point, and circles use w for radius. Text commands add a text field.

{
  "title": "JSON shape scene",
  "commands": [
    {"type": "rect", "x": 220, "y": 140, "w": 180, "h": 120, "color": "#263d75"},
    {"type": "circle", "x": 500, "y": 70, "w": 38, "color": "#8dd8c5"}
  ]
}