pathbool

package
v0.26.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2026 License: BSD-3-Clause, MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package pathbool computes the geometric boolean operations of paths: the union, the difference, the intersection and the exclusion of the areas that they fill. lottie uses it for the result of a merge path that a stroke or a trim path draws (D94). It ports no upstream code. Neither kurbo nor ThorVG has such operations.

Combine flattens the curves of each operand with kurbo.Flatten, and snaps the points to a grid of integers, so that each test of the geometry is exact. It splits the edges where they cross or touch, and merges the edges that lie on each other. For each edge, it counts the winding number of each operand on both sides, with a vertical ray. An edge is part of the result when the operation gives the inside on one side and the outside on the other. Combine then links these edges into closed contours, with the inside on their left.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Combine

func Combine(op Op, operands [][]kurbo.PathEl, tolerance float64, dst []kurbo.PathEl) []kurbo.PathEl

Combine returns the outline of the area that the operands give when they combine with op, in their order, and appends it to dst. Each operand fills with the nonzero rule, and a subpath that is not closed closes. Combine flattens the curves with the tolerance tolerance, so the result holds only lines. Each contour of the result is closed and has the inside on its left in a coordinate system where y goes up, so a hole turns the other way. The contours do not cross.

Types

type Op

type Op uint8

Op is a boolean operation of Combine.

const (
	// Union is the area that any operand covers.
	Union Op = iota
	// Difference is the area of the first operand without the areas of the
	// operands after it.
	Difference
	// Intersection is the area that all operands cover.
	Intersection
	// Xor is the area that an odd number of operands covers.
	Xor
)

The values of Op.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL