Stroke
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 |
|---|
Stroke(@NonNull Brush brush, @NonNull StrokeInputBatch inputs)Construct a |
Stroke(Construct a |
Public methods |
|
|---|---|
final @NonNull Stroke |
Returns a |
final @NonNull Brush |
getBrush()Contains information on how the |
final @NonNull ImmutableStrokeInputBatch |
The user-drawn (or perhaps synthetically generated) path that this |
final @NonNull PartitionedMesh |
getShape()The geometric shape of the |
@NonNull String |
toString() |
Protected methods |
|
|---|---|
final void |
finalize() |
Public constructors
Stroke
public Stroke(@NonNull Brush brush, @NonNull StrokeInputBatch inputs)
Construct a Stroke given a Brush and a StrokeInputBatch, generating its shape.
Stroke
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
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
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
public final @NonNull ImmutableStrokeInputBatch getInputs()
The user-drawn (or perhaps synthetically generated) path that this Stroke takes.
getShape
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.