-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathStringExtensions.cs
More file actions
28 lines (23 loc) · 963 Bytes
/
Copy pathStringExtensions.cs
File metadata and controls
28 lines (23 loc) · 963 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System.Globalization;
namespace PictureRenderer.Optimizely
{
public static class StringExtensions
{
/// <summary>
/// Cast a string in the PictureRenderer focal point format ("x|y") to two numbers.
/// </summary>
public static (double x, double y) ToImageFocalPoint(this string focalPointString)
{
if (focalPointString == default)
return default;
(double x, double y) focalPoint = default;
var focalValues = focalPointString.Split('|');
if (focalValues.Length != 2)
return focalPoint;
if (!(double.TryParse(focalValues[0], NumberStyles.Any, CultureInfo.InvariantCulture, out focalPoint.x) &&
double.TryParse(focalValues[1], NumberStyles.Any, CultureInfo.InvariantCulture, out focalPoint.y)))
focalPoint = default;
return focalPoint;
}
}
}