ShapePath
public
class
ShapePath
extends Object
java.lang.Object | |
↳ | com.google.android.material.shape.ShapePath |
Represents the descriptive path of a shape. Path segments are stored in sequence so that
transformations can be applied to them when the Path
is produced by the
MaterialShapeDrawable
.
Summary
Nested classes | |
---|---|
class |
ShapePath.PathArcOperation
Path arc operation. |
class |
ShapePath.PathCubicOperation
Path cubic operation. |
class |
ShapePath.PathLineOperation
Straight line operation. |
class |
ShapePath.PathOperation
Interface for a path operation to be appended to the operations list. |
class |
ShapePath.PathQuadOperation
Path quad operation. |
Fields | |
---|---|
public
float |
currentShadowAngle
This field is deprecated. Use the class methods to interact with this field so internal state can be * maintained. |
public
float |
endShadowAngle
This field is deprecated. Use the class methods to interact with this field so internal state can be * maintained. |
public
float |
endX
This field is deprecated. Use the class methods to interact with this field so internal state can be maintained. |
public
float |
endY
This field is deprecated. Use the class methods to interact with this field so internal state can be maintained. |
public
float |
startX
This field is deprecated. Use the class methods to interact with this field so internal state can be maintained. |
public
float |
startY
This field is deprecated. Use the class methods to interact with this field so internal state can be maintained. |
Public methods | |
---|---|
void
|
addArc(float left, float top, float right, float bottom, float startAngle, float sweepAngle)
Add an arc to the ShapePath. |
void
|
applyToPath(Matrix transform, Path path)
Apply the ShapePath sequence to a |
void
|
cubicToPoint(float controlX1, float controlY1, float controlX2, float controlY2, float toX, float toY)
Add a cubic to the ShapePath. |
void
|
lineTo(float x, float y)
Add a line to the ShapePath. |
void
|
lineTo(float x1, float y1, float x2, float y2)
Add two connected segments to the ShapePath. |
void
|
quadToPoint(float controlX, float controlY, float toX, float toY)
Add a quad to the ShapePath. |
void
|
reset(float startX, float startY)
Resets the ShapePath using a default shadow. |
void
|
reset(float startX, float startY, float shadowStartAngle, float shadowSweepAngle)
Resets fields given the provided assignment parameters. |
Inherited methods | |||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Fields
currentShadowAngle
public float currentShadowAngle
This field is deprecated.
Use the class methods to interact with this field so internal state can be *
maintained.
The angle of the start of the last drawn shadow. Changes internally. Do not change.
endShadowAngle
public float endShadowAngle
This field is deprecated.
Use the class methods to interact with this field so internal state can be *
maintained.
The angle at the end of the final shadow. Changes internally. Do not change.
endX
public float endX
This field is deprecated.
Use the class methods to interact with this field so internal state can be
maintained.
The x coordinate for the current end of the path given the previously applied transformation. Changes internally. Do not change.
endY
public float endY
This field is deprecated.
Use the class methods to interact with this field so internal state can be
maintained.
The y coordinate for the current end of the path given the previously applied transformation. Changes internally. Do not change.
startX
public float startX
This field is deprecated.
Use the class methods to interact with this field so internal state can be
maintained.
The x coordinate for the start of the path. Does not change. Do not change.
startY
public float startY
This field is deprecated.
Use the class methods to interact with this field so internal state can be
maintained.
The y coordinate for the start of the path. Does not change. Do not change.
Public constructors
ShapePath
public ShapePath ()
ShapePath
public ShapePath (float startX, float startY)
Parameters | |
---|---|
startX |
float |
startY |
float |
Public methods
addArc
public void addArc (float left, float top, float right, float bottom, float startAngle, float sweepAngle)
Add an arc to the ShapePath.
Parameters | |
---|---|
left |
float : the X coordinate of the left side of the rectangle containing the arc oval. |
top |
float : the Y coordinate of the top of the rectangle containing the arc oval. |
right |
float : the X coordinate of the right side of the rectangle containing the arc oval. |
bottom |
float : the Y coordinate of the bottom of the rectangle containing the arc oval. |
startAngle |
float : start angle of the arc. |
sweepAngle |
float : sweep angle of the arc.
|
applyToPath
public void applyToPath (Matrix transform, Path path)
Apply the ShapePath sequence to a Path
under a matrix transform.
Parameters | |
---|---|
transform |
Matrix : the matrix transform under which this ShapePath is applied |
path |
Path : the path to which this ShapePath is applied
|
cubicToPoint
public void cubicToPoint (float controlX1, float controlY1, float controlX2, float controlY2, float toX, float toY)
Add a cubic to the ShapePath.
Note: This operation will not draw compatibility shadows. This means no shadow will be drawn on API < 21 and a shadow will only be drawn on API < 29 if the final path is convex.
Parameters | |
---|---|
controlX1 |
float : the 1st control point x of the arc. |
controlY1 |
float : the 1st control point y of the arc. |
controlX2 |
float : the 2nd control point x of the arc. |
controlY2 |
float : the 2nd control point y of the arc. |
toX |
float : the end x of the arc. |
toY |
float : the end y of the arc.
|
lineTo
public void lineTo (float x, float y)
Add a line to the ShapePath.
Parameters | |
---|---|
x |
float : the x to which the line should be drawn. |
y |
float : the y to which the line should be drawn.
|
lineTo
public void lineTo (float x1, float y1, float x2, float y2)
Add two connected segments to the ShapePath. This is equivalent to call lineTo(float, float)
twice. If an inner corner is formed, this can also draw the compat shadow without
overlapping.
Parameters | |
---|---|
x1 |
float |
y1 |
float |
x2 |
float |
y2 |
float |
quadToPoint
public void quadToPoint (float controlX, float controlY, float toX, float toY)
Add a quad to the ShapePath.
Note: This operation will not draw compatibility shadows. This means no shadow will be drawn on API < 21 and a shadow will only be drawn on API < 29 if the final path is convex.
Parameters | |
---|---|
controlX |
float : the control point x of the arc. |
controlY |
float : the control point y of the arc. |
toX |
float : the end x of the arc. |
toY |
float : the end y of the arc.
|
reset
public void reset (float startX, float startY)
Resets the ShapePath using a default shadow. reset(float, float, float, float)
.
Parameters | |
---|---|
startX |
float |
startY |
float |
reset
public void reset (float startX, float startY, float shadowStartAngle, float shadowSweepAngle)
Resets fields given the provided assignment parameters.
Parameters | |
---|---|
startX |
float |
startY |
float |
shadowStartAngle |
float |
shadowSweepAngle |
float |