androidx.compose.ui.graphics.vector

Classes

PathBuilder

PathNode

Class representing a singular path command in a vector.

PathParser

VectorApplier

VectorAsset

Vector graphics object that is generated as a result of VectorAssetBuilder It can be composed and rendered by passing it as an argument to VectorPainter

VectorAssetBuilder

Builder used to construct a Vector graphic tree.

VectorGroup

Defines a group of paths or subgroups, plus transformation information.

VectorNode

VectorPainter

Painter implementation that abstracts the drawing of a Vector graphic.

VectorPath

Leaf node of a Vector graphics tree.

VNode

Top-level constants summary

const String

const String

const Float

const Float

const Float

const Float

const Float

const Float

const Float

const Float

const Float

const Float

const Float

const Float

const String

Default identifier for the root group if a Vector graphic

Top-level functions summary

Unit
Group(name: String = DefaultGroupName, rotation: Float = DefaultRotation, pivotX: Float = DefaultPivotX, pivotY: Float = DefaultPivotY, scaleX: Float = DefaultScaleX, scaleY: Float = DefaultScaleY, translationX: Float = DefaultTranslationX, translationY: Float = DefaultTranslationY, clipPathData: List<PathNode> = EmptyPath, children: () -> Unit)

Unit
Path(pathData: List<PathNode>, pathFillType: PathFillType = DefaultFillType, name: String = DefaultPathName, fill: Brush? = null, fillAlpha: Float = 1.0f, stroke: Brush? = null, strokeAlpha: Float = 1.0f, strokeLineWidth: Float = DefaultStrokeLineWidth, strokeLineCap: StrokeCap = DefaultStrokeLineCap, strokeLineJoin: StrokeJoin = DefaultStrokeLineJoin, strokeLineMiter: Float = DefaultStrokeLineMiter, trimPathStart: Float = DefaultTrimPathStart, trimPathEnd: Float = DefaultTrimPathEnd, trimPathOffset: Float = DefaultTrimPathOffset)

List<PathNode>
PathData(block: PathBuilder.() -> Unit)

VectorPainter
VectorPainter(defaultWidth: Dp, defaultHeight: Dp, viewportWidth: Float = Float.NaN, viewportHeight: Float = Float.NaN, name: String = RootGroupName, children: (viewportWidth: Float, viewportHeight: Float) -> Unit)

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

VectorPainter

Create a VectorPainter with the given VectorAsset.

List<PathNode>
addPathNodes(pathStr: String?)

Top-level properties summary

PathFillType

StrokeCap

StrokeJoin

BlendMode

Color

List<PathNode>

Extension functions summary

For VectorAssetBuilder
VectorAssetBuilder
VectorAssetBuilder.group(name: String = DefaultGroupName, rotate: Float = DefaultRotation, pivotX: Float = DefaultPivotX, pivotY: Float = DefaultPivotY, scaleX: Float = DefaultScaleX, scaleY: Float = DefaultScaleY, translationX: Float = DefaultTranslationX, translationY: Float = DefaultTranslationY, clipPathData: List<PathNode> = EmptyPath, block: VectorAssetBuilder.() -> Unit)

DSL extension for adding a VectorGroup to this.

VectorAssetBuilder
VectorAssetBuilder.path(name: String = DefaultPathName, fill: Brush? = null, fillAlpha: Float = 1.0f, stroke: Brush? = null, strokeAlpha: Float = 1.0f, strokeLineWidth: Float = DefaultStrokeLineWidth, strokeLineCap: StrokeCap = DefaultStrokeLineCap, strokeLineJoin: StrokeJoin = DefaultStrokeLineJoin, strokeLineMiter: Float = DefaultStrokeLineMiter, pathFillType: PathFillType = DefaultFillType, pathBuilder: PathBuilder.() -> Unit)

DSL extension for adding a VectorPath to this.

Top-level constants

DefaultGroupName

const val DefaultGroupName: String
Value: ""

DefaultPathName

const val DefaultPathName: String
Value: ""

DefaultPivotX

const val DefaultPivotX: Float
Value: 0.0f

DefaultPivotY

const val DefaultPivotY: Float
Value: 0.0f

DefaultRotation

const val DefaultRotation: Float
Value: 0.0f

DefaultScaleX

const val DefaultScaleX: Float
Value: 1.0f

DefaultScaleY

const val DefaultScaleY: Float
Value: 1.0f

DefaultStrokeLineMiter

const val DefaultStrokeLineMiter: Float
Value: 4.0f

DefaultStrokeLineWidth

const val DefaultStrokeLineWidth: Float
Value: 0.0f

DefaultTranslationX

const val DefaultTranslationX: Float
Value: 0.0f

DefaultTranslationY

const val DefaultTranslationY: Float
Value: 0.0f

DefaultTrimPathEnd

const val DefaultTrimPathEnd: Float
Value: 1.0f

DefaultTrimPathOffset

const val DefaultTrimPathOffset: Float
Value: 0.0f

DefaultTrimPathStart

const val DefaultTrimPathStart: Float
Value: 0.0f

RootGroupName

const val RootGroupName: String

Default identifier for the root group if a Vector graphic

Value: "VectorRootGroup"

Top-level functions

Group

@Composable fun Group(
    name: String = DefaultGroupName,
    rotation: Float = DefaultRotation,
    pivotX: Float = DefaultPivotX,
    pivotY: Float = DefaultPivotY,
    scaleX: Float = DefaultScaleX,
    scaleY: Float = DefaultScaleY,
    translationX: Float = DefaultTranslationX,
    translationY: Float = DefaultTranslationY,
    clipPathData: List<PathNode> = EmptyPath,
    children: () -> Unit
): Unit

Path

@Composable fun Path(
    pathData: List<PathNode>,
    pathFillType: PathFillType = DefaultFillType,
    name: String = DefaultPathName,
    fill: Brush? = null,
    fillAlpha: Float = 1.0f,
    stroke: Brush? = null,
    strokeAlpha: Float = 1.0f,
    strokeLineWidth: Float = DefaultStrokeLineWidth,
    strokeLineCap: StrokeCap = DefaultStrokeLineCap,
    strokeLineJoin: StrokeJoin = DefaultStrokeLineJoin,
    strokeLineMiter: Float = DefaultStrokeLineMiter,
    trimPathStart: Float = DefaultTrimPathStart,
    trimPathEnd: Float = DefaultTrimPathEnd,
    trimPathOffset: Float = DefaultTrimPathOffset
): Unit

PathData

inline fun PathData(block: PathBuilder.() -> Unit): List<PathNode>

VectorPainter

@Composable fun VectorPainter(
    defaultWidth: Dp,
    defaultHeight: Dp,
    viewportWidth: Float = Float.NaN,
    viewportHeight: Float = Float.NaN,
    name: String = RootGroupName,
    children: (viewportWidth: Float, viewportHeight: Float) -> Unit
): VectorPainter

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

Parameters
defaultWidth: Dp Intrinsic width of the Vector in Dp
defaultHeight: Dp Intrinsic height of the Vector in Dp
viewportWidth: Float = Float.NaN 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: Float = Float.NaN 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: String = RootGroupName optional identifier used to identify the root of this vector graphic
children: (viewportWidth: Float, viewportHeight: Float) -> Unit Composable used to define the structure and contents of the vector graphic

VectorPainter

@Composable fun VectorPainter(asset: VectorAsset): VectorPainter

Create a VectorPainter with the given VectorAsset. This will create a sub-composition of the vector hierarchy given the tree structure in VectorAsset

Parameters
asset: VectorAsset VectorAsset used to create a vector graphic sub-composition

addPathNodes

fun addPathNodes(pathStr: String?): List<PathNode>

Top-level properties

DefaultFillType

val DefaultFillType: PathFillType

DefaultStrokeLineCap

val DefaultStrokeLineCap: StrokeCap

DefaultStrokeLineJoin

val DefaultStrokeLineJoin: StrokeJoin

DefaultTintBlendMode

val DefaultTintBlendMode: BlendMode

DefaultTintColor

val DefaultTintColor: Color

EmptyPath

val EmptyPath: List<PathNode>

Extension functions

group

inline fun VectorAssetBuilder.group(
    name: String = DefaultGroupName,
    rotate: Float = DefaultRotation,
    pivotX: Float = DefaultPivotX,
    pivotY: Float = DefaultPivotY,
    scaleX: Float = DefaultScaleX,
    scaleY: Float = DefaultScaleY,
    translationX: Float = DefaultTranslationX,
    translationY: Float = DefaultTranslationY,
    clipPathData: List<PathNode> = EmptyPath,
    block: VectorAssetBuilder.() -> Unit
): VectorAssetBuilder

DSL extension for adding a VectorGroup to this.

See VectorAssetBuilder.pushGroup for the corresponding builder function.

Parameters
name: String = DefaultGroupName the name of the group
rotate: Float = DefaultRotation the rotation of the group in degrees
pivotX: Float = DefaultPivotX the x coordinate of the pivot point to rotate or scale the group
pivotY: Float = DefaultPivotY the y coordinate of the pivot point to rotate or scale the group
scaleX: Float = DefaultScaleX the scale factor in the X-axis to apply to the group
scaleY: Float = DefaultScaleY the scale factor in the Y-axis to apply to the group
translationX: Float = DefaultTranslationX the translation in virtual pixels to apply along the x-axis
translationY: Float = DefaultTranslationY the translation in virtual pixels to apply along the y-axis
clipPathData: List<PathNode> = EmptyPath the path information used to clip the content within the group
block: VectorAssetBuilder.() -> Unit builder lambda to add children to this group

path

inline fun VectorAssetBuilder.path(
    name: String = DefaultPathName,
    fill: Brush? = null,
    fillAlpha: Float = 1.0f,
    stroke: Brush? = null,
    strokeAlpha: Float = 1.0f,
    strokeLineWidth: Float = DefaultStrokeLineWidth,
    strokeLineCap: StrokeCap = DefaultStrokeLineCap,
    strokeLineJoin: StrokeJoin = DefaultStrokeLineJoin,
    strokeLineMiter: Float = DefaultStrokeLineMiter,
    pathFillType: PathFillType = DefaultFillType,
    pathBuilder: PathBuilder.() -> Unit
): VectorAssetBuilder

DSL extension for adding a VectorPath to this.

See VectorAssetBuilder.addPath for the corresponding builder function.

Parameters
name: String = DefaultPathName the name for this path
fill: Brush? = null specifies the Brush used to fill the path
fillAlpha: Float = 1.0f the alpha to fill the path
stroke: Brush? = null specifies the Brush used to fill the stroke
strokeAlpha: Float = 1.0f the alpha to stroke the path
strokeLineWidth: Float = DefaultStrokeLineWidth the width of the line to stroke the path
strokeLineCap: StrokeCap = DefaultStrokeLineCap specifies the linecap for a stroked path
strokeLineJoin: StrokeJoin = DefaultStrokeLineJoin specifies the linejoin for a stroked path
strokeLineMiter: Float = DefaultStrokeLineMiter specifies the miter limit for a stroked path
pathBuilder: PathBuilder.() -> Unit PathBuilder lambda for adding PathNodes to this path.