Sketch tip: How boolean operations work

by Christian Krammer from sketchtips.info

Before I go to the meat and potatoes I want to tell you a bit about boolean operations in general. They let you combine shapes in different ways, which leads to countless possibilities for entirely new forms.

There are four types of boolean operations in Sketch. Let’s see them in action in the following animated GIF:

  1. Union: Merges two shapes into one.
  2. Subtract: Removes one shape from another.
  3. Intersect: Just shows the part where the shapes overlap.
  4. Difference: The area where the shapes don’t meet is retained.

The ones you will need the most are Union and Subtract, while the other two are not that common. Especially Subtract can lead to some awkward situations, but if you mind a few simple points there shouldn’t be a problem at all.

Keep in mind

  1. Order matters, especially for Subtract. Shapes above are always removed from the ones below.
  2. The biggest shape in the combination should always be at the bottom, with the shapes getting smaller the higher you go up in the hierarchy.
  3. Shapes that don’t interact directly and just sit on top of others should be set to “None”.

The good thing about boolean operations in Sketch is that they can always be reversed, reordered and reapplied in different ways. Either by moving the shape out of the boolean group and executing another boolean operation, or by clicking on the little icon next to the related layer and changing the type of boolean operation. If you want to remove all at once go to “Layer > Paths > Split” in the menu bar.

An example

Let me give you an example with the following truck shape, which consists of eight basic shapes:

  • The wheel cases (3) and the driver’s cabin (6) are subtracted from the body (1).
  • The load bed (2) and the bumper (5) are set to “Union”, so that they are combined with the body (1).
  • The wheels (4) are set to “None”, because they don’t need to interact at all. “Union” would also be an option, but “None” is saver.

If you reduce things to their basic elements it becomes quite easy and almost any form can be created this way.

When to flatten

However if shapes get too complex try to break the process down into different steps, flatten the combined shape in between and then continue with other boolean operations. Just remember to keep a copy of the form for later reference.

Flattening a shape can also be an option if you want to export a shape as an SVG, where it’s always a good idea to reduce forms as much as possible. To do that just go to “Layer > Paths > Flatten” in the menu bar.

Thanks to Peter Nowell for his helpful article.

Do you want to learn more? Take my Sketch course on Skillshare!

Follow sketchtips.info on Twitter