Introducing macros

Published May 9, 2026 · 5 min read


Macros are a powerful feature that lets you bundle a bunch of commands into a single command. Instead of typing out the same sequence of operations repeatedly, you can define a macro once and reuse it anywhere.

What is a macro?

Think of a macro as a reusable recipe for geometric constructions. You define it once with parameters, and then you can call it with different values to create variations of the same construction.

For example, here's a macro that creates an equilateral triangle:

[
  {
    "macro": "equilateral-triangle x y side",
    "commands": [
      "e1 = \point x y",
      "x2 = \add x side",
      "e2 = \point x2 y",
      "rsin = \multiply 0.8660254038 side",
      "rcos = \multiply 0.5 side",
      "x3 = \add x rcos",
      "y3 = \add y rsin",
      "e3 = \point x3 y3",
      "\triangle e1 e2 e3"
    ]
  }
]

This macro takes three parameters: x and y for the starting point, and side for the length of the triangle's sides. When you call \equilateral-triangle 0 0 5, it executes all the commands in sequence, creating the three points and the triangle.

You can load this macro by visiting the macros page and pasting this URL:

https://gist.githubusercontent.com/vinsis/113e02bfe5b9ab67c1d3bec9d2642c45/raw/0d7bf08bfef6fbf173de8767e2d9613f3d2b7729/equilateral-triangle.json

Note that loading macros is a premium feature. Once loaded, you can find all your macros on the macros page.

Try it out

The editor comes with several macros pre-loaded and ready to use. You can try running macros directly in the editor—for example, try \cardioid to see a beautiful cardioid curve appear instantly, or \peaucellier-lipkin-linkage to explore a classic mechanical linkage. Other available macros include \fermat-point-of-a-triangle, \gradient-of-an-angle, and \square-root-of-3. Each macro handles the complex calculations for you, letting you focus on the geometry.

Sharing and building on others' work

One of the most powerful aspects of macros is shareability. You can define a macro once and share it with others, allowing them to use your constructions in their own work. This creates a collaborative ecosystem where people can build upon each other's ideas.

If someone has created a useful macro—whether it's a complex geometric pattern or a handy helper function—you can import it and use it as a building block for your own constructions. This composability is at the heart of scientific thinking, and macros make it accessible in a geometric context.

A note on elements

It's worth noting that elements created within macros are not broadcastable. This is because macros always create variables with the same names (like e1, e2, e3 in our example), which would cause conflicts if broadcast. For broadcastable constructions, you'll want to use the standard command approach instead.

Getting started

Ready to create your own macros? Check out the macros page to learn how to define and load your own geometric constructions as macros.

If you're looking for inspiration or want to jump right into using macros, visit the macro store. There you can find macros related to different scenarios and problems, ready for you to use and build upon immediately.