FREELessons: 19Length: 2.4 hours

Next lesson playing in 5 seconds

  • Overview
  • Transcript

2.7 How to Use Boolean Operators in Sketch

If you remember the earlier lesson about vectors and shapes, you’ll have seen that you can create custom shapes by using the vector tool. Sometimes, however, you can achieve much more precise results and spend less time by using boolean operations. These operations allow us to generate complex shapes by combining existing ones. Watch the video to learn how to use boolean operators in Sketch.

Related Links

2.7 How to Use Boolean Operators in Sketch

If you remember in lesson six about vectors and shapes, you saw that you can create custom shapes or hand-drawn shapes by using the vector tool. But the thing is you can achieve much more precise and fast results by using something called Boolean operations. These are some layer operations that basically combine multiple shapes into a more complex one. So let's quickly check that out. The boolean operations, there are four of them, can be found right here. They're called union, subtract, intersect, and difference. And I'm just gonna jump straight into it and show you what they do. So I'm gonna draw two shapes, two rectangles. I'm gonna use some simple fill colors, and then I'm gonna bring these two shapes together. Like this, okay? So now we have two shapes that are basically intersecting they're overlapping each other. Now to access Boolean operations, you must have two or more shapes selected. So let's start with the union. Union will basically take the shapes you selected and merge them into a single shape. Notice in the layers panel, we now have a combined shape but we also have access to the individual shapes. The fill color was borrowed from one of the shapes, and let's do an undo, right? It was borrowed from the bottom shape. So if I were to bring this up, you will see that once we do the union, now it will be green. So the color of the combined shape will be borrowed from the most bottom shape. So now we have a single shape that we can drag around. We can change its properties. It's just like any other shape, but at the same time we have access to its founding shapes. So we can move these around, we can change their size. We can add a corner radius to this one if we want. But in the end it's the same shape. So this is what the union is doing. It's combining multiple shapes into a single one, it's merging them. Now, let's come back here. And I'm gonna select these two again, but this time I'm going choose subtract. So, subtract will basically cut away one shape from the other. In this case, it cuts away the top shape from the bottom shape, all right? So subtract, and now we're just left with this shape. That has this cut-away corresponding to the shape that we just had here. And again, we have access to the underlying shapes, so we can move this around at any point. And the resulting shape will be updated automatically. That's pretty cool. If I were to change the order of the shapes, so if I were to put this one on the bottom you'll notice that once we do subtract we have a different shape, right? So it always subtracts the top shape from the bottom one. Now intersect, Will create a shape that the result of the intersection between these two shapes. So, if I go back here, notice what part of these two shapes overlaps. It's this one right here. Well, this will be the result of intersect. And then finally difference will create a shape that preserves the main shapes without the part that is intersecting, and it does this bit. This is now my shape. That's pretty cool, right? It's very straightforward. Now you'll get slightly different results when you have more than two shapes. Like for example, let's do this with three circles. All right, so I'm gonna do this I'm gonna do this, okay? Now if I combine these union, I get a nice Mickey Mouse figure, and actually have four of these. I accidentally duplicated that one. So if I do subtract. Yeah, it only works with certain shapes, right? You'll see that these chop shapes are subtracted from the one at the bottom. And if I work to make this larger. You will see that the result now updates. These two shapes are now subtracted from the bottom one. We can also do intersect, and it's gonna be, well, nothing. Because these three shapes don't intersect each other. If I were to do this, then the intersect will get us this result here. But in this configuration it doesn't work because this intersects with this, and this intersects with this. But these two don't intersect each other. So the rules are slightly different here. And finally, difference, just gonna remove the overlapping parts. All right, and that's a quick look at how to use Boolean operations. If you want to learn more about this, then check out the lesson notes where I've included a link to a free tutorial. On how to use these Boolean operations in Sketch to design an icon. Now, a huge part of working with layers in sketch is the resizing and constraining capabilities. And we'll learn more about those in the next lesson. See you there.

Back to the top