11 private readonly
bool _isSlideIn;
12 private PointF _originalFactor;
13 private PointF _originalPixels;
14 private PointF _startFactor;
15 private PointF _targetFactor;
26 float durationSeconds,
29 : base(durationSeconds, easing)
32 throw new ArgumentOutOfRangeException(nameof(direction));
35 _isSlideIn = isSlideIn;
41 internal override EffectChannel Channel => EffectChannel.Transform;
43 internal override bool SupportsTarget(
object target) =>
49 _originalFactor = EffectTargetAccess.GetOffsetFactor(Target);
50 _originalPixels = EffectTargetAccess.GetOffsetPixels(Target);
52 PointF travel = GetTravelFactor(
Direction);
56 _startFactor = IsNearlyZero(_originalFactor)
57 ?
new PointF(-travel.X, -travel.Y)
60 _targetFactor = PointF.Empty;
64 _startFactor = _originalFactor;
65 _targetFactor = travel;
68 EffectTargetAccess.SetTransform(
77 var factor =
new PointF(
78 _startFactor.X + (_targetFactor.X - _startFactor.X) * progress,
79 _startFactor.Y + (_targetFactor.Y - _startFactor.Y) * progress);
81 var pixels =
new PointF(
82 _originalPixels.X * (1f - progress),
83 _originalPixels.Y * (1f - progress));
85 EffectTargetAccess.SetTransform(Target, factor, pixels);
90 EffectTargetAccess.SetTransform(Target, _originalFactor, _originalPixels);
92 private static bool IsNearlyZero(PointF value) =>
93 Math.Abs(value.X) < 0.0001f && Math.Abs(value.Y) < 0.0001f;
95 private static PointF GetTravelFactor(
EffectDirection direction) => direction
switch
105 _ =>
throw new ArgumentOutOfRangeException(nameof(direction))
118 float durationSeconds,
120 : base(direction, durationSeconds, easing, isSlideIn: true)
134 float durationSeconds,
136 : base(direction, durationSeconds, easing, isSlideIn: false)
DisplayEffect(float durationSeconds, EasingKind easing=EasingKind.Linear)
Initializes a new instance of the DisplayEffect class.
override void RestoreOriginalState()
EffectDirection Direction
Gets the direction in which the target travels.
override void OnStarting()
Captures or prepares target state before the effect starts.
override void ApplyProgress(float progress)
SlideEffect(EffectDirection direction, float durationSeconds, EasingKind easing, bool isSlideIn)
Initializes a new instance of the SlideEffect class.
SlideInEffect(EffectDirection direction, float durationSeconds, EasingKind easing=EasingKind.EaseOutCubic)
Creates a slide-in effect.
SlideOutEffect(EffectDirection direction, float durationSeconds, EasingKind easing=EasingKind.EaseInCubic)
Creates a slide-out effect.
Represents a rendered view of a scene, combining a camera position with a viewport configuration to c...
Represents a single layer within a Scene, containing a grid of tiles and supporting various coordinat...
EffectDirection
Specifies the direction in which a directional display effect travels.
@ FromTopLeftToBottomRight
The effect travels from the upper-left corner toward the lower-right corner.
@ FromBottomLeftToTopRight
The effect travels from the lower-left corner toward the upper-right corner.
@ FromTopRightToBottomLeft
The effect travels from the upper-right corner toward the lower-left corner.
@ FromLeftToRight
The effect travels from the left edge toward the right edge.
@ FromBottomRightToTopLeft
The effect travels from the lower-right corner toward the upper-left corner.
@ FromRightToLeft
The effect travels from the right edge toward the left edge.
@ FromTopToBottom
The effect travels from the top edge toward the bottom edge.
@ FromBottomToTop
The effect travels from the bottom edge toward the top edge.
EasingKind
Enumeration of all supported easing functions for animation and movement interpolation....