transformParts

open override fun transformParts(transformation: (Shape2d) -> Shape2d): Shape2d

Some operations, such as transform require the paths data. This isn't available for Union2d, Difference2d and Intersection2d, so it may seem impossible to transform a union, difference or intersection. We can though. If we pull the component parts out of the union/difference/intersection, apply the transformation to those shapes, and then recombine the results, everything works out fine.

It isn't important that you understand how this works, but if you want to ... Imagine you have a mathematical equation such as (2x + y), and you wish to multiply it by three. Alas, for some reason, we can't multiply the result of an addition, but we still want to say 3(2x + y). The solution is to multiple each part by 3, and then perform the addition last : 33x + 3y = 9x +3y.

In our analogy, addition is like a Union2d, and multiplication is like transform, or any other transformation that requires the paths data.