lerpTo method

LightingConfig lerpTo(
  1. LightingConfig other,
  2. double t
)

Interpolates between this config and other.

Used by LightingApi.animateTo to animate radius, color, blur and alignment. Discrete fields switch at the middle of the animation.

Implementation

LightingConfig lerpTo(LightingConfig other, double t) {
  final discrete = t < 0.5;
  return LightingConfig(
    radius: lerpDouble(radius, other.radius, t)!,
    color: Color.lerp(color, other.color, t)!,
    withPulse: discrete ? withPulse : other.withPulse,
    useComponentAngle: discrete ? useComponentAngle : other.useComponentAngle,
    pulseVariation: lerpDouble(pulseVariation, other.pulseVariation, t)!,
    pulseSpeed: lerpDouble(pulseSpeed, other.pulseSpeed, t)!,
    pulseCurve: discrete ? pulseCurve : other.pulseCurve,
    blurBorder: lerpDouble(blurBorder, other.blurBorder, t),
    type: discrete ? type : other.type,
    align: Vector2(
      lerpDouble(align.x, other.align.x, t)!,
      lerpDouble(align.y, other.align.y, t)!,
    ),
    mode: discrete ? mode : other.mode,
    falloff: discrete ? falloff : other.falloff,
    innerRadius: lerpDouble(innerRadius, other.innerRadius, t)!,
    intensity: lerpDouble(intensity, other.intensity, t)!,
    additiveBlendMode: discrete ? additiveBlendMode : other.additiveBlendMode,
    flicker: discrete ? flicker : other.flicker,
    castShadows: discrete ? castShadows : other.castShadows,
  );
}