DampingNode


public final class DampingNode extends ValueNode


A ValueNode that applies damping to an input value, smoothing out rapid changes by causing the output value to asymptotically decay towards the input value over a specified time or distance.

Summary

Public constructors

DampingNode(
    @NonNull ProgressDomain dampOver,
    float strength,
    @NonNull ValueNode input
)

Creates a DampingNode that damps changes in an input value, causing the output value to slowly follow changes in the input value over a specified time or distance.

Public methods

boolean
equals(Object other)
final @NonNull ProgressDomain

The domain units over which damping is applied (whether distance or time).

final @NonNull ValueNode

The input node that produces the value to be modified by the damping.

final float

The strength of the damping to apply, measured in dampOver units.

int
@NonNull String

Inherited methods

From androidx.ink.brush.behavior.Node
final @NonNull Version

Returns the minimum required Version for this Node.

final @NonNull List<@NonNull ValueNode>

The ordered list of inputs that this node directly depends on.

Public constructors

DampingNode

Added in 1.1.0-alpha10
public DampingNode(
    @NonNull ProgressDomain dampOver,
    float strength,
    @NonNull ValueNode input
)

Creates a DampingNode that damps changes in an input value, causing the output value to slowly follow changes in the input value over a specified time or distance.

Damping smooths changes in the input value using standard exponential decay, where strength acts as the decay constant, measured in dampOver units. The greater the damping strength, the longer it takes for the output value to asymptotically approach the input value. For example, if dampOver is set to ProgressDomain.TIME_IN_SECONDS and strength is 0.5, then it will take about half a second for the output value to decay most of the way (see the documentation of the strength property) towards the input value; if strength is 0.25 then it will take only a quarter second. If strength is zero, then there is no damping at all, and the output value will instantly snap to the input value whenever that value changes.

If dampOver is ProgressDomain.DISTANCE_IN_CENTIMETERS and the stroke input data does not indicate the relationship between stroke units and physical units (e.g. as may be the case for programmatically-generated inputs), then the output value will be null regardless of the input.

Parameters
@NonNull ProgressDomain dampOver

The domain units over which damping is applied.

float strength

The amount of damping to apply, measured in dampOver units. Must be finite and non-negative. Smaller values result in less damping (i.e. faster transitions, following the input more closely), while larger values result in more damping (i.e. slower transitions and heavier smoothing).

@NonNull ValueNode input

The input node that produces the value to be modified by the damping.

Public methods

equals

public boolean equals(Object other)

getDampOver

Added in 1.1.0-alpha10
public final @NonNull ProgressDomain getDampOver()

The domain units over which damping is applied (whether distance or time).

getInput

Added in 1.1.0-alpha10
public final @NonNull ValueNode getInput()

The input node that produces the value to be modified by the damping.

getStrength

Added in 1.1.0-alpha10
public final float getStrength()

The strength of the damping to apply, measured in dampOver units.

This represents the amount of distance or time it will take for the output value of this node to exponentially decay most of the way (see note below) towards the input value.

This value will always be finite and non-negative.

Note: This value is used as the decay constant for a standard exponential decay function, so "most of the way" above means specifically 1 - 1/e, about 63%. This may seem like an arbitrary amount, but using a standard natural-base exponential decay function has nicer mathematical properties than using another base, and tends to feel more intuitive when tuning the strength value by hand.

hashCode

public int hashCode()

toString

public @NonNull String toString()