Subtract
Until now, we have two rectangles which are generated within the same file but to build a frame, we have to combine them.
Grouping statements
The first step is to bundle the rectangles into a group with curly brackets {}.
So let's put some around the frame's rectangles.
thickness = 1.2mm;
width = 31.8mm;
height = 15.8mm;
{
std::geo2d::Rect(width, height);
std::geo2d::Rect(width = width - 2 * thickness, height = height - 2 * thickness);
}
As you can see, there is no ; after the braces.
The visual output did not change by using the group braces. However, now we can combine both rectangles by using an operation.
Manipulate geometry with Operations
In µcad, the operation to subtract a geometry from one another is called subtract.
In our case, we want to subtract the outer part by the inner part in our frame group:
thickness = 1.2mm;
width = 31.8mm;
height = 15.8mm;
{
std::geo2d::Rect(width, height);
std::geo2d::Rect(width = width - 2 * thickness, height = height - 2 * thickness);
}.std::ops::subtract(); // Apply the operation.
Now the semicolon is back, because we added the operation.