Example #1
0
File: Rect.cs Project: alexiej/YATE
 /// <summary>
 /// Parses the specified value.
 /// </summary>
 public static Rect Parse(string value)
 {
   Rect rect = new Rect();
   IFormatProvider formatProvider = CultureInfo.InvariantCulture;
   TokenizerHelper helper = new TokenizerHelper(value, formatProvider);
   rect.X = Convert.ToDouble(helper.NextTokenRequired(), formatProvider);
   rect.Y = Convert.ToDouble(helper.NextTokenRequired(), formatProvider);
   rect.Width = Convert.ToDouble(helper.NextTokenRequired(), formatProvider);
   rect.Height = Convert.ToDouble(helper.NextTokenRequired(), formatProvider);
   return rect;
 }
Example #2
0
File: Rect.cs Project: alexiej/YATE
 internal void Union(Rect rect)
 {
   double minX = Math.Min(X, rect.X);
   double minY = Math.Min(Y, rect.Y);
   double maxWidth = Math.Max(X + Width, rect.X + rect.Width);
   double maxHeight = Math.Max(Y + Height, rect.Y + Height);
   X = minX;
   Y = minY;
   Width = Math.Max(maxWidth - minX, 0.0);
   Height = Math.Max(maxHeight - minY, 0.0);
 }