11 changed files with 234 additions and 1 deletions
@ -0,0 +1,21 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
namespace Avalonia.Animation.Animators |
|||
{ |
|||
/// <summary>
|
|||
/// Animator that handles <see cref="bool"/> properties.
|
|||
/// </summary>
|
|||
public class BoolAnimator : Animator<bool> |
|||
{ |
|||
/// <inheritdocs/>
|
|||
public override bool Interpolate(double progress, bool oldValue, bool newValue) |
|||
{ |
|||
if(progress >= 1d) |
|||
return newValue; |
|||
if(progress >= 0) |
|||
return oldValue; |
|||
return oldValue; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
|
|||
namespace Avalonia.Animation.Animators |
|||
{ |
|||
/// <summary>
|
|||
/// Animator that handles <see cref="byte"/> properties.
|
|||
/// </summary>
|
|||
public class ByteAnimator : Animator<byte> |
|||
{ |
|||
static double maxVal = (double)byte.MaxValue; |
|||
|
|||
/// <inheritdocs/>
|
|||
public override byte Interpolate(double progress, byte oldValue, byte newValue) |
|||
{ |
|||
var normOV = oldValue / maxVal; |
|||
var normNV = newValue / maxVal; |
|||
var deltaV = normNV - normOV; |
|||
return (byte)Math.Round(maxVal * ((deltaV * progress) + normOV)); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
namespace Avalonia.Animation.Animators |
|||
{ |
|||
/// <summary>
|
|||
/// Animator that handles <see cref="decimal"/> properties.
|
|||
/// </summary>
|
|||
public class DecimalAnimator : Animator<decimal> |
|||
{ |
|||
/// <inheritdocs/>
|
|||
public override decimal Interpolate(double progress, decimal oldValue, decimal newValue) |
|||
{ |
|||
return ((newValue - oldValue) * (decimal)progress) + oldValue; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
namespace Avalonia.Animation.Animators |
|||
{ |
|||
/// <summary>
|
|||
/// Animator that handles <see cref="float"/> properties.
|
|||
/// </summary>
|
|||
public class FloatAnimator : Animator<float> |
|||
{ |
|||
/// <inheritdocs/>
|
|||
public override float Interpolate(double progress, float oldValue, float newValue) |
|||
{ |
|||
return ((newValue - oldValue) * (float)progress) + oldValue; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
|
|||
namespace Avalonia.Animation.Animators |
|||
{ |
|||
/// <summary>
|
|||
/// Animator that handles <see cref="Int16"/> properties.
|
|||
/// </summary>
|
|||
public class Int16Animator : Animator<Int16> |
|||
{ |
|||
static double maxVal = (double)Int16.MaxValue; |
|||
|
|||
/// <inheritdocs/>
|
|||
public override Int16 Interpolate(double progress, Int16 oldValue, Int16 newValue) |
|||
{ |
|||
var normOV = oldValue / maxVal; |
|||
var normNV = newValue / maxVal; |
|||
var deltaV = normNV - normOV; |
|||
return (Int16)Math.Round(maxVal * ((deltaV * progress) + normOV)); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
|
|||
namespace Avalonia.Animation.Animators |
|||
{ |
|||
/// <summary>
|
|||
/// Animator that handles <see cref="Int32"/> properties.
|
|||
/// </summary>
|
|||
public class Int32Animator : Animator<Int32> |
|||
{ |
|||
static double maxVal = (double)Int32.MaxValue; |
|||
|
|||
/// <inheritdocs/>
|
|||
public override Int32 Interpolate(double progress, Int32 oldValue, Int32 newValue) |
|||
{ |
|||
var normOV = oldValue / maxVal; |
|||
var normNV = newValue / maxVal; |
|||
var deltaV = normNV - normOV; |
|||
return (Int32)Math.Round(maxVal * ((deltaV * progress) + normOV)); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
|
|||
namespace Avalonia.Animation.Animators |
|||
{ |
|||
/// <summary>
|
|||
/// Animator that handles <see cref="Int64"/> properties.
|
|||
/// </summary>
|
|||
public class Int64Animator : Animator<Int64> |
|||
{ |
|||
static double maxVal = (double)Int64.MaxValue; |
|||
|
|||
/// <inheritdocs/>
|
|||
public override Int64 Interpolate(double progress, Int64 oldValue, Int64 newValue) |
|||
{ |
|||
var normOV = oldValue / maxVal; |
|||
var normNV = newValue / maxVal; |
|||
var deltaV = normNV - normOV; |
|||
return (Int64)Math.Round(maxVal * ((deltaV * progress) + normOV)); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
|
|||
namespace Avalonia.Animation.Animators |
|||
{ |
|||
/// <summary>
|
|||
/// Animator that handles <see cref="UInt16"/> properties.
|
|||
/// </summary>
|
|||
public class UInt16Animator : Animator<UInt16> |
|||
{ |
|||
static double maxVal = (double)UInt16.MaxValue; |
|||
|
|||
/// <inheritdocs/>
|
|||
public override UInt16 Interpolate(double progress, UInt16 oldValue, UInt16 newValue) |
|||
{ |
|||
var normOV = oldValue / maxVal; |
|||
var normNV = newValue / maxVal; |
|||
var deltaV = normNV - normOV; |
|||
return (UInt16)Math.Round(maxVal * ((deltaV * progress) + normOV)); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
|
|||
namespace Avalonia.Animation.Animators |
|||
{ |
|||
/// <summary>
|
|||
/// Animator that handles <see cref="UInt32"/> properties.
|
|||
/// </summary>
|
|||
public class UInt32Animator : Animator<UInt32> |
|||
{ |
|||
static double maxVal = (double)UInt32.MaxValue; |
|||
|
|||
/// <inheritdocs/>
|
|||
public override UInt32 Interpolate(double progress, UInt32 oldValue, UInt32 newValue) |
|||
{ |
|||
var normOV = oldValue / maxVal; |
|||
var normNV = newValue / maxVal; |
|||
var deltaV = normNV - normOV; |
|||
return (UInt32)Math.Round(maxVal * ((deltaV * progress) + normOV)); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
|
|||
namespace Avalonia.Animation.Animators |
|||
{ |
|||
/// <summary>
|
|||
/// Animator that handles <see cref="UInt64"/> properties.
|
|||
/// </summary>
|
|||
public class UInt64Animator : Animator<UInt64> |
|||
{ |
|||
static double maxVal = (double)UInt64.MaxValue; |
|||
|
|||
/// <inheritdocs/>
|
|||
public override UInt64 Interpolate(double progress, UInt64 oldValue, UInt64 newValue) |
|||
{ |
|||
var normOV = oldValue / maxVal; |
|||
var normNV = newValue / maxVal; |
|||
var deltaV = normNV - normOV; |
|||
return (UInt64)Math.Round(maxVal * ((deltaV * progress) + normOV)); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue