Skip to content

How to make a Shapes program

Calico Niko edited this page Dec 31, 2021 · 11 revisions

Software

You can use any image creating software to make Shapes programs. You can use raster graphics or vector graphics software. Though I recommend using vector graphics software because it's mostly easier.

Raster graphics apps in no particular order:

  • Krita
  • GIMP
  • Paint

Vector graphics apps:

  • Inkscape
  • Blender

Tutorial

In this tutorial, I'm going to show you how to make a calculator in Shapes. I will be using Inkscape but you could use anything you want.

First, make layers for shapes, paths, and the background.

Choose some colors. There are a lot of nice ones on Lospec. I found a nice palette called copper cut

Then, put the colors in the right place. Put shape colors in the left, path colors in the right, and background colors in the bottom.

Make a start shape. Every shapes program must have this.

Make an input shape to get the operation that will be done.

Convert input.

The arrow shaped shape converts characters to their code. The rest subtracts 42 from the character code. The hexagon prints it.

This will convert + to 1, - to 3, * to 0, and / to 5. Which makes it easier to work with later.

Connect the shapes. The start shape must be connected to one shape and the program will just stop if it meets a dead end.

When run, this will just get input and print the character code of the input subtracted by 42.

Make shapes for getting input numbers.

The swap shapes are there to keep the operation code on top of the stack.

Make shapes for branching. This is why I love Shapes. Branching actually shows up as branches.

The branch would move the instruction pointer to the first branch (from the top) if + is inputted, second branch if - is inputted, etc.

Add shapes that do the operations. Put a pop shape, a swap shape, and an operation shape on each branch.

The pop shape is there because number shapes also push the number of holes it has, so we need to get rid of it. The swap shape is for ordering the operand properly so inputting /, 4, and 2, won't give you 0.5

The operation shape is different for each branch so it would actually do different things when different operations are chosen.

Make shapes for outputting the result and ending the program. The rectangles are junctions. They don't do anything besides moving the instruction pointer. Which is good for crossing paths.

Tidy it up and add details. This is entirely optional but I like doing it.

And ta-da! A calculator!

Here it is in action

Things to avoid

These are some things to avoid doing when making Shapes programs. Some times the parser would think some shapes are what they are not

  • Beveled corners. If you want computer to think it is not circular, make the corners sharp.
  • Too small shapes or too small image resolution. This could lead to the parser thinking they are entirely different shapes.