Builder used to construct a Vector graphic tree.
Common
class Builder(
/** Name of the vector asset */
private val name: String = DefaultGroupName,
/** Intrinsic width of the Vector in [Dp] */
private val defaultWidth: Dp,
/** Intrinsic height of the Vector in [Dp] */
private val defaultHeight: Dp,
/**
* Used to define the width of the viewport space. Viewport is basically the virtual canvas
* where the paths are drawn on.
*/
private val viewportWidth: Float,
/**
* Used to define the height of the viewport space. Viewport is basically the virtual canvas
* where the paths are drawn on.
*/
private val viewportHeight: Float,
/** Optional color used to tint the entire vector image */
private val tintColor: Color = Color.Unspecified,
/** Blend mode used to apply the tint color */
private val tintBlendMode: BlendMode = BlendMode.SrcIn,
/**
* Determines if the vector asset should automatically be mirrored for right to left locales
*/
private val autoMirror: Boolean = false,
)
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
Secondary Constructors
// Secondary constructor to maintain API compatibility that defaults autoMirror to false
constructor(
/** Name of the vector asset */
name: String = DefaultGroupName,
/** Intrinsic width of the Vector in [Dp] */
defaultWidth: Dp,
/** Intrinsic height of the Vector in [Dp] */
defaultHeight: Dp,
/**
* Used to define the width of the viewport space. Viewport is basically the virtual
* canvas where the paths are drawn on.
*/
viewportWidth: Float,
/**
* Used to define the height of the viewport space. Viewport is basically the virtual
* canvas where the paths are drawn on.
*/
viewportHeight: Float,
/** Optional color used to tint the entire vector image */
tintColor: Color = Color.Unspecified,
/** Blend mode used to apply the tint color */
tintBlendMode: BlendMode = BlendMode.SrcIn,
) : this(
name,
defaultWidth,
defaultHeight,
viewportWidth,
viewportHeight,
tintColor,
tintBlendMode,
false,
)
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,
): Builder
Create a new group and push it to the front of the stack of ImageVector nodes
Parameters
|
|
| name |
the name of the group |
| rotate |
the rotation of the group in degrees |
| pivotX |
the x coordinate of the pivot point to rotate or scale the group |
| pivotY |
the y coordinate of the pivot point to rotate or scale the group |
| scaleX |
the scale factor in the X-axis to apply to the group |
| scaleY |
the scale factor in the Y-axis to apply to the group |
| translationX |
the translation in virtual pixels to apply along the x-axis |
| translationY |
the translation in virtual pixels to apply along the y-axis |
| clipPathData |
the path information used to clip the content within the group |
Returns
|
|
|
This ImageVector.Builder instance as a convenience for chaining calls |
clearGroup
fun clearGroup(): 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
|
|
|
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,
): Builder
Add a path to the ImageVector graphic. This represents a leaf node in the ImageVector graphics tree structure
Parameters
|
|
| pathData |
path information to render the shape of the path |
| pathFillType |
rule to determine how the interior of the path is to be calculated |
| name |
the name of the path |
| fill |
specifies the Brush used to fill the path |
| fillAlpha |
the alpha to fill the path |
| stroke |
specifies the Brush used to fill the stroke |
| strokeAlpha |
the alpha to stroke the path |
| strokeLineWidth |
the width of the line to stroke the path |
| strokeLineCap |
specifies the linecap for a stroked path |
| strokeLineJoin |
specifies the linejoin for a stroked path |
| strokeLineMiter |
specifies the miter limit for a stroked path |
| trimPathStart |
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. |
| trimPathEnd |
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 |
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
|
|
|
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
|
|
|
The newly created ImageVector instance |