public final class Stroke


An immutable object comprised of a StrokeInputBatch that represents a user-drawn (or sometimes synthetic) path, a Brush that contains information on how that path should be converted into a geometric shape and rendered on screen, and a PartitionedMesh which is the geometric shape calculated from the combination of the StrokeInputBatch and the Brush.

This can be constructed directly from a StrokeInputBatch that has already been completed. To construct a stroke incrementally and render it as input events are received in real time, use InProgressStrokesView or InProgressStroke, which will ultimately return a Stroke when input is completed.

Summary

Public constructors

Construct a Stroke given a Brush and a StrokeInputBatch, generating its shape.

Stroke(
    @NonNull Brush brush,
    @NonNull StrokeInputBatch inputs,
    @NonNull PartitionedMesh shape
)

Construct a Stroke given a Brush, a StrokeInputBatch, and a PartitionedMesh.

Public methods

final @NonNull Stroke
copy(@NonNull Brush brush)

Returns a Stroke with the brush replaced.

final @NonNull Brush

Contains information on how the inputs should be used to calculate the shape and how that shape should be drawn on screen.

final @NonNull ImmutableStrokeInputBatch

The user-drawn (or perhaps synthetically generated) path that this Stroke takes.

final @NonNull PartitionedMesh

The geometric shape of the Stroke, which can be used to render it on screen and to perform geometric calculations.

@NonNull String

Protected methods

final void

Public constructors

Stroke

Added in 1.0.0-alpha02
public Stroke(@NonNull Brush brush, @NonNull StrokeInputBatch inputs)

Construct a Stroke given a Brush and a StrokeInputBatch, generating its shape.

Stroke

Added in 1.0.0-alpha02
public Stroke(
    @NonNull Brush brush,
    @NonNull StrokeInputBatch inputs,
    @NonNull PartitionedMesh shape
)

Construct a Stroke given a Brush, a StrokeInputBatch, and a PartitionedMesh.

Note that this does not do any validation that brush and inputs together would produce shape. This constructor is primarily intended for deserialization, in cases where the PartitionedMesh is being stored in addition to the Brush and StrokeInputBatch.

Public methods

copy

Added in 1.0.0-alpha02
public final @NonNull Stroke copy(@NonNull Brush brush)

Returns a Stroke with the brush replaced. This may or may not affect the shape, but will not change the inputs.

getBrush

Added in 1.0.0-alpha02
public final @NonNull Brush getBrush()

Contains information on how the inputs should be used to calculate the shape and how that shape should be drawn on screen.

getInputs

Added in 1.0.0-alpha02
public final @NonNull ImmutableStrokeInputBatch getInputs()

The user-drawn (or perhaps synthetically generated) path that this Stroke takes.

getShape

Added in 1.0.0-alpha02
public final @NonNull PartitionedMesh getShape()

The geometric shape of the Stroke, which can be used to render it on screen and to perform geometric calculations. This PartitionedMesh will have one render group per brush coat in brush.

toString

public @NonNull String toString()

Protected methods

finalize

Added in 1.0.0-alpha02
protected final void finalize()