Gondwana Game Engine Development (master) - 2.6.1
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
ZoomEffects.cs
3
4namespace Gondwana.Effects;
5
7public abstract class ZoomEffect : DisplayEffect
8{
9 private float _originalZoom;
10 private float _clampedTargetZoom;
11
17 private protected ZoomEffect(float targetZoom, float durationSeconds)
18 : base(durationSeconds, EasingKind.Linear)
19 {
20 if (targetZoom <= 0f)
21 throw new ArgumentOutOfRangeException(nameof(targetZoom));
22
23 TargetZoom = targetZoom;
24 }
25
27 public float TargetZoom { get; }
28
29 internal override EffectChannel Channel => EffectChannel.Zoom;
30
31 internal override bool SupportsTarget(object target) => target is View;
32
34 private protected override void OnStarting()
35 {
36 var view = GetTarget<View>();
37 _originalZoom = view.Viewport.Zoom;
38 _clampedTargetZoom = Math.Clamp(TargetZoom, view.MinZoom, view.MaxZoom);
39 view.Viewport.ZoomToOverDuration(_clampedTargetZoom, DurationSeconds);
40 }
41
42 // View.Update() advances the existing Viewport zoom animator. The effect
43 // manager owns only lifecycle, replacement, and completion notification.
45 private protected override void ApplyProgress(float progress)
46 {
47 }
48
50 private protected override void OnCompleted() =>
51 GetTarget<View>().Viewport.SnapZoom(_clampedTargetZoom);
52
54 private protected override void RestoreOriginalState() =>
55 GetTarget<View>().Viewport.SnapZoom(_originalZoom);
56}
57
59public sealed class ZoomInEffect : ZoomEffect
60{
64 public ZoomInEffect(float targetZoom, float durationSeconds)
65 : base(targetZoom, durationSeconds)
66 {
67 }
68}
69
71public sealed class ZoomOutEffect : ZoomEffect
72{
76 public ZoomOutEffect(float targetZoom, float durationSeconds)
77 : base(targetZoom, durationSeconds)
78 {
79 }
80}
float DurationSeconds
Gets the requested effect duration in seconds.
DisplayEffect(float durationSeconds, EasingKind easing=EasingKind.Linear)
Initializes a new instance of the DisplayEffect class.
override void OnStarting()
Captures or prepares target state before the effect starts.
override void ApplyProgress(float progress)
override void RestoreOriginalState()
override void OnCompleted()
Runs the effect-specific completion behavior.
float TargetZoom
Gets the requested final zoom factor.
ZoomEffect(float targetZoom, float durationSeconds)
Initializes a new instance of the ZoomEffect class.
ZoomInEffect(float targetZoom, float durationSeconds)
Creates a zoom-in effect.
ZoomOutEffect(float targetZoom, float durationSeconds)
Creates a zoom-out effect.
Represents a rendered view of a scene, combining a camera position with a viewport configuration to c...
Definition View.cs:14
EasingKind
Enumeration of all supported easing functions for animation and movement interpolation....
Definition EasingKind.cs:9
@ Linear
Linear easing with constant velocity throughout the transition. No acceleration or deceleration is ap...
Definition EasingKind.cs:15