Welcome back again to our introduction to code generation. Generating code from some non-code description is a big topic, so we’re focusing our attention for now on the specific problem of generating JavaScript code from an SVG drawing. In the last part, we managed to generate code that could not only draw rectangles, but also render them at different sizes and aspect ratios.

Just look at those black rectangles go

In this last part of the series, we’re going to make our code generator smart enough to handle colors. We’re working from the repository at https://github.com/Cycling74/codegen-eng-blog. …


Hi and welcome back to an introduction to code generation. If you haven’t read the first part of this series, we’re trying to generate JavaScript code that will recreate an SVG drawing. In the last part, we managed to write a parser/generator that could understand any drawing, so long as it was made up entirely of black rectangles.

This, I think you’ll agree, is art

In this part of the series, we’ll add generated code to scale and stretch our image as we resize our Max object. We’re working from the repository at https://github.com/Cycling74/codegen-eng-blog. …


This post is all about code generation. When we’re done, we’ll have a working command line tool that will automatically generate JavaScript code from an SVG file. In later parts, we’ll add complexity and sophistication to that tool.

Custom Drawing in Max

In Max (our visual programming language for multimedia manipulation), you build programs by connecting together objects with things called patch cords. A patch that adds two numbers together could look like this:

Under the hood, so to speak, this “+” object is just a bit of C code that calls an “add” function. Most Max objects have pre-defined behavior. …

Cycling '74 Engineering

We’re the engineers behind Max, the visual programming environment for sound and video. Follow for more programming stories, side projects and rabbit holes.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store