@ -4,6 +4,7 @@
using System ;
using System ;
using System.Globalization ;
using System.Globalization ;
using Avalonia.Animation.Animators ;
using Avalonia.Animation.Animators ;
using Avalonia.Utilities ;
using JetBrains.Annotations ;
using JetBrains.Annotations ;
namespace Avalonia
namespace Avalonia
@ -85,6 +86,22 @@ namespace Avalonia
public static Vector operator / ( Vector vector , double scale )
public static Vector operator / ( Vector vector , double scale )
= > Divide ( vector , scale ) ;
= > Divide ( vector , scale ) ;
/// <summary>
/// Parses a <see cref="Vector"/> string.
/// </summary>
/// <param name="s">The string.</param>
/// <returns>The <see cref="Vector"/>.</returns>
public static Vector Parse ( string s )
{
using ( var tokenizer = new StringTokenizer ( s , CultureInfo . InvariantCulture , exceptionMessage : "Invalid Vector." ) )
{
return new Vector (
tokenizer . ReadDouble ( ) ,
tokenizer . ReadDouble ( )
) ;
}
}
/// <summary>
/// <summary>
/// Length of the vector
/// Length of the vector
/// </summary>
/// </summary>
@ -166,9 +183,9 @@ namespace Avalonia
}
}
/// <summary>
/// <summary>
/// Returns the string representation of the point .
/// Returns the string representation of the vector .
/// </summary>
/// </summary>
/// <returns>The string representation of the point .</returns>
/// <returns>The string representation of the vector .</returns>
public override string ToString ( )
public override string ToString ( )
{
{
return string . Format ( CultureInfo . InvariantCulture , "{0}, {1}" , _ x , _ y ) ;
return string . Format ( CultureInfo . InvariantCulture , "{0}, {1}" , _ x , _ y ) ;