{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

PathEffect.Companion

public static class PathEffect.Companion


Summary

Public methods

static final @NonNull PathEffect

Create a PathEffect that applies the inner effect to the path, and then applies the outer effect to the result of the inner effect.

static final @NonNull PathEffect
cornerPathEffect(float radius)

Replaces sharp angles between line segments into rounded angles of the specified radius

static final @NonNull PathEffect
dashPathEffect(@NonNull float[] intervals, float phase)

Draws a shape as a series of dashes with the given intervals and offset into the specified interval array.

static final @NonNull PathEffect
stampedPathEffect(
    @NonNull Path shape,
    float advance,
    float phase,
    @NonNull StampedPathEffectStyle style
)

Dash the drawn path by stamping it with the specified shape represented as a Path.

Public methods

chainPathEffect

public static final @NonNull PathEffect chainPathEffect(@NonNull PathEffect outer, @NonNull PathEffect inner)

Create a PathEffect that applies the inner effect to the path, and then applies the outer effect to the result of the inner effect. (e.g. outer(inner(path)).

cornerPathEffect

public static final @NonNull PathEffect cornerPathEffect(float radius)

Replaces sharp angles between line segments into rounded angles of the specified radius

Parameters
float radius

Rounded corner radius to apply for each angle of the drawn shape

dashPathEffect

public static final @NonNull PathEffect dashPathEffect(@NonNull float[] intervals, float phase)

Draws a shape as a series of dashes with the given intervals and offset into the specified interval array. The intervals must contain an even number of entries (>=2). The even indices specify "on" intervals and the odd indices represent "off" intervals. The phase parameter is the pixel offset into the intervals array (mod the sum of all of the intervals).

For example: if intervals[] = {10, 20}, and phase = 25, this will set up a dashed path like so: 5 pixels off 10 pixels on 20 pixels off 10 pixels on 20 pixels off

The phase parameter is an offset into the intervals array. The intervals array controls the length of the dashes. This is only applied for stroked shapes (ex. PaintingStyle.Stroke and is ignored for filled in shapes (ex. PaintingStyle.Fill

Parameters
@NonNull float[] intervals

Array of "on" and "off" distances for the dashed line segments

float phase

Pixel offset into the intervals array

stampedPathEffect

public static final @NonNull PathEffect stampedPathEffect(
    @NonNull Path shape,
    float advance,
    float phase,
    @NonNull StampedPathEffectStyle style
)

Dash the drawn path by stamping it with the specified shape represented as a Path. This is only applied to stroke shapes and will be ignored with filled shapes. The stroke width used with this PathEffect is ignored as well.

Parameters
@NonNull Path shape

Path to stamp along

float advance

Spacing between each stamped shape

float phase

Amount to offset before the first shape is stamped

@NonNull StampedPathEffectStyle style

How to transform the shape at each position as it is stamped