# PathUtils

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/graphics/PathUtils.java+class:androidx.core.graphics.PathUtils) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***


```
public final class PathUtils
```

<br />

*** ** * ** ***

A set of path-related utility methods.

## Summary

| ### Public methods |
|---|---|
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/Collection.html<https://developer.android.com/reference/androidx/core/graphics/PathSegment>` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/androidx/core/graphics/PathUtils#flatten(android.graphics.Path)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Path.html path)` Flattens (or approximate) a `https://developer.android.com/reference/android/graphics/Path.html` with a series of line segments using a 0.5 pixel error. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/Collection.html<https://developer.android.com/reference/androidx/core/graphics/PathSegment>` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/androidx/core/graphics/PathUtils#flatten(android.graphics.Path,float)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Path.html path, @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0) float error)` Flattens (or approximate) a `https://developer.android.com/reference/android/graphics/Path.html` with a series of line segments. |

## Public methods

### flatten

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
@RequiresApi(value = 26)
public static @NonNull Collection<PathSegment> flatten(@NonNull Path path)
```

Flattens (or approximate) a `https://developer.android.com/reference/android/graphics/Path.html` with a series of line segments using a 0.5 pixel error. *Note:* This method requires API 26 or newer.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Path.html path` | path to flatten. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/graphics/PathUtils#flatten(android.graphics.Path,float)` |   |

### flatten

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
@RequiresApi(value = 26)
public static @NonNull Collection<PathSegment> flatten(@NonNull Path path, @FloatRange(from = 0) float error)
```

Flattens (or approximate) a `https://developer.android.com/reference/android/graphics/Path.html` with a series of line segments. *Note:* This method requires API 26 or newer.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Path.html path` | path to flatten. |
| `@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0) float error` | The acceptable error for a line on the Path. Typically this would be 0.5 so that the error is less than half a pixel. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/graphics/Path.html#approximate(float)` |   |