Function

divide

Divides this path into a list of paths.

divide

Source set: Common
public fun Path.divide(contours: MutableList<Path> = mutableListOf()): MutableList<Path>

Divides this path into a list of paths. Each contour inside this path is returned as a separate Path. For instance the following code snippet creates two rectangular contours:

val p = Path()
p.addRect(...)
p.addRect(...)

val contours = p.divide()

The list returned by calling p.divide() will contain two Path instances, each representing one of the two rectangles.

Empty contours (contours with no lines/curves) are omitted from the resulting list.

Parameters

contours An optional mutable list of Path that will hold the result of the division.

Return

A list of Path representing all the contours in this path. The returned list is either a newly allocated list if the contours parameter was left unspecified, or the contours parameter.

Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: