VectorAssetBuilder

class VectorAssetBuilder
kotlin.Any
   ↳ androidx.ui.graphics.vector.VectorAssetBuilder

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 VectorAsset before it is composed through DrawVector The generated VectorAsset is recommended to be memoized across composition calls to avoid doing redundant work

Summary

Public constructors

<init>(name: String = DefaultGroupName, defaultWidth: Px, defaultHeight: Px, viewportWidth: Float, viewportHeight: Float)

Builder used to construct a Vector graphic tree.

Public methods

VectorAssetBuilder
addPath(pathData: List<PathNode>, name: String = DefaultPathName, fill: Brush? = null, fillAlpha: Float = DefaultAlpha, stroke: Brush? = null, strokeAlpha: Float = DefaultAlpha, strokeLineWidth: Float = DefaultStrokeLineWidth, strokeLineCap: StrokeCap = DefaultStrokeLineCap, strokeLineJoin: StrokeJoin = DefaultStrokeLineJoin, strokeLineMiter: Float = DefaultStrokeLineMiter)

Add a path to the VectorAsset graphic.

VectorAsset

Construct a VectorAsset.

Unit

Throws IllegalStateException if the VectorAssetBuilder is already been consumed

VectorAssetBuilder

Pops the topmost VectorGroup from this VectorAssetBuilder.

VectorAssetBuilder
pushGroup(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)

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

Properties

Px

Intrinsic height of the Vector in pixels

Px

Intrinsic width of the Vector in pixels

String

Name of the vector asset

Float

Used to define the height of the viewport space.

Float

Used to define the width of the viewport space.

Public constructors

<init>

VectorAssetBuilder(
    name: String = DefaultGroupName,
    defaultWidth: Px,
    defaultHeight: Px,
    viewportWidth: Float,
    viewportHeight: Float)

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 VectorAsset before it is composed through DrawVector The generated VectorAsset is recommended to be memoized across composition calls to avoid doing redundant work

Public methods

addPath

fun addPath(
    pathData: List<PathNode>,
    name: String = DefaultPathName,
    fill: Brush? = null,
    fillAlpha: Float = DefaultAlpha,
    stroke: Brush? = null,
    strokeAlpha: Float = DefaultAlpha,
    strokeLineWidth: Float = DefaultStrokeLineWidth,
    strokeLineCap: StrokeCap = DefaultStrokeLineCap,
    strokeLineJoin: StrokeJoin = DefaultStrokeLineJoin,
    strokeLineMiter: Float = DefaultStrokeLineMiter
): VectorAssetBuilder

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

Return
This VectorAssetBuilder instance as a convenience for chaining calls

build

fun build(): VectorAsset

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

Return
Thew newly created VectorAsset instance

ensureNotConsumed

fun ensureNotConsumed(): Unit

Throws IllegalStateException if the VectorAssetBuilder is already been consumed

popGroup

fun popGroup(): VectorAssetBuilder

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

Return
This VectorAssetBuilder instance as a convenience for chaining calls

pushGroup

fun pushGroup(
    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
): VectorAssetBuilder

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

Return
This VectorAssetBuilder instance as a convenience for chaining calls

Properties

defaultHeight

val defaultHeight: Px

Intrinsic height of the Vector in pixels

defaultWidth

val defaultWidth: Px

Intrinsic width of the Vector in pixels

name

val name: String

Name of the vector asset

viewportHeight

val viewportHeight: Float

Used to define the height of the viewport space. Viewport is basically the virtual canvas where the paths are drawn on.

viewportWidth

val viewportWidth: Float

Used to define the width of the viewport space. Viewport is basically the virtual canvas where the paths are drawn on.