# PathParser

Artifact: [androidx.compose.ui:ui-graphics](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/graphics/vector/PathParser.kt+class:androidx.compose.ui.graphics.vector.PathParser) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Common/All
- Cmn

  ```
  class PathParser
  ```

*** ** * ** ***

## Summary

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathParser#PathParser()()` | Cmn |

| ### Public functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathParser` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathParser#addPathNodes(kotlin.collections.List)(nodes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathNode>)` Adds the list of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathParser#addPathNodes(kotlin.collections.List)` to this parser's internal list of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathNode`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathParser#clear()()` Clears the collection of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathNode` stored in this parser and returned by `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathParser#toNodes()`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathParser` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathParser#parsePathString(kotlin.String)(pathData: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Parses the SVG path string to extract `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathNode` instances for each path instruction (`lineTo`, `moveTo`, etc.). | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-array-list/index.html<https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathNode>` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathParser#pathStringToNodes(kotlin.String,kotlin.collections.ArrayList)(pathData: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, nodes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-array-list/index.html<https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathNode>)` Parses the path string and adds the corresponding `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathNode` instances to the specified `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathParser#pathStringToNodes(kotlin.String,kotlin.collections.ArrayList)` collection. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathNode>` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathParser#toNodes()()` Returns this parser's list of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathNode`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Path` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathParser#toPath(androidx.compose.ui.graphics.Path)(target: https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Path)` Converts this parser's list of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathNode` instances into a `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Path`. | Cmn |

## Public constructors

### PathParser

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
PathParser()
```

## Public functions

### addPathNodes

Cmn

```
fun addPathNodes(nodes: List<PathNode>): PathParser
```

Adds the list of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathParser#addPathNodes(kotlin.collections.List)` to this parser's internal list of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathNode`. The resulting list can be obtained by calling `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathParser#toNodes()`.

### clear

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun clear(): Unit
```

Clears the collection of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathNode` stored in this parser and returned by `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathParser#toNodes()`.

### parsePathString

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun parsePathString(pathData: String): PathParser
```

Parses the SVG path string to extract `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathNode` instances for each path instruction (`lineTo`, `moveTo`, etc.). The `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathNode` are stored in this parser's internal list of nodes which can be queried by calling `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathParser#toNodes()`. Calling this method replaces any existing content in the current nodes list.

### pathStringToNodes

Cmn

```
fun pathStringToNodes(
    pathData: String,
    nodes: ArrayList<PathNode> = ArrayList()
): ArrayList<PathNode>
```

Parses the path string and adds the corresponding `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathNode` instances to the specified `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathParser#pathStringToNodes(kotlin.String,kotlin.collections.ArrayList)` collection. This method returns `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathParser#pathStringToNodes(kotlin.String,kotlin.collections.ArrayList)`.

### toNodes

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun toNodes(): List<PathNode>
```

Returns this parser's list of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathNode`. Note: this function does not return a copy of the list. The caller should make a copy when appropriate.

### toPath

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun toPath(target: Path = Path()): Path
```

Converts this parser's list of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/vector/PathNode` instances into a `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Path`. A new `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Path` is returned every time this method is invoked.