Jumar Macato
6 years ago
No known key found for this signature in database
GPG Key ID: B19884DAC3A5BF3F
3 changed files with
10 additions and
34 deletions
-
src/Avalonia.Animation/Easing/Easing.cs
-
src/Avalonia.Animation/Easing/SplineEasing.cs
-
src/Avalonia.Animation/KeySpline.cs
|
|
|
@ -28,39 +28,7 @@ namespace Avalonia.Animation.Easings |
|
|
|
{ |
|
|
|
if (e.Contains(',')) |
|
|
|
{ |
|
|
|
var k = e.Split(','); |
|
|
|
|
|
|
|
if (k.Count() != 4) |
|
|
|
{ |
|
|
|
throw new FormatException($"SplineEasing only accepts exactly 4 arguments."); |
|
|
|
} |
|
|
|
|
|
|
|
var splineEase = new SplineEasing(); |
|
|
|
|
|
|
|
var setterArray = new Action<double>[4] |
|
|
|
{ |
|
|
|
(x) => splineEase.X1 = x, |
|
|
|
|
|
|
|
(x) => splineEase.Y1 = x, |
|
|
|
|
|
|
|
(x) => splineEase.X2 = x, |
|
|
|
|
|
|
|
(x) => splineEase.Y2 = x |
|
|
|
}; |
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) |
|
|
|
{ |
|
|
|
if (double.TryParse(k[i], NumberStyles.Any, CultureInfo.InvariantCulture, out var x)) |
|
|
|
{ |
|
|
|
setterArray[i](x); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
throw new FormatException($"Parameter string \"{k[i]}\" is not a double."); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return splineEase; |
|
|
|
return new SplineEasing(KeySpline.Parse(e, CultureInfo.InvariantCulture)); |
|
|
|
} |
|
|
|
|
|
|
|
if (_easingTypes == null) |
|
|
|
|
|
|
|
@ -68,6 +68,11 @@ namespace Avalonia.Animation.Easings |
|
|
|
this.Y1 = y2; |
|
|
|
} |
|
|
|
|
|
|
|
public SplineEasing(KeySpline keySpline) |
|
|
|
{ |
|
|
|
_internalKeySpline = keySpline; |
|
|
|
} |
|
|
|
|
|
|
|
public SplineEasing() |
|
|
|
{ |
|
|
|
_internalKeySpline = new KeySpline(); |
|
|
|
|
|
|
|
@ -81,7 +81,10 @@ namespace Avalonia.Animation |
|
|
|
/// <returns>A <see cref="KeySpline"/> with the appropriate values set</returns>
|
|
|
|
public static KeySpline Parse(string value, CultureInfo culture) |
|
|
|
{ |
|
|
|
using (var tokenizer = new StringTokenizer((string)value, CultureInfo.InvariantCulture, exceptionMessage: "Invalid KeySpline.")) |
|
|
|
if (culture is null) |
|
|
|
culture = CultureInfo.InvariantCulture; |
|
|
|
|
|
|
|
using (var tokenizer = new StringTokenizer((string)value, culture, exceptionMessage: $"Invalid KeySpline string: \"{value}\".")) |
|
|
|
{ |
|
|
|
return new KeySpline(tokenizer.ReadDouble(), tokenizer.ReadDouble(), tokenizer.ReadDouble(), tokenizer.ReadDouble()); |
|
|
|
} |
|
|
|
|