Boolean

Boolean #

NijiGPen provides following 2D boolean operations on the closed paths of two or more strokes:

  • Union (Sum, OR)
  • Difference (Subtract, NOT)
  • Intersection (AND)
  • Exclusive (XOR)

These functions are realized by calling the Clipper library. Please check the link for more details.

Edit Mode Operators #

There are multiple buttons in the Edit mode panel, which are shortcuts of the same operator. This operator takes the paths of selected strokes as the input, and generate new strokes which are results of the boolean operation. You can choose to keep the input strokes or delete them.

It is possible, but not recommended to select strokes from multiple layers, since it is not intuitive to judge in which layer the output strokes should be generated and how they should be arranged.

Stroke Attributes #

The output strokes inherit the point attributes of the input strokes, including radius, strength, depth and vertex color. However, if the input strokes have different stroke attributes, e.g., the fill color and the assigned material, the output strokes can only choose one of them to inherit. There is an option to specify the criterion for such inheritance.

Cases of 3 or More Shapes #

The expected result of two input strokes is straightforward. However, with three or more input strokes, there may be multiple ways to finish the operation.

The figure above is an example of performing the Difference operation on 3 shapes. The numbers of Subjects and Clips need to be specified in the options.

Also, the sequence of stroke selection matters. The first selected strokes are regarded as Subjects, and the last selected strokes are Clips.

Draw Mode Operators #

The boolean operators are also available in the Draw mode. In this mode, it will take the lastest drawn stroke as the Clip, and perform the operation on each stroke overlapping with it in the same layer.

There is an option to use the line radius as the Clip path. This resembles the experience of the erasor tool in raster painting software, as shown in the figure above.