ShapePath

public class ShapePath


Represents the descriptive path of a shape. Path segments are stored in sequence so that transformations can be applied to them when the android.graphics.Path is produced by the MaterialShapeDrawable.

Summary

Nested types

Path arc operation.

Path cubic operation.

Straight line operation.

public abstract class ShapePath.PathOperation

Interface for a path operation to be appended to the operations list.

Path quad operation.

Public fields

float

This field is deprecated.

Use the class methods to interact with this field so internal state can be * maintained.

float

This field is deprecated.

Use the class methods to interact with this field so internal state can be * maintained.

float

This field is deprecated.

Use the class methods to interact with this field so internal state can be maintained.

float

This field is deprecated.

Use the class methods to interact with this field so internal state can be maintained.

float

This field is deprecated.

Use the class methods to interact with this field so internal state can be maintained.

float

This field is deprecated.

Use the class methods to interact with this field so internal state can be maintained.

Public constructors

ShapePath(float startX, float startY)

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 android.graphics.Path under a matrix transform.

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.

Public fields

currentShadowAngle

public float currentShadowAngle

The angle of the start of the last drawn shadow. Changes internally. Do not change.

endShadowAngle

public float endShadowAngle

The angle at the end of the final shadow. Changes internally. Do not change.

endX

public float endX

The x coordinate for the current end of the path given the previously applied transformation. Changes internally. Do not change.

endY

public float endY

The y coordinate for the current end of the path given the previously applied transformation. Changes internally. Do not change.

startX

public float startX

The x coordinate for the start of the path. Does not change. Do not change.

startY

public float startY

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)

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
float left

the X coordinate of the left side of the rectangle containing the arc oval.

float top

the Y coordinate of the top of the rectangle containing the arc oval.

float right

the X coordinate of the right side of the rectangle containing the arc oval.

float bottom

the Y coordinate of the bottom of the rectangle containing the arc oval.

float startAngle

start angle of the arc.

float sweepAngle

sweep angle of the arc.

applyToPath

public void applyToPath(Matrix transform, Path path)

Apply the ShapePath sequence to a android.graphics.Path under a matrix transform.

Parameters
Matrix transform

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
float controlX1

the 1st control point x of the arc.

float controlY1

the 1st control point y of the arc.

float controlX2

the 2nd control point x of the arc.

float controlY2

the 2nd control point y of the arc.

float toX

the end x of the arc.

float toY

the end y of the arc.

lineTo

public void lineTo(float x, float y)

Add a line to the ShapePath.

Parameters
float x

the x to which the line should be drawn.

float y

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 twice. If an inner corner is formed, this can also draw the compat shadow without overlapping.

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
float controlX

the control point x of the arc.

float controlY

the control point y of the arc.

float toX

the end x of the arc.

float toY

the end y of the arc.

reset

public void reset(float startX, float startY)

Resets the ShapePath using a default shadow. reset.

reset

public void reset(
    float startX,
    float startY,
    float shadowStartAngle,
    float shadowSweepAngle
)

Resets fields given the provided assignment parameters.