Showing posts with label visual programming. Show all posts
Showing posts with label visual programming. Show all posts

Friday, 30 October 2026

Visual Programming Languages: Thirteen Tools That Teach Code Before Syntax

Standard


We are in an AI era. A student can paste a homework prompt into a chatbot and get working Python back in seconds. That does not mean they can read the result, fix it, or tell a good loop from a lucky guess. Before kids step into AI usage, they still need the old core: what a program is, how logic branches, and why a computer only does what you asked, not what you meant.

Visual programming languages (VPLs) are the school-friendly way to build that core. You snap a block, draw a flowchart, or move a character, then watch the idea run. Typing, and later prompting, come after the student can see sequence, choice, and loops. A first class that dies on a missing semicolon never gets that far. A class that starts visual usually does.

This post walks through thirteen tools that keep showing up on school laptops, lab benches, and phone screens: Flowgorithm, MIT Scratch, Blockly, Snap!, Sketchware, Alice, MIT App Inventor, Kodu, Moenagade, Open Roberta, Kojo (Kogics), Visual Logic, and Flowcode. They are not one product family. They share one bet: if you can see the program, you can think about the program, and that thinking is still required in an AI classroom (Resnick et al., 2009; Cook, 2015).

Key Abbreviations in This Post

  • VPL (Visual Programming Language): A language you build by placing shapes, not by typing source first.
  • IDE (Integrated Development Environment): The editor, runner, and debugger in one window.
  • CS1: A first university or college programming course.
  • BYOB (Build Your Own Blocks): The Scratch fork that became Snap!. Adds first-class procedures.
  • NEPO: The block language used in Open Roberta Lab (Fraunhofer IAIS).
  • APK (Android Package): The install file an Android phone runs.
  • SoC / MCU (Microcontroller): The small chip Flowcode and robot labs actually flash.
  • EV3 / micro:bit / Arduino: Common classroom robots and boards that Open Roberta and similar tools target.
  • Scala: The text language behind Kojo. Looks like a modern Java cousin, with a gentler start.
  • Export / code gen: Turning a flowchart or block stack into C++, Java, Python, or similar.

The One-Minute Version

  • Scratch, Snap!, Blockly: Puzzle blocks. Scratch is the kids' studio. Snap! is the university-strength cousin. Blockly is the library other apps sit on.
  • App Inventor and Sketchware: Same block idea, aimed at a phone app. App Inventor is browser plus companion. Sketchware lives on the phone.
  • Alice and Kodu: 3D stories and games. Sequence and events without a blank text file.
  • Flowgorithm, Visual Logic, Flowcode: Executable flowcharts. The first two teach algorithms. Flowcode talks to real boards.
  • Open Roberta: Browser blocks for robots. No local install fight with school IT.
  • Moenagade: Blocks that become real Java you can open in NetBeans.
  • Kojo (Kogics): Turtle, art, math, and Scala. Visual canvas, text language.
Thirteen visual programming tools arranged as a family of cards

Why These Tools Exist

Text languages punish beginners twice. First for the idea. Then for the grammar. A Hello World in Java already hides classes, static methods, and string arrays. The student needed output. They got object-oriented ceremony (Cook, 2015).

Research on CS1 keeps finding the same pattern. Students spend the hour hunting syntax, then leave without a working algorithm. Visual tools cut the grammar tax so the hour goes to sequence, choice, loops, and events (Gudmundsen et al., 2012; Cooper et al., 2000).

Problem: a 14-year-old can describe "if the sprite hits the wall, bounce," but cannot type the event handler.
Cause: the language wants listeners, coordinates, and braces before it will move a pixel.
Effect: they quit, or they copy a snippet they cannot read. A block editor lets them snap when touching edge, bounce and see it work the same afternoon (Resnick et al., 2009).

That is the whole family in one story. The tools differ in shape: flowchart, puzzle, 3D stage, robot, phone, or turtle canvas.

Three visual styles: flowcharts, puzzle blocks, and 3D stages
Same idea. Three shapes. Flowchart Ovals, boxes, diamonds Run the chart as a program Flowgorithm Visual Logic Flowcode Best for algorithm class Puzzle blocks Snap pieces that fit Wrong types will not dock Scratch, Blockly, Snap! App Inventor, Sketchware Moenagade, Open Roberta Best for events and apps Worlds and canvas A stage you can see Code moves a body or pen Alice, Kodu Kojo (turtle + art) Open Roberta (robots) Best for stories and motion

Block Studios: Scratch, Blockly, Snap!

These three get mixed up in every faculty meeting. Scratch is a product kids open. Blockly is a JavaScript library you embed. Snap! is a Scratch descendant that treats procedures as data, which is why UC Berkeley can teach CS10 with it (Harvey & Mönig, 2010; Fraser, 2015).

MIT Scratch

Scratch came out of the Lifelong Kindergarten group at the MIT Media Lab, led by Mitchel Resnick. The public 1.0 release was 2007. Scratch 2.0 moved to the browser in 2013. Scratch 3.0 (2019) rebuilt the editor on Blockly (Resnick et al., 2009; Scratch Foundation, 2019).

You drag colored blocks: motion, looks, sound, events, control, sensing, operators, variables. Sprites live on a 2D stage. The community is the other half of the product. Kids remix shared projects, which is how a cat-chasing-a-mouse game becomes a thousand variants.

Use it when: ages 8 to 16, clubs, intro computing, media and storytelling. Not when you need a published Android store app or a PIC microcontroller.

Problem → cause → effect: a middle-schooler wants a game by Friday. A text IDE asks for a window toolkit first. Scratch gives a stage, a green flag, and a forever loop. They ship a playable sketch, then later ask what a real loop looks like in Python.

Blockly

Google released Blockly as open source in 2012. Neil Fraser and the Blockly team built a drop-in block editor: toolbox, workspace, code generators for JavaScript, Python, PHP, Lua, Dart, and others (Fraser, 2015).

You do not "switch a class to Blockly" the way you switch a class to Scratch. You put Blockly inside something else. App Inventor, Code.org, MIT Scratch 3, Microsoft MakeCode, and Open Roberta all sit on that idea. The blocks look familiar because the library taught the industry a visual grammar: C-shaped loops, puzzle-piece types, a trash can.

Use it when: you are building an editor, a lesson site, or a hardware tool and you do not want to invent snapping from scratch.

Snap!

Snap! (often written Snap) grew from BYOB, a Scratch modification by Jens Mönig and Brian Harvey. The goal was a ceiling, not only a floor. You can build your own blocks. Lists and procedures are first-class. You can write a map or a recursive tree without leaving the block world (Harvey & Mönig, 2010).

Berkeley's Beauty and Joy of Computing course uses Snap! so students meet abstraction before they meet Java braces. If Scratch is "make a game," Snap! is "make a language that makes games."

Use it when: high school AP-style computing, CS0/CS1 that wants functions as values, or a Scratch kid who outgrew the built-in palette.

Scratch as the kids studio, Blockly as the library, Snap as the university-strength blocks

Phone Apps: App Inventor and Sketchware

Two answers to "can I ship something my friends can install?" One assumes a laptop. One assumes only a phone.

MIT App Inventor

App Inventor started at Google in 2009 and moved to MIT in 2011 and 2012. The current MIT App Inventor is a browser IDE: Designer for screens and components, Blocks for behavior. The block engine is Blockly. Companion apps on Android (and later iOS) let you live-test without a full compile every click (Wolber et al., 2014; MIT App Inventor, 2024).

You get sensors, maps, speech, TinyDB, and web APIs as components. That is why a civic-tech class can build a pothole reporter in two weeks. The limit is the component set and the performance of the generated app, not the student's ability to type Java.

Sketchware

Sketchware put the same block idea on the Android device itself. You design a layout, snap logic, and build an APK on the phone. The original commercial app later stalled. The community kept the idea alive as Sketchware Pro (Sketchware Pro, 2023).

It is messy in the way phone-native tools are messy: storage permissions, signing keys, Play Store policy. It is also the only option in rooms where there is no laptop cart.

Problem → cause → effect: a college club wants a campus bus app. App Inventor gives Designer plus Blocks on a lab PC, then a QR install. A student with only a phone uses Sketchware and sideloads the APK. Same visual habit. Different hardware constraint.

App Inventor on a laptop with a phone companion, Sketchware coding on the phone itself

Stories and Games: Alice and Kodu

Alice

Alice is a 3D environment from Carnegie Mellon University. Randy Pausch, Steve Cooper, and Wanda Dann built it so novices could tell a story in a virtual world while learning objects, methods, and events (Cooper et al., 2000). Alice 3 added a path toward Java and aligned characters with a commercial 3D gallery.

A student drops a person in a room, writes walk to the door, then say "hello". The camera and the character make bugs obvious. If the person walks through the wall, the algorithm is wrong. You do not need a debugger log.

Kodu

Kodu Game Lab came from Microsoft Research (Matt MacLaurin and team). It started on Xbox and later landed on Windows. Rules look like tiles: WHEN see apple DO move toward. Terrain, characters, and scoring sit in a small 3D world (MacLaurin, 2011).

Kodu teaches event-condition-action, not algebra. That is a feature. A primary class can build a collect-the-coins game without variables if they do not need them yet. When they do, score and pages are there.

Use Alice when the course wants objects and storytelling on a PC.
Use Kodu when the course wants a game controller, a hill, and a rover, and the students are younger.

Alice 3D storytelling classroom and Kodu game hills with a rover

Flowchart Trio: Flowgorithm, Visual Logic, Flowcode

Blocks hide syntax. Flowcharts hide almost everything except control flow. Intro algorithm courses love them because the chart is the program.

Flowgorithm

Devin Cook at California State University, Sacramento, built Flowgorithm as a free, executable flowchart language. You drop start, input, assign, output, if, loops, functions, and arrays. You run it. A watch window shows variables. Then you generate C#, C++, Java, JavaScript, Python, Ruby, Swift, Visual Basic, and more, interactively, so the student can see how a diamond becomes an if (Cook, 2015; Flowgorithm, 2024).

It is Windows-first, light, and honest about its job: teach logic, then hand the student a real language.

Visual Logic

Visual Logic (visuallogic.org) is a commercial executable-flowchart tool used in U.S. program-logic courses. It covers variables, input and output, conditions, loops, procedures, arrays, and files. The demo watermarks and will not save. Departments buy a license when they want a whole CS0 term on charts, then a jump to Python or Java (Gudmundsen et al., 2012; Crews & Murphy, 2009).

Compared with Flowgorithm, Visual Logic is less about multilingual export and more about a closed teaching loop: draw, run, grade.

Flowcode

Flowcode, from Matrix TSL in the United Kingdom (the company once known as Matrix Multimedia), is a commercial visual IDE for embedded systems. Students draw flowcharts or use a mix of flowchart, blocks, and C, then simulate and download to PIC, Arduino, AVR, and other boards. Education licenses pair with E-blocks, AllCode robots, and curriculum packs for motors, sensors, and comms (Matrix TSL, 2024).

Do not treat Flowcode as a CS1 flowchart toy. It is an electronics and mechatronics tool that happens to be visual. The "Hello World" is an LED, not a console line.

Problem → cause → effect: a technician course must teach PWM before it teaches pointers. Flowcode lets the student chart "read pot, write duty cycle," simulate the LED brightness, then flash a board. They meet C later, when the generated code is no longer magic.

Flowgorithm and Visual Logic for algorithms, Flowcode for microcontroller boards

Robots and a Java Bridge: Open Roberta and Moenagade

Open Roberta

Open Roberta Lab is a browser environment from Fraunhofer IAIS in Germany, grown out of the Roberta initiative that put robots in schools. The language is NEPO, a Blockly-inspired block set. Pick a robot, snap actions and sensors, run a simulation or download. Targets have included LEGO EV3, NXT, WeDo, Calliope, micro:bit, Arduino-class boards, NAO, and others. Generated code depends on the target: Java, Python, C/C++, MicroPython (Fraunhofer IAIS, 2024).

The classroom win is logistics. No admin rights. Any OS. One URL. A teacher can move from EV3 one term to micro:bit the next without rewriting the pedagogy.

Moenagade

Moenagade is a small, honest tool. Franz-Josef Schmitt (fesch) published it around 2017 from Luxembourg (moenagade.fisch.lu, GitHub fesch/Moenagade). It is GPL-3. Blocks describe beginner Java structures. The point is the live conversion to real, executable Java that you can later open in NetBeans or Unimozer (Schmitt, 2017).

It is limited on purpose. Other block tools hide the text. Moenagade exists because the author wanted students to see the Java appear while they still remember why they snapped the loop.

Open Roberta NEPO blocks for robots and Moenagade blocks that compile to Java

Kojo, from the Kogics Foundation

People write "Kogics" on a syllabus and mean Kojo. Kogics is the foundation. Kojo is the learning environment Lalit Pant built: desktop app for Linux, Windows, and Mac, plus a web app. The language is Scala. The first contact is often turtle graphics, then pictures, animation, games, music, and even Arduino (Kogics Foundation, 2024).

Kojo is a hybrid, not a pure VPL. You type. The canvas answers. That is closer to Logo and Processing than to Scratch. Indian state curricula have used it in grades 7 to 10 because one tool can cover drawing, math, and a path into a real industrial language.

Use it when: you want art and algebra in the same window, and you are willing to teach a little text on day one.

Kojo from Kogics with a turtle drawing on a canvas next to Scala code

How the Thirteen Compare

Pick by output, not by fashion Tool Shape Home You walk out with Flowgorithm Flowchart Desktop, free Logic + 18 language exports Visual Logic Flowchart Desktop, licensed Gradable algorithm labs Flowcode Flow + C Matrix TSL, paid Firmware on a real MCU Scratch Blocks MIT, browser Games, stories, remixes Snap! Blocks++ Berkeley, browser Functions as data, CS0 Blockly Library Google, JS Your own block editor App Inventor Blocks MIT, browser Phone app + sensors Sketchware Blocks Android device APK built on the phone Alice 3D world Carnegie Mellon Story + objects → Java path Kodu Tiles / 3D Microsoft Research Xbox/PC game worlds Open Roberta NEPO blocks Fraunhofer, browser Robot / board program Moenagade Blocks Desktop, GPL Visible Java source Kojo (Kogics) Text + canvas Kogics, desktop/web Art, math, Scala A useful split Teach thinking: Flowgorithm, Visual Logic, Scratch, Snap!, Alice, Kodu, Kojo Ship an artifact: App Inventor, Sketchware, Open Roberta, Flowcode, Moenagade Build a tool: Blockly

Which Tool Fits the Room

Do not start with the brand on a conference slide. Start with the artifact and the hardware you already own.

  • Kids, games, remix culture: Scratch. If they outgrow it, Snap!.
  • Phone in their pocket: App Inventor if you have laptops. Sketchware if you do not.
  • 3D story, objects, later Java: Alice.
  • Controller and a landscape: Kodu.
  • CS0 algorithm unit, Windows lab: Flowgorithm (free) or Visual Logic (licensed, save/grade workflow).
  • Electronics, PIC, Arduino kits you already bought from a UK catalog: Flowcode.
  • Robot cupboard, locked-down school PCs: Open Roberta in the browser.
  • Must see Java this term: Moenagade, then NetBeans.
  • Math, art, India-friendly curriculum, Scala later: Kojo.
  • You are the one writing the editor: Blockly.
Decision tree matching a project type to a visual programming tool

A Classroom Path That Does Not Trap Students

Visual tools fail when they become a gated community. The student can snap forever and still freeze in front of a blank main. The better path is short and visible.

  1. See the idea. Stage, flowchart, or robot. One output on day one.
  2. Snap or draw the steps. Sequence, then if, then loop. Name the pattern out loud.
  3. Run and watch. Step mode if the tool has it (Flowgorithm's watch window, Scratch's single-step, robot simulation).
  4. Fix the bug you can see. The sprite walks through the wall. The LED never lights. The flowchart never reaches Output.
  5. Export once, on purpose. Flowgorithm to Python. Moenagade to Java. Open Roberta to the target language. App Inventor students open the built APK and talk about events in words that will match later Java listeners.

Problem: year-10 students ace Scratch and fail the first Python quiz.
Cause: the course never showed that a C-shaped block is a while, and never made them type one.
Effect: they call visual languages "not real." Pair every unit with a 20-minute export or rewrite. The tool is a scaffold, not a career.

Five-step classroom path from seeing an idea to exporting real code

What These Tools Are Not

They are not a replacement for data structures, complexity, or systems programming. They will not make a production backend. Blockly inside a factory HMI is still an HMI, not a proof that blocks scale to every domain.

They also are not all free, and they are not all alive at the same speed. Visual Logic and Flowcode are commercial. Sketchware's original store listing went quiet. Moenagade's last public push was 2018. Scratch, Snap!, Blockly, App Inventor, Open Roberta, Kojo, and Flowgorithm are the ones you can plan a three-year curriculum around without holding your breath.

Pick the living tool that matches the artifact. Keep the export step. Treat the colorful blocks as a way to think, not as a place to hide.

References

  • Cook, D. D. (2015). Flowgorithm: Principles for teaching introductory programming using flowcharts. ASEE Annual Conference. https://peer.asee.org/flowgorithm-principles-for-teaching-introductory-programming-using-flowcharts
  • Cooper, S., Dann, W., & Pausch, R. (2000). Alice: A 3-D tool for introductory programming concepts. Journal of Computing Sciences in Colleges, 15(5), 107–116.
  • Crews, T., & Murphy, C. (2009). A guide to working with Visual Logic. Course Technology.
  • Flowgorithm. (2024). Flowgorithm: Flowchart programming language. http://flowgorithm.org/
  • Fraser, N. (2015). Ten things we've learned from Blockly. In 2015 IEEE Blocks and Beyond Workshop (pp. 49–50). IEEE. https://developers.google.com/blockly
  • Fraunhofer IAIS. (2024). Open Roberta Lab. https://lab.open-roberta.org/
  • Gudmundsen, D., Olivieri, L., & Sarawagi, N. (2012). Reducing the learning curve in an introductory programming course using Visual Logic. Journal of Computing Sciences in Colleges, 27(4), 10–12.
  • Harvey, B., & Mönig, J. (2010). Bringing "no ceiling" to Scratch: Can one language serve kids and computer scientists? Constructionism 2010. https://snap.berkeley.edu/
  • Kogics Foundation. (2024). Kojo. https://www.kogics.net/kojo
  • MacLaurin, M. (2011). The design of Kodu: A tiny visual programming language for children on the Xbox 360. Proceedings of the 38th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (pp. 241–246). ACM.
  • Matrix TSL. (2024). Flowcode for education. https://flowcode.co.uk/education/
  • MIT App Inventor. (2024). MIT App Inventor. https://appinventor.mit.edu/
  • Resnick, M., Maloney, J., Monroy-Hernández, A., Rusk, N., Eastmond, E., Brennan, K., Millner, A., Rosenbaum, E., Silver, J., Silverman, B., & Kafai, Y. (2009). Scratch: Programming for all. Communications of the ACM, 52(11), 60–67. https://scratch.mit.edu/
  • Schmitt, F.-J. (2017). Moenagade [Computer software]. GitHub. https://github.com/fesch/Moenagade
  • Scratch Foundation. (2019). Scratch 3.0. https://scratch.mit.edu/
  • Sketchware Pro. (2023). Sketchware Pro [Computer software]. GitHub. https://github.com/Sketchware-Pro/Sketchware-Pro
  • Wolber, D., Abelson, H., Spertus, E., & Looney, L. (2014). App Inventor 2: Create your own Android apps. O'Reilly.

Sunday, 26 July 2026

LightDraw Diagram Engine: JSON In, Animated Visuals Out

Standard

Hi, this is part 2 of my LightDraw series. Last time we covered the big picture (dashboards, automotive, diagrams, UI). Today we go deep on one feature people keep asking about: diagram wire-flow animation, and how to drive every chart from plain JSON you can store, edit, or generate with AI.

By the end of this post you’ll be able to:

  • Describe a flowchart, pipeline, network, org chart, schematic, or UML class diagram as JSON
  • Pass that JSON to JavaScript and render it with LightDraw
  • Turn on path animation (dashes + packets + status tint) and use the built-in play/pause toolbar
  • Copy working examples without fighting a framework stack

Requires: lightdraw@1.2.1+ for the built-in diagram toolbar when flow.enabled is on.

The mental model (keep this)

Everything in this post follows the same three steps:

  1. Write a scene object: { type, props }
  2. Mount it: Diagram.fromJSON(type, props, app) → app.add(chart)
  3. Optional polish: fitToBounds, editor, flow controls
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lightdraw@1/dist/lightdraw.min.css">
<div id="app" style="position:relative; width:800px; height:480px;"></div>
<script src="https://cdn.jsdelivr.net/npm/lightdraw@1/dist/lightdraw.min.js"></script>
<script>
const app = LightDraw.createApp('#app', {
  width: 800,
  height: 480,
  renderer: 'canvas',
  background: '#0f172a',
});

function mountDiagram(scene) {
  app.clear();
  const chart = LightDraw.Diagram.fromJSON(scene.type, scene.props, app);
  app.add(chart);
  LightDraw.Diagram.fitToBounds(chart, 800, 480, 24);
  return chart;
}

// later: mountDiagram(yourScene);
</script>

That’s the whole contract. Your diagrams live as JSON. JS only loads and renders them.

1. Flowchart: decisions, paths, and motion

Figure: Flowchart with multi-path wire flow and status tint (idle → active → done).

A flowchart is nodes + edges. Animation is just an ordered list of node ids under flow.paths.

const flowchartScene = {
  type: 'flowchart',
  props: {
    width: 800,
    height: 480,
    data: {
      nodes: [
        { id: 'start', label: 'Start', type: 'start', x: 360, y: 24 },
        { id: 'check', label: 'Valid?', type: 'decision', x: 360, y: 110 },
        { id: 'process', label: 'Process', type: 'process', x: 360, y: 210 },
        { id: 'notify', label: 'Notify', type: 'process', x: 140, y: 210 },
        { id: 'end', label: 'Done', type: 'end', x: 360, y: 320 },
      ],
      edges: [
        { from: 'start', to: 'check' },
        { from: 'check', to: 'process', label: 'Yes' },
        { from: 'check', to: 'notify', label: 'No' },
        { from: 'process', to: 'end' },
        { from: 'notify', to: 'end' },
      ],
    },
    flow: {
      enabled: true,
      mode: 'both',          // 'dash' | 'packet' | 'both'
      playback: 'loop',      // or 'once'
      highlight: 'pulse',
      statusHighlight: true,
      speed: 1.5,
      pathGapMs: 400,
      paths: [
        ['start', 'check', 'process', 'end'],
        ['start', 'check', 'notify', 'end'],
      ],
    },
  },
};

mountDiagram(flowchartScene);

Tip: Status tint needs packet or both. Grey = not yet visited, yellow = current hop, green = done for this path run.

2. Process pipeline: CI / ETL stages

Figure: Process pipeline stages animating in order.

const pipelineScene = {
  type: 'processPipeline',
  props: {
    width: 800,
    height: 280,
    stages: [
      { id: 'ingest', label: 'Ingest', status: 'done', type: 'input' },
      { id: 'validate', label: 'Validate', status: 'done', type: 'test' },
      { id: 'build', label: 'Build', status: 'active', type: 'build' },
      { id: 'test', label: 'Test', status: 'pending', type: 'test' },
      { id: 'deploy', label: 'Deploy', status: 'pending', type: 'deploy' },
    ],
    flow: {
      enabled: true,
      mode: 'both',
      playback: 'loop',
      statusHighlight: true,
      path: ['ingest', 'validate', 'build', 'test', 'deploy'],
    },
  },
};

mountDiagram(pipelineScene);

Use a single path for one run, or paths: [['a','b'], ['a','c']] for alternating runs (same as flowchart).

3. Network topology: traffic between devices

Figure: Network icons with two traffic paths (edge → web, edge → API → DB).

const networkScene = {
  type: 'networkTopology',
  props: {
    width: 800,
    height: 400,
    data: {
      nodes: [
        { id: 'inet', label: 'Internet', type: 'cloud', x: 360, y: 24 },
        { id: 'fw', label: 'NGFW', type: 'ngfw', x: 360, y: 130 },
        { id: 'web', label: 'Web', type: 'server', x: 160, y: 260 },
        { id: 'api', label: 'API', type: 'server', x: 360, y: 260 },
        { id: 'db', label: 'SQL', type: 'sql_database', x: 560, y: 260 },
      ],
      edges: [
        { from: 'inet', to: 'fw' },
        { from: 'fw', to: 'web' },
        { from: 'fw', to: 'api' },
        { from: 'api', to: 'db' },
      ],
    },
    flow: {
      enabled: true,
      mode: 'both',
      playback: 'loop',
      paths: [
        ['inet', 'fw', 'web'],
        ['inet', 'fw', 'api', 'db'],
      ],
    },
  },
};

mountDiagram(networkScene);

Node type values map to a Visio/Cisco-style catalog (server, router, ngfw, sql_database, cloud, …). Perfect for NOC boards and security runbooks.

4. Animation properties & controls (the JSON knobs)

Figure: Built-in toolbar (▶⏸↻ + zoom + Fit) with path status tint.

All of these live under props.flow and round-trip with Diagram.toJSON / fromJSON:

PropertyValuesWhat it does
enabledtrue / falseStart wire-flow animation
modedash · packet · bothMarching dashes, traveling dot, or both
playbackloop · onceRepeat forever, or play then pause
paths / patharray of node idsOrdered hops to animate
speednumber (e.g. 1.5)Playback rate
pathGapMsmsPause between path runs
highlightpulse · breathe · flash · noneMotion chrome on active hops
statusHighlightboolIdle / active / done color tint
statusColorsobjectOverride idle/active/done/error colors
chrometrue (default) / falseShow ▶⏸↻ + zoom overlay

Control from JS (same chart you mounted):

LightDraw.Diagram.applyFlow(app, chart, { /* same options as flow */ });
LightDraw.Diagram.pauseFlow(app, chart);
LightDraw.Diagram.resumeFlow(app, chart);
LightDraw.Diagram.toggleFlowPause(app, chart);
LightDraw.Diagram.replayFlow(app, chart);
LightDraw.Diagram.stopFlow(chart);

// Manual toolbar if you disabled chrome in JSON:
// LightDraw.Diagram.installToolbar(app, chart);
// LightDraw.Diagram.uninstallToolbar(chart);

Give the host #app { position: relative; } so the toolbar overlays correctly.

5. Org chart: hierarchy from a nested tree

Figure: Org chart rendered from a nested root JSON tree.

No edges array here, just a tree. Same mount helper.

const orgScene = {
  type: 'orgChart',
  props: {
    width: 900,
    height: 480,
    root: {
      name: 'Alex Rivera',
      role: 'CEO',
      children: [
        {
          name: 'Sam Chen',
          role: 'CTO',
          department: 'Engineering',
          children: [
            { name: 'Priya N.', role: 'Platform Lead' },
            { name: 'Jordan K.', role: 'Frontend Lead' },
          ],
        },
        {
          name: 'Morgan Lee',
          role: 'CFO',
          department: 'Finance',
          children: [{ name: 'Riley P.', role: 'Controller' }],
        },
        { name: 'Casey Brooks', role: 'COO', department: 'Ops' },
      ],
    },
  },
};

mountDiagram(orgScene);

// Optional: drag / resize / collapse in the editor
LightDraw.Diagram.installEditor(app, chart, {
  mode: 'arrange',
  allowResize: true,
});

6. Schematic diagram: IEC symbols as JSON

Figure: Battery → switch → resistor → LED → ground from a component list.

const schematicScene = {
  type: 'electricalSchematic',
  props: {
    width: 800,
    height: 360,
    components: [
      { id: 'bat', type: 'battery', x: 80, y: 120, label: 'BAT' },
      { id: 'sw', type: 'spst', x: 220, y: 120, label: 'S1' },
      { id: 'r1', type: 'resistor', x: 360, y: 120, label: 'R1' },
      { id: 'led', type: 'led', x: 500, y: 120, label: 'D1' },
      { id: 'gnd', type: 'ground', x: 500, y: 220, label: 'GND' },
    ],
  },
};

mountDiagram(schematicScene);

Symbol kinds come from the IEC catalog (spst, nmos, opAmp, led, …). Discover them with LightDraw.Diagram.listSchematicSymbols().

7. UML class diagram: structure + animated relations

Figure: Class boxes with inheritance paths animated for a walkthrough.

const umlScene = {
  type: 'classDiagram',
  props: {
    width: 800,
    height: 400,
    data: {
      classes: [
        { id: 'drawable', name: 'Drawable', x: 80, y: 40, methods: ['draw()'], stereotype: 'interface' },
        { id: 'shape', name: 'Shape', x: 360, y: 40, attrs: ['id: string'], methods: ['draw()'] },
        { id: 'rect', name: 'Rect', x: 220, y: 240, attrs: ['w', 'h'], methods: ['draw()'] },
        { id: 'circle', name: 'Circle', x: 520, y: 240, attrs: ['r'], methods: ['draw()'] },
      ],
      relations: [
        { from: 'shape', to: 'drawable', type: 'realization' },
        { from: 'rect', to: 'shape', type: 'inheritance' },
        { from: 'circle', to: 'shape', type: 'inheritance' },
      ],
    },
    flow: {
      enabled: true,
      mode: 'both',
      playback: 'loop',
      paths: [
        ['rect', 'shape', 'drawable'],
        ['circle', 'shape', 'drawable'],
      ],
    },
  },
};

mountDiagram(umlScene);

Load JSON from a file or API

Because the scene is just data, you can keep charts next to configs:

// From a static file
const scene = await fetch('/scenes/onboarding-flow.json').then((r) => r.json());
mountDiagram(scene);

// Or via the app helper when the diagram plugin is registered
app.loadJSON(scene);

// Round-trip after the user edits in the canvas
const saved = LightDraw.Diagram.toJSON(chart);
localStorage.setItem('my-diagram', JSON.stringify(saved));

This is why LightDraw works well for AI agents and config-driven UIs: the agent emits JSON; your page only mounts it.

Quick reference: diagram type values

typeKey propsWire flow?
flowchartdata.nodes, data.edgesYes
stateMachinedata.states, data.transitionsYes
processPipelinestages[]Yes
networkTopologydata.nodes, data.edgesYes
canNetworkdata.ecus, data.busLabelYes (virtual bus hops)
classDiagramdata.classes, data.relationsYes
orgChartroot treeNo
electricalSchematiccomponents[]No
mindMapcenter, branchesNo

Try it yourself

  1. npm install lightdraw or drop the CDN script from the top of this post
  2. Copy any scene JSON above into mountDiagram(scene)
  3. Open the live diagram playground: rakeshrajena.github.io/lightDraw/#diagram
  4. Read the flow guide: docs/diagram-flow.md

If this helped, tell me which diagram type you want next (CAN bus walkthrough, mind maps, or exporting animated scenes for docs). Part 1 introduced the library; this part should be enough to ship a real animated diagram from JSON alone.

LightDraw · zero-dependency · JSON-first graphics for the browser

Sunday, 12 July 2026

LightDraw.js: One Library for Dashboards, Automotive HMIs, Diagrams, and UI — Without the Dependency Bloat

Standard

If you've ever tried to ship a real-time dashboard inside an embedded WebView, or let an AI agent generate a live admin panel, you know the pain: React here, Chart.js there, D3 for one chart, a diagram library for topology, and suddenly your "simple HMI" is a 2 MB bundle that won't even run on Chromium 49 in a car infotainment stack.

LightDraw.js is a different bet. It's a zero-dependency, JSON-first 2D graphics engine for the browser — dashboards, automotive clusters, network diagrams, and form-style UI controls, all from one API. Canvas when you need speed. SVG when you need vectors. HTML when you need accessibility or legacy WebView support.

In this guide, I'll walk through what LightDraw actually is, how to get started in under five minutes, and five real-world use cases with code you can copy, tweak, and run today.

What Problem Does LightDraw Solve?

Building interactive 2D graphics in the browser usually means stacking tools:

Typical stackThe pain
React + Chart.js + D3 + diagram libHuge bundle, framework lock-in, four APIs to learn
Raw Canvas APINo scene graph, manual hit-testing, no animation timeline
Low-code / AI UI generatorsOutput is React/JSX — hard to embed in WebView or validate
Automotive HMI toolsExpensive, closed, or not web-native

LightDraw replaces that stack with one engine:

  • Retained-mode scene graph — add, move, and animate nodes; the renderer redraws efficiently
  • Three renderers — Canvas (performance), SVG (vectors), HTML (accessibility + old WebViews)
  • JSON scenes — load, validate, export; ideal for AI agents and config-driven UIs
  • Domain modules — dashboard widgets, automotive cluster, diagrams, UI components — same API
  • ES5 legacy build — ship to Chromium 49+ infotainment without a runtime transpiler

Bundle sizes (gzip): core ~26 KB, full bundle ~101 KB, dashboard plugin ~32 KB, automotive ~29 KB. You only load what you need.

Who Is This For?

✅ Great fit:

  • IoT / ops dashboards on factory tablets or NOC wall displays
  • Automotive digital cockpits fed by CAN or simulator data
  • AI-generated admin panels where the agent outputs JSON, not JSX
  • Network topology and architecture diagrams in docs or incident boards
  • Embedded control panels on Raspberry Pi kiosks — single HTML file, no npm on device

❌ Not the right tool:

  • Full SPA with routing and SSR — use React/Vue for the shell; embed LightDraw in a panel
  • 3D games — use Three.js or Babylon
  • Google Docs–class document editing
  • Native mobile UI — Swift/Kotlin territory

Step 1: Install LightDraw

Option A — npm (modern apps)

npm install lightdraw
import LightDraw from 'lightdraw';

const app = LightDraw.createApp('#app', {
  width: 800,
  height: 600,
  renderer: 'auto',  // canvas | svg | html
  background: '#1e293b'
});

Option B — CDN (no build step)

Perfect for embedded devices, kiosks, or quick prototypes:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lightdraw@1/dist/lightdraw.min.css">
<div id="app"></div>
<script src="https://cdn.jsdelivr.net/npm/lightdraw@1/dist/lightdraw.min.js"></script>
<script>
  const app = LightDraw.createApp('#app', { width: 800, height: 600, renderer: 'html' });
</script>

Expected output after Step 1: An empty canvas (or HTML surface) with your chosen background color. No errors in the console. You're ready to draw.

Step 2: Draw Your First Scene (JavaScript API)

LightDraw uses a retained-mode scene graph. You create nodes, add them to the stage, and the engine handles redraws, hit-testing, and animation.

const app = LightDraw.createApp('#app', {
  width: 800,
  height: 600,
  renderer: 'canvas',
  background: '#1e293b'
});

const circle = app.circle({
  x: 200,
  y: 200,
  radius: 50,
  fill: '#2563eb',
  draggable: true
});

app.add(circle);

circle.on('click', () => {
  circle.animate({
    scale: 1.5,
    duration: 300,
    easing: 'easeOutBounce'
  });
});

Output:

What you'll see: A blue circle on a dark slate background. Click it — it bounces to 1.5× scale. Drag it — it moves with your pointer. That's the scene graph and interaction layer working without you writing a single requestAnimationFrame loop by hand.

Step 3: Build UIs from JSON (The AI-Friendly Path)

This is where LightDraw diverges from most canvas libraries. Instead of imperative drawing calls, you can describe an entire UI as JSON and load it in one line:

app.loadJSON({
  type: 'group',
  children: [
    { type: 'thermometer', props: { value: 72, x: 24, y: 24 } },
    {
      type: 'lineChart',
      props: {
        data: [18, 22, 31, 28, 35],
        width: 400,
        height: 160,
        x: 24,
        y: 120
      }
    },
    { type: 'gauge', props: { value: 68, size: 110, x: 480, y: 40 } },
    {
      type: 'statusBar',
      props: {
        segments: ['Connected', 'MQTT', '1.2k msg/s'],
        x: 24,
        y: 300
      }
    }
  ]
});

Output:

What you'll see: A mini ops dashboard — thermometer at 72°, a line chart with five data points, a gauge at 68%, and a status bar showing connection info. No React. No Chart.js import. One JSON object.

To update live data:

const gauge = app.stage.findOne('gauge');
gauge.set('value', 85);
app.requestRender();

Step 4: Validate JSON Before Rendering (Critical for AI)

When an LLM generates your UI, you must validate before rendering. LightDraw ships schema docs and a built-in validator:

const scene = await fetch('/api/agent/scene.json').then(r => r.json());

const { valid, errors } = LightDraw.validateSceneJSON(scene);

if (!valid) {
  console.error('Scene validation failed:', errors);
  // Example error output:
  // ["Unknown type 'gague' — did you mean 'gauge'?"]
  return;
}

app.clear();
app.loadJSON(scene);
app.setUiTheme({ preset: 'slate', mode: 'dark' });

Expected output when valid: A themed dark UI renders immediately (see AI admin panel example below).

Expected output when invalid: valid: false and a human-readable errors array — no half-broken UI on screen.

The validation pipeline for AI:

User prompt → LLM + schema docs → scene JSON → validateSceneJSON → loadJSON → live UI

Step 5: Pick the Right Renderer

RendererBest forTrade-off
canvas60 FPS animations, 1000+ nodes, automotive clusterRaster — export as PNG
svgCrisp vectors, zoom-friendly diagramsDOM-heavy at very large node counts
htmlForm controls, accessibility, legacy WebViewsNot ideal for 5000-node particle systems
autoLet LightDraw pick based on contextGood default for prototyping

Benchmark snapshot (canvas renderer, 1000 nodes): render ~0.46 ms per frame — enough headroom for 60 FPS on mid-range hardware.


Real-World Use Cases (With Code and Screenshots)

Use Case 1: IoT / Factory Floor Dashboard

Scenario: A tablet on the factory floor shows live sensor readings from MQTT. No React build pipeline on the device.

const app = LightDraw.createApp('#dashboard', {
  width: 1024,
  height: 600,
  renderer: 'canvas'
});

app.loadJSON({
  type: 'group',
  children: [
    { type: 'thermometer', props: { value: 72, x: 24, y: 24, label: 'Line 3 Temp' } },
    { type: 'gauge', props: { value: 68, size: 120, x: 200, y: 24, label: 'Humidity %' } },
    {
      type: 'lineChart',
      props: {
        data: [18, 22, 31, 28, 35, 42, 38],
        width: 500,
        height: 180,
        x: 24,
        y: 180,
        title: 'Throughput (units/hr)'
      }
    },
    {
      type: 'statusBar',
      props: {
        segments: ['● Connected', 'MQTT', '1.2k msg/s'],
        x: 24,
        y: 400
      }
    }
  ]
});

Output:

What operators see: Gauges and charts update in real time. Status bar shows broker health. Entire UI fits in ~101 KB gzip (full bundle via CDN).

Use Case 2: Automotive Digital Cockpit

Scenario: An instrument cluster in an infotainment WebView, updating at 30–60 FPS from CAN bus or a driving simulator.

const app = LightDraw.createApp('#cluster', {
  width: 800,
  height: 480,
  renderer: 'canvas'
});

app.loadJSON({
  type: 'instrumentCluster',
  props: {
    theme: 'classic',
    width: 800,
    height: 480,
    speed: 0,
    rpm: 800,
    fuel: 100
  }
});

const cluster = app.stage.children[0];

function onDriveTick(canData) {
  LightDraw.applyDriveState(cluster, {
    speed: canData.speed,
    rpm: canData.rpm,
    fuel: canData.fuelPercent
  });
  app.requestRender();
}

Output:

What the driver sees: Speedometer at 95, tach at 3200 RPM, fuel at 68%. Smooth updates because render stays sub-millisecond for typical cluster node counts.

Use Case 3: AI-Generated Admin Panel

Scenario: Your internal copilot receives "Build a server health dashboard with CPU chart and acknowledge button." It outputs JSON, not React.

const app = LightDraw.createApp('#app', {
  width: 960,
  height: 540,
  renderer: 'html'
});

const scene = await agentResponse.json();

if (LightDraw.validateSceneJSON(scene).valid) {
  app.loadJSON(scene);
  app.setUiTheme({ preset: 'slate', mode: 'dark' });
}

Example LLM output (scene JSON):

{
  "type": "group",
  "children": [
    { "type": "card", "props": { "title": "Server health", "x": 16, "y": 16, "width": 420, "height": 200 } },
    { "type": "lineChart", "props": { "data": [22,35,28,48,41,55], "x": 32, "y": 56, "width": 380, "height": 140 } },
    { "type": "button", "props": { "label": "Acknowledge", "variant": "primary", "x": 480, "y": 200 } }
  ]
}

Output:

What the user sees: A card titled "Server health", CPU line chart trending upward, and a primary "Acknowledge" button — rendered in seconds, no codegen pipeline.

Use Case 4: Network / Architecture Diagram

Scenario: An SRE pastes an LLM-generated topology into an incident board during an outage.

app.loadJSON({
  type: 'networkTopology',
  props: {
    data: {
      nodes: [
        { id: 'gw', label: 'Gateway', type: 'router', x: 400, y: 40 },
        { id: 'api', label: 'API', type: 'server', x: 200, y: 160 },
        { id: 'db', label: 'Database', type: 'server', x: 400, y: 160 },
        { id: 'cache', label: 'Redis', type: 'server', x: 600, y: 160 }
      ],
      edges: [
        { from: 'gw', to: 'api' },
        { from: 'gw', to: 'db' },
        { from: 'api', to: 'cache' }
      ]
    }
  }
});

Output:

What you see: Router at top, three servers below, connectors auto-routed between nodes — not hand-drawn SVG paths.

Use Case 5: Embedded Control Panel (CDN, Zero Build)

Scenario: A Raspberry Pi kiosk controls industrial pumps. Firmware team delivers one HTML file. No npm on the device.

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lightdraw@1/dist/lightdraw.min.css">
<div id="app"></div>
<script src="https://cdn.jsdelivr.net/npm/lightdraw@1/dist/lightdraw.min.js"></script>
<script>
  const app = LightDraw.createApp('#app', { width: 480, height: 320, renderer: 'html' });
  app.loadJSON({
    type: 'group',
    children: [
      { type: 'toggle', props: { label: 'Pump A', value: true, x: 20, y: 20 } },
      { type: 'slider', props: { value: 60, width: 200, x: 20, y: 70, label: 'Flow rate %' } },
      { type: 'button', props: { label: 'Emergency stop', variant: 'danger', x: 20, y: 130 } },
      { type: 'statusBar', props: { segments: ['PLC Online', 'Pump A: RUN'], x: 20, y: 200 } }
    ]
  });
</script>

Output:

What the operator sees: Toggle for Pump A (on), slider at 60%, red emergency stop button, status bar showing PLC state.

Console output on interaction:

Control changed: toggle true
Control changed: slider 73
Control changed: button (click event)

How LightDraw Compares

LightDrawReact + Chart.jsD3.jsGoJS / commercial
Runtime deps0React + chart libD3License + lib
Full HMI in one package✅❌ assemble yourself❌ data-viz focusPartial
JSON → live UI✅❌ usually codegen❌Some import/export
Canvas 60 FPS scene✅Via chart canvasManualVaries
ES5 / old WebView✅ legacy build❌ needs build❌Varies
AI agent friendly✅ schema docs❌ outputs JSX❌❌
LicenseMITMITISCOften paid

LightDraw is not a React replacement. It's a graphics engine you embed inside any page or framework.

Try It Yourself

git clone https://github.com/rakeshrajena/lightDraw.git
cd lightDraw
npm install
npm run build
npm run dev:website   # → http://localhost:5173

Wrapping Up

If your project touches embedded web, real-time dashboards, automotive HMIs, or AI-generated UIs, the usual "assemble five libraries" approach costs you bundle size, validation complexity, and WebView compatibility headaches.

LightDraw gives you one scene graph, three renderers, JSON-first loading with validation, and domain modules that cover the widgets you'd otherwise glue together yourself. Start with a CDN script tag and loadJSON — you can have a working dashboard on screen before your npm install finishes elsewhere.

MIT licensed. Built for embedded web, dashboards, and AI-built UIs.