port from perforce

This commit is contained in:
2026-04-18 22:31:51 +02:00
commit 8d0ab5b7cc
8409 changed files with 3972376 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
namespace AiwazAnimator
{
abstract public class Animation : INotifyPropertyChanged
{
public float StartTime { get; set; }
public float EndTime { get; set; }
public float StartValue { get; set; }
public float EndValue { get; set; }
public Func<float> ValueGetter;
public Action<float> ValueSetter;
public Func<string> ValueNamer;
public float Value
{
get { return ValueGetter(); }
set { ValueSetter(value); OnPropertyChanged("Value"); }
}
private float _time;
public float Time
{
get
{
return _time;
}
set
{
if (_time == value)
return;
_time = value;
OnPropertyChanged("Time");
}
}
public Animation()
{
AnimationName = "Erroneous";
}
public string ListString
{
get
{
return string.Format("Type: {0}, Time: [{1}, {2}], Value: [{3}, {4}], Target: {5}", AnimationName, StartTime, EndTime, StartValue, EndValue, ValueNamer());
}
}
public void Animate(float time)
{
if (time < StartTime)
{
return;
}
else if (time > EndTime)
{
return;
}
float NormalizedTime = (time - StartTime) / (EndTime - StartTime);
Time = NormalizedTime;
Value = Calculate(NormalizedTime);
}
protected abstract float Calculate(float NormalizedTime);
public string AnimationName;
protected virtual void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
public event PropertyChangedEventHandler PropertyChanged;
}
}

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AiwazAnimator.Animations
{
class CosineAnimation
: Animation
{
public CosineAnimation()
: base()
{
AnimationName = "Cosine";
}
protected override float Calculate(float NormalizedTime)
{
float Interpolant = (float)((1.0 - Math.Cos(NormalizedTime * Math.PI)) / 2.0);
return (StartValue * (1.0f - Interpolant) + EndValue * Interpolant);
}
}
}

View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AiwazAnimator.Animations
{
class LinearAnimation
: Animation
{
public LinearAnimation()
: base()
{
AnimationName = "Linear";
}
protected override float Calculate(float NormalizedTime)
{
return StartValue * (1.0f - NormalizedTime) + EndValue * NormalizedTime;
}
}
}