State of Compose 2023 results are in! Click here to learn more

← Back to Compose UI

VectorPainter

Component
in
Compose UI
. Since 0.1.0-dev15

Overview

Code Examples

Create a VectorPainter with the Vector defined by the provided sub-composition

@param defaultWidth Intrinsic width of the Vector in Dp @param defaultHeight Intrinsic height of the Vector in Dp @param viewportWidth Width of the viewport space. The viewport is the virtual canvas where paths are drawn on. This parameter is optional. Not providing it will use the defaultWidth converted to pixels @param viewportHeight Height of the viewport space. The viewport is the virtual canvas where paths are drawn on. This parameter is optional. Not providing it will use the defaultHeight converted to pixels @param name optional identifier used to identify the root of this vector graphic @param children Composable used to define the structure and contents of the vector graphic

Overloads

VectorPainter

@Suppress("ComposableNaming")
@Deprecated(
    "Use rememberVectorPainter instead as the composable implementation already invokes " +
        "remember to persist data across compositions and callers do not need to do so themselves",
    ReplaceWith(
        "rememberVectorPainter(defaultWidth, defaultHeight, viewportWidth, " +
            "viewportHeight, name, children)",
        "androidx.compose.ui.graphics.vector"
    )
)
@Composable
fun VectorPainter(
    defaultWidth: Dp,
    defaultHeight: Dp,
    viewportWidth: Float = Float.NaN,
    viewportHeight: Float = Float.NaN,
    name: String = RootGroupName,
    children: @Composable (viewportWidth: Float, viewportHeight: Float) -> Unit
)

Parameters

NameDescription
[defaultWidth]Intrinsic width of the Vector in Dp
[defaultHeight]Intrinsic height of the Vector in Dp
[viewportWidth]Width of the viewport space. The viewport is the virtual canvas where paths are drawn on. This parameter is optional. Not providing it will use the defaultWidth converted to pixels
[viewportHeight]Height of the viewport space. The viewport is the virtual canvas where paths are drawn on. This parameter is optional. Not providing it will use the defaultHeight converted to pixels
[name]optional identifier used to identify the root of this vector graphic
[children]Composable used to define the structure and contents of the vector graphi

VectorPainter

@Suppress("ComposableNaming")
@Deprecated(
    "Use rememberVectorPainter instead as the composable implementation already invokes " +
        "remember to persist data across compositions and callers do not need to do so themselves",
    ReplaceWith(
        "rememberVectorPainter(asset)",
        "androidx.compose.ui.graphics.vector"
    )
)
@Composable
fun VectorPainter(image: ImageVector)

Parameters

NameDescription
[image]ImageVector used to create a vector graphic sub-compositio