ImageVector.Builder


Builder used to construct a Vector graphic tree. This is useful for caching the result of expensive operations used to construct a vector graphic for compose. For example, the vector graphic could be serialized and downloaded from a server and represented internally in a ImageVector before it is composed through rememberVectorPainter The generated ImageVector is recommended to be memoized across composition calls to avoid doing redundant work

Summary

Public constructors

Builder(
    name: String,
    defaultWidth: Dp,
    defaultHeight: Dp,
    viewportWidth: Float,
    viewportHeight: Float,
    tintColor: Color,
    tintBlendMode: BlendMode,
    autoMirror: Boolean
)
Cmn

Public functions

ImageVector.Builder
addGroup(
    name: String,
    rotate: Float,
    pivotX: Float,
    pivotY: Float,
    scaleX: Float,
    scaleY: Float,
    translationX: Float,
    translationY: Float,
    clipPathData: List<PathNode>
)

Create a new group and push it to the front of the stack of ImageVector nodes

Cmn
ImageVector.Builder
addPath(
    pathData: List<PathNode>,
    pathFillType: PathFillType,
    name: String,
    fill: Brush?,
    fillAlpha: Float,
    stroke: Brush?,
    strokeAlpha: Float,
    strokeLineWidth: Float,
    strokeLineCap: StrokeCap,
    strokeLineJoin: StrokeJoin,
    strokeLineMiter: Float,
    trimPathStart: Float,
    trimPathEnd: Float,
    trimPathOffset: Float
)

Add a path to the ImageVector graphic.

Cmn
ImageVector

Construct a ImageVector.

Cmn
ImageVector.Builder

Pops the topmost VectorGroup from this ImageVector.Builder.

Cmn

Extension functions

inline ImageVector.Builder
ImageVector.Builder.materialPath(
    fillAlpha: Float,
    strokeAlpha: Float,
    pathFillType: PathFillType,
    pathBuilder: PathBuilder.() -> Unit
)

Adds a vector path to this icon with Material defaults.

Cmn
inline ImageVector.Builder
ImageVector.Builder.group(
    name: String,
    rotate: Float,
    pivotX: Float,
    pivotY: Float,
    scaleX: Float,
    scaleY: Float,
    translationX: Float,
    translationY: Float,
    clipPathData: List<PathNode>,
    block: ImageVector.Builder.() -> Unit
)

DSL extension for adding a VectorGroup to this.

Cmn
inline ImageVector.Builder
ImageVector.Builder.path(
    name: String,
    fill: Brush?,
    fillAlpha: Float,
    stroke: Brush?,
    strokeAlpha: Float,
    strokeLineWidth: Float,
    strokeLineCap: StrokeCap,
    strokeLineJoin: StrokeJoin,
    strokeLineMiter: Float,
    pathFillType: PathFillType,
    pathBuilder: PathBuilder.() -> Unit
)

DSL extension for adding a VectorPath to this.

Cmn

Public constructors

Builder

Builder(
    name: String = DefaultGroupName,
    defaultWidth: Dp,
    defaultHeight: Dp,
    viewportWidth: Float,
    viewportHeight: Float,
    tintColor: Color = Color.Unspecified,
    tintBlendMode: BlendMode = BlendMode.SrcIn,
    autoMirror: Boolean = false
)

Public functions

addGroup

fun addGroup(
    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
): ImageVector.Builder

Create a new group and push it to the front of the stack of ImageVector nodes

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

Returns
ImageVector.Builder

This ImageVector.Builder instance as a convenience for chaining calls

addPath

fun addPath(
    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
): ImageVector.Builder

Add a path to the ImageVector graphic. This represents a leaf node in the ImageVector graphics tree structure

Parameters
pathData: List<PathNode>

path information to render the shape of the path

pathFillType: PathFillType = DefaultFillType

rule to determine how the interior of the path is to be calculated

name: String = DefaultPathName

the name of the 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

trimPathStart: Float = DefaultTrimPathStart

specifies the fraction of the path to trim from the start in the range from 0 to 1. Values outside the range will wrap around the length of the path. Default is 0.

trimPathStart: Float = DefaultTrimPathStart

specifies the fraction of the path to trim from the end in the range from 0 to 1. Values outside the range will wrap around the length of the path. Default is 1.

trimPathOffset: Float = DefaultTrimPathOffset

specifies the fraction to shift the path trim region in the range from 0 to 1. Values outside the range will wrap around the length of the path. Default is 0.

Returns
ImageVector.Builder

This ImageVector.Builder instance as a convenience for chaining calls

build

fun build(): ImageVector

Construct a ImageVector. This concludes the creation process of a ImageVector graphic This builder cannot be re-used to create additional ImageVector instances

Returns
ImageVector

The newly created ImageVector instance

clearGroup

fun clearGroup(): ImageVector.Builder

Pops the topmost VectorGroup from this ImageVector.Builder. This is used to indicate that no additional ImageVector nodes will be added to the current VectorGroup

Returns
ImageVector.Builder

This ImageVector.Builder instance as a convenience for chaining calls

Extension functions

inline fun ImageVector.Builder.materialPath(
    fillAlpha: Float = 1.0f,
    strokeAlpha: Float = 1.0f,
    pathFillType: PathFillType = DefaultFillType,
    pathBuilder: PathBuilder.() -> Unit
): ImageVector.Builder

Adds a vector path to this icon with Material defaults.

Parameters
fillAlpha: Float = 1.0f

fill alpha for this path

strokeAlpha: Float = 1.0f

stroke alpha for this path

pathFillType: PathFillType = DefaultFillType

PathFillType for this path

pathBuilder: PathBuilder.() -> Unit

builder lambda to add commands to this path

group

inline fun ImageVector.Builder.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: ImageVector.Builder.() -> Unit
): ImageVector.Builder

DSL extension for adding a VectorGroup to this.

See ImageVector.Builder.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: ImageVector.Builder.() -> Unit

builder lambda to add children to this group

path

inline fun ImageVector.Builder.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
): ImageVector.Builder

DSL extension for adding a VectorPath to this.

See ImageVector.Builder.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.