androidx.compose.ui.graphics.vector
Interfaces
VectorConfig |
Holds a set of values that overwrite the original property values of an |
Cmn
|
Classes
ImageVector |
Vector graphics object that is generated as a result of |
Cmn
|
ImageVector.Builder |
Builder used to construct a Vector graphic tree. |
Cmn
|
PathBuilder |
|
Cmn
|
PathNode |
Represents a single command in a vector graphics path. |
Cmn
|
PathNode.ArcTo |
Draws an elliptical arc from the current point to a new point using absolute coordinates. |
Cmn
|
PathNode.CurveTo |
Draws a cubic Bézier curve from the current point to a new point using absolute coordinates. |
Cmn
|
PathNode.HorizontalTo |
Draws a horizontal line from the current point to the specified absolute x-coordinate. |
Cmn
|
PathNode.LineTo |
Draws a line from the current point to the specified absolute (x,y) coordinate. |
Cmn
|
PathNode.MoveTo |
Starts a new subpath at the given absolute (x,y) coordinate. |
Cmn
|
PathNode.QuadTo |
Draws a quadratic Bézier curve from the current point to a new point using absolute coordinates. |
Cmn
|
PathNode.ReflectiveCurveTo |
Draws a smooth cubic Bézier curve using absolute coordinates. |
Cmn
|
PathNode.ReflectiveQuadTo |
Draws a smooth quadratic Bézier curve using absolute coordinates. |
Cmn
|
PathNode.RelativeArcTo |
Draws an elliptical arc from the current point to a new point using relative coordinates. |
Cmn
|
PathNode.RelativeCurveTo |
Draws a cubic Bézier curve from the current point to a new point using relative coordinates. |
Cmn
|
PathNode.RelativeHorizontalTo |
Draws a horizontal line from the current point, offset by a relative distance |
Cmn
|
PathNode.RelativeLineTo |
Draws a line from the current point to a new point, defined by a relative offset. |
Cmn
|
PathNode.RelativeMoveTo |
Starts a new subpath at a point defined by a relative offset from the current point. |
Cmn
|
PathNode.RelativeQuadTo |
Draws a quadratic Bézier curve from the current point to a new point using relative coordinates. |
Cmn
|
PathNode.RelativeReflectiveCurveTo |
Draws a smooth cubic Bézier curve using relative coordinates. |
Cmn
|
PathNode.RelativeReflectiveQuadTo |
Draws a smooth quadratic Bézier curve using relative coordinates. |
Cmn
|
PathNode.RelativeVerticalTo |
Draws a vertical line from the current point, offset by a relative distance |
Cmn
|
PathNode.VerticalTo |
Draws a vertical line from the current point to the specified absolute y-coordinate. |
Cmn
|
PathParser |
Cmn
|
|
VNode |
Cmn
|
|
VectorApplier |
Cmn
|
|
VectorGroup |
Defines a group of paths or subgroups, plus transformation information. |
Cmn
|
VectorNode |
Cmn
|
|
VectorPainter |
|
Cmn
|
VectorPath |
Leaf node of a Vector graphics tree. |
Cmn
|
VectorProperty |
Represents one of the properties for PathComponent or GroupComponent that can be overwritten when it is composed and drawn with |
Cmn
|
Objects
ImageVector.Companion |
Cmn
|
|
PathNode.Close |
Closes the current subpath by drawing a straight line from the current point to the initial point of the subpath. |
Cmn
|
VectorProperty.Fill |
Cmn
|
|
VectorProperty.FillAlpha |
Cmn
|
|
VectorProperty.PathData |
Cmn
|
|
VectorProperty.PivotX |
Cmn
|
|
VectorProperty.PivotY |
Cmn
|
|
VectorProperty.Rotation |
Cmn
|
|
VectorProperty.ScaleX |
Cmn
|
|
VectorProperty.ScaleY |
Cmn
|
|
VectorProperty.Stroke |
Cmn
|
|
VectorProperty.StrokeAlpha |
Cmn
|
|
VectorProperty.StrokeLineWidth |
Cmn
|
|
VectorProperty.TranslateX |
Cmn
|
|
VectorProperty.TranslateY |
Cmn
|
|
VectorProperty.TrimPathEnd |
Cmn
|
|
VectorProperty.TrimPathOffset |
Cmn
|
|
VectorProperty.TrimPathStart |
Cmn
|
Annotations
VectorComposable |
An annotation that can be used to mark an composable function as being expected to be use in a composable function that is also marked or inferred to be marked as a |
Cmn
|
Constants summary
const String |
Cmn
|
|
const String |
Cmn
|
|
const Float |
DefaultPivotX = 0.0f |
Cmn
|
const Float |
DefaultPivotY = 0.0f |
Cmn
|
const Float |
DefaultRotation = 0.0f |
Cmn
|
const Float |
DefaultScaleX = 1.0f |
Cmn
|
const Float |
DefaultScaleY = 1.0f |
Cmn
|
const Float |
DefaultStrokeLineMiter = 4.0f |
Cmn
|
const Float |
DefaultStrokeLineWidth = 0.0f |
Cmn
|
const Float |
DefaultTranslationX = 0.0f |
Cmn
|
const Float |
DefaultTranslationY = 0.0f |
Cmn
|
const Float |
DefaultTrimPathEnd = 1.0f |
Cmn
|
const Float |
DefaultTrimPathOffset = 0.0f |
Cmn
|
const Float |
DefaultTrimPathStart = 0.0f |
Cmn
|
const String |
Default identifier for the root group if a Vector graphic |
Cmn
|
Top-level functions summary
Unit |
@ComposableDefines a group of |
Cmn
|
Unit |
@ComposableDefines a path inside a |
Cmn
|
inline List<PathNode> |
PathData(block: PathBuilder.() -> Unit) |
Cmn
|
Unit |
@ComposableRecursively creates the vector graphic composition by traversing the tree structure. |
Cmn
|
List<PathNode> |
addPathNodes(pathStr: String?) |
Cmn
|
VectorPainter |
Create a |
Cmn
|
VectorPainter |
@ComposableThis function is deprecated. Replace rememberVectorPainter graphicsLayer that consumes the auto mirror flag |
Cmn
|
VectorPainter |
@ComposableCreate a |
Cmn
|
Extension functions summary
inline ImageVector.Builder |
ImageVector.Builder.group(DSL extension for adding a |
Cmn
|
inline ImageVector.Builder |
ImageVector.Builder.path(DSL extension for adding a |
Cmn
|
Path |
Converts this list of |
Cmn
|
Top-level properties summary
PathFillType |
Cmn
|
|
StrokeCap |
Cmn
|
|
StrokeJoin |
Cmn
|
|
BlendMode |
Cmn
|
|
Color |
Cmn
|
|
List<PathNode> |
Cmn
|
Constants
RootGroupName
const val RootGroupName: String
Default identifier for the root group if a Vector graphic
Top-level functions
Group
@Composable
@VectorComposable
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,
content: @Composable @VectorComposable () -> Unit
): Unit
Defines a group of Paths and other Groups inside a VectorPainter. This is not a regular UI composable, it can only be called inside composables called from the content parameter to rememberVectorPainter.
| Parameters | |
|---|---|
name: String = DefaultGroupName |
Optional name of the group used when describing the vector as a string. |
rotation: Float = DefaultRotation |
The rotation of the group around the Z axis, in degrees. |
pivotX: Float = DefaultPivotX |
The horizontal pivot point used for rotation, in pixels. |
pivotY: Float = DefaultPivotY |
The vertical pivot point used for rotation, in pixels. |
scaleX: Float = DefaultScaleX |
Factor to scale the group by horizontally. |
scaleY: Float = DefaultScaleY |
Factor to scale the group by vertically. |
translationX: Float = DefaultTranslationX |
Horizontal offset of the group, in pixels. |
translationY: Float = DefaultTranslationY |
Vertical offset of the group, in pixels. |
clipPathData: List<PathNode> = EmptyPath |
A list of |
content: @Composable @VectorComposable () -> Unit |
A composable that defines the contents of the group. |
Path
@Composable
@VectorComposable
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
Defines a path inside a VectorPainter. This is not a regular UI composable, it can only be called inside composables called from the content parameter to rememberVectorPainter.
| Parameters | |
|---|---|
pathData: List<PathNode> |
List of |
pathFillType: PathFillType = DefaultFillType |
The |
name: String = DefaultPathName |
Optional name of the path used when describing the vector as a string. |
fill: Brush? = null |
The |
fillAlpha: Float = 1.0f |
The alpha value to use for |
stroke: Brush? = null |
The |
strokeAlpha: Float = 1.0f |
The alpha value to use for |
strokeLineWidth: Float = DefaultStrokeLineWidth |
The width of the |
strokeLineCap: StrokeCap = DefaultStrokeLineCap |
The |
strokeLineJoin: StrokeJoin = DefaultStrokeLineJoin |
The |
strokeLineMiter: Float = DefaultStrokeLineMiter |
The stroke miter value. See |
trimPathStart: Float = DefaultTrimPathStart |
The fraction of the path that specifies the start of the clipped region of the path. See |
trimPathEnd: Float = DefaultTrimPathEnd |
The fraction of the path that specifies the end of the clipped region of the path. See |
trimPathOffset: Float = DefaultTrimPathOffset |
The amount to offset both |
RenderVectorGroup
@Composable
fun RenderVectorGroup(
group: VectorGroup,
configs: Map<String, VectorConfig> = emptyMap()
): Unit
Recursively creates the vector graphic composition by traversing the tree structure.
| Parameters | |
|---|---|
group: VectorGroup |
The vector group to render. |
configs: Map<String, VectorConfig> = emptyMap() |
An optional map of |
rememberVectorPainter
@Composable
fun rememberVectorPainter(image: ImageVector): VectorPainter
Create a VectorPainter with the given ImageVector. This will create a sub-composition of the vector hierarchy given the tree structure in ImageVector
| Parameters | |
|---|---|
image: ImageVector |
ImageVector used to create a vector graphic sub-composition |
rememberVectorPainter
@Composable
@ComposableOpenTarget(index = -1)
funrememberVectorPainter(
defaultWidth: Dp,
defaultHeight: Dp,
viewportWidth: Float = Float.NaN,
viewportHeight: Float = Float.NaN,
name: String = RootGroupName,
tintColor: Color = Color.Unspecified,
tintBlendMode: BlendMode = BlendMode.SrcIn,
content: @Composable @VectorComposable (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 |
defaultHeight: Dp |
Intrinsic height of the Vector in |
viewportWidth: Float |
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 |
viewportHeight: Float |
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 |
name: String = RootGroupName |
optional identifier used to identify the root of this vector graphic |
tintColor: Color = Color.Unspecified |
optional color used to tint the root group of this vector graphic |
tintBlendMode: BlendMode = BlendMode.SrcIn |
BlendMode used in combination with |
content: @Composable @VectorComposable (viewportWidth: Float, viewportHeight: Float) -> Unit |
Composable used to define the structure and contents of the vector graphic |
rememberVectorPainter
@Composable
@ComposableOpenTarget(index = -1)
fun rememberVectorPainter(
defaultWidth: Dp,
defaultHeight: Dp,
viewportWidth: Float = Float.NaN,
viewportHeight: Float = Float.NaN,
name: String = RootGroupName,
tintColor: Color = Color.Unspecified,
tintBlendMode: BlendMode = BlendMode.SrcIn,
autoMirror: Boolean = false,
content: @Composable @VectorComposable (viewportWidth: Float, viewportHeight: Float) -> Unit
): VectorPainter
Create a VectorPainter with the Vector defined by the provided sub-composition.
Inside content use the Group and Path composables to define the vector.
| Parameters | |
|---|---|
defaultWidth: Dp |
Intrinsic width of the Vector in |
defaultHeight: Dp |
Intrinsic height of the Vector in |
viewportWidth: Float |
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 |
viewportHeight: Float |
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 |
name: String = RootGroupName |
optional identifier used to identify the root of this vector graphic |
tintColor: Color = Color.Unspecified |
optional color used to tint the root group of this vector graphic |
tintBlendMode: BlendMode = BlendMode.SrcIn |
BlendMode used in combination with |
autoMirror: Boolean = false |
Determines if the contents of the Vector should be mirrored for right to left layouts. |
content: @Composable @VectorComposable (viewportWidth: Float, viewportHeight: Float) -> Unit |
Composable used to define the structure and contents of the vector graphic |
Extension functions
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 |
fillAlpha: Float = 1.0f |
the alpha to fill the path |
stroke: Brush? = null |
specifies the |
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 |
pathFillType: PathFillType = DefaultFillType |
specifies the winding rule that decides how the interior of a |
pathBuilder: PathBuilder.() -> Unit |
|
toPath
fun List<PathNode>.toPath(target: Path = Path()): Path
Converts this list of PathNode into a Path by adding the appropriate commands to the target path. If target is not specified, a new Path instance is created. This method returns target or the newly created Path.