DampingNode



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(dampOver: ProgressDomain, strength: Float, input: ValueNode)

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.

Cmn

Public functions

open operator Boolean
equals(other: Any?)
Cmn
open Int
Cmn
open String
Cmn

Public properties

ProgressDomain

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

Cmn
ValueNode

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

Cmn
Float

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

Cmn

Inherited functions

From androidx.ink.brush.behavior.Node
Version

Returns the minimum required Version for this Node.

Cmn

Inherited properties

From androidx.ink.brush.behavior.Node
List<ValueNode>

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

Cmn

Public constructors

DampingNode

DampingNode(dampOver: ProgressDomain, strength: Float, input: ValueNode)

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
dampOver: ProgressDomain

The domain units over which damping is applied.

strength: Float

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).

input: ValueNode

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

Public functions

equals

open operator fun equals(other: Any?): Boolean

hashCode

open fun hashCode(): Int

toString

open fun toString(): String

Public properties

dampOver

val dampOver: ProgressDomain

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

input

val input: ValueNode

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

strength

val strength: Float

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.