Icons & Vector

Boolean shapes

A boolean shape is one shape made of others. A crescent is a circle less a circle. A keyhole is a circle joined to a wedge. In Nox the combination stays live: the shapes inside can still be moved and resized, and the result follows. When you need a plain outline, you flatten it.

The four ways to combine a square and a circle
The four ways to combine a square and a circle

The four operations#

OperationThe resultA use
UnionEverything any of the shapes coversA cloud from three circles. A speech bubble from a box and its tail
SubtractThe lowest shape, less what the others coverA crescent. A notch in a panel. A hole in a coin
IntersectOnly what all of the shapes coverA leaf from two circles. A lens
ExcludeWhat an odd number of the shapes coverA ring from two circles. A checker from two squares

Order matters for Subtract: the shape at the bottom of the stack is the one that is kept. To cut the other way, change their order with Arrange › Bring Forward (⌘]) or Send Backward (⌘[).

The menus and the bar say Union. The command field lists the same action as Unite the selection.

Combine shapes#

By hand
  1. Select two or more shapes: rectangles, ellipses, polygons, stars, paths, or other combined shapes.
  2. Press Combine at the right of the tools in the top bar and choose Union, Subtract, Intersect or Exclude.
  3. Or use the keys: ⌥⌘U Union, ⌥⌘S Subtract, ⌥⌘I Intersect, ⌥⌘X Exclude.
  4. The shapes are now inside one combined shape, in their place. Give that shape its fill and stroke.

The same four are in the Arrange menu and in the bar of vector actions.

With an agent

Describe the shape as a sum. The agent makes a node of kind boolean whose children are the shapes, with an operation.

Draw a crescent moon 40 tall in #F5C84B: a circle with a slightly smaller
circle cut from its upper right.

The agent calls create_nodes with:

{
  "nodes": [
    {
      "kind": "boolean",
      "name": "Moon",
      "operation": "subtract",
      "x": 100,
      "y": 0,
      "fills": ["#F5C84B"],
      "children": [
        { "kind": "ellipse", "x": 0, "y": 0, "width": 40, "height": 40 },
        { "kind": "ellipse", "x": 14, "y": -4, "width": 36, "height": 36 }
      ]
    }
  ]
}

The first child is the lowest: the one kept. The children are not drawn themselves. The boolean is painted with its own fill and stroke.

Live booleans#

A combined shape keeps its parts. This is the reason to use one instead of drawing the outline by hand.

  • Edit a part. Double-click the combined shape to reach a shape inside it, then move or resize that shape. The result is drawn again as you go.
  • Change the operation. An agent sets operation on the boolean with update_nodes, and a crescent becomes a lens.
  • Nest them. A combined shape can be a part of another. A gear is a circle joined to its teeth, less a hole.
  • Take it apart. Arrange › Ungroup (⇧⌘G) puts the parts back where they were.

Through the tools, get_nodes on a boolean returns its operation and also its outline: the result as SVG path data, with outline_box, the box around it. An agent reads these to place something against the real edge of the shape.

Flatten#

Flatten replaces a combined shape with one plain path of its outline, painted the same. The parts are gone. Flatten also turns a rectangle or an ellipse into a path, and makes the rounded corners of a path part of its outline.

Flatten when:

  • you want to edit the result point by point;
  • the shape is finished and you want the simplest thing to hand over;
  • another tool will read the file and you want no surprises.
By hand
  1. Select the combined shape.
  2. Press Combine in the top bar and choose Flatten, or press Flatten in the bar of vector actions.

Through the tools it is flatten on update_nodes. The reply lists the new path in flattened_as.

{
  "changes": [
    { "id": "8:8", "flatten": true }
  ]
}
Note

Keep booleans live while you design, and flatten a copy when you hand over. Flatten is one step you can undo, but once the document has moved on, the parts are not coming back.

Outline stroke#

A stroke is a line with a width. Outline Stroke makes that line a filled shape of its own: a path around the stroke's whole body, with its dashes and arrowheads, filled with the stroke's color.

A stroke of 18, the same as an outlined path, and a star with its offset path
A stroke of 18, the same as an outlined path, and a star with its offset path

Use it when a line must take part in a boolean. A magnifying glass is a ring and a handle. Outline the handle's stroke and you can unite it with the ring into one shape. Use it also when a stroke must scale as a shape does, or needs a gradient along its body.

By hand
  1. Select a shape or line with a stroke.
  2. Choose Arrange › Outline Stroke, or press Outline Stroke in the bar of vector actions.

The new path lies just above the original. A shape that had a fill keeps it and loses its stroke.

Through the tools it is outline_stroke on update_nodes. The reply lists the new path in outlined_as.

{
  "changes": [
    { "id": "8:13", "outline_stroke": true }
  ]
}

Outline a stroke last. Once it is a shape, its width is no longer a number you can type.

Offset path#

An offset path is a copy of a closed shape made larger all round by a distance, or smaller if the distance is negative. Where the shape grows, its corners are rounded. The original stays.

Use it for a sticker edge around an icon, a glow plate behind a badge, a focus ring that follows a button's real outline, or a hit area a few pixels larger than what is drawn.

Offset path is done through an agent. It is offset_path on update_nodes, with the distance. It works on a rectangle, an ellipse, a polygon, a star, a closed path, or a boolean.

With an agent
Give the star a sticker edge: an outline 10 outside its shape, white, behind it.

The agent calls update_nodes with:

{
  "changes": [
    { "id": "8:20", "offset_path": 10 }
  ]
}

The reply lists the new path in offset_as. It is made just above the shape and looks as the shape does. The agent then paints it white with update_nodes and sends it behind with move_nodes.

A way of working#

  1. Block the icon in whole shapes: circles, rounded rectangles, a few paths.
  2. Combine them, and leave the booleans live while you adjust.
  3. Outline any stroke that must join a boolean.
  4. Flatten a copy at the end, and check it: see Check and export icons.