Esempio n. 1
0
 /// <summary>
 /// Create new vector from two distance values
 /// </summary>
 /// <param name="x">X value</param>
 /// <param name="y">Y value</param>
 /// <param name="width">Width value</param>
 /// <param name="height">Height value</param>
 public Rectangle2d(DistanceD x, DistanceD y, DistanceD width, DistanceD height)
 {
     this.x = x.NativeValue;
     this.y = y.GetIn(x.NativeUnit);
     this.w = width.GetIn(x.NativeUnit);
     this.h = height.GetIn(x.NativeUnit);
     this.unit = x.NativeUnit;
 }
Esempio n. 2
0
 /// <summary>
 /// Create new vector from two distance values
 /// </summary>
 /// <param name="x">X value</param>
 /// <param name="y">Y value</param>
 public Vector2d(DistanceD x, DistanceD y)
 {
     this.x = x.NativeValue;
     this.y = y.GetIn(x.NativeUnit);
     this.unit = x.NativeUnit;
 }
Esempio n. 3
0
 /// <summary>
 /// Returns scaled vector which maches specified length
 /// </summary>
 /// <param name="newLength">New vector length</param>
 /// <returns>New vector of specified length</returns>
 public Vector2d Scaled(DistanceD newLength)
 {
     double scale = newLength.GetIn(unit) / NativeLength;
     return this * scale;
 }
Esempio n. 4
0
 /// <summary>
 /// Scales vector to match specified length
 /// </summary>
 /// <param name="newLength">New vector length</param>
 public void Scale(DistanceD newLength)
 {
     double scale = newLength.GetIn(unit) / NativeLength;
     x *= scale;
     y *= scale;
 }
Esempio n. 5
0
 /// <summary>
 /// Return cropped rectangle by specified amounts from all sides
 /// </summary>
 /// <param name="left">How much to crop from left</param>
 /// <param name="right">How much to crop from right</param>
 /// <param name="top">How much to crop from top</param>
 /// <param name="bottom">How much to crop from bottom</param>
 /// <returns>New cropped rectangle</returns>
 public Rectangle2d Cropped(DistanceD left, DistanceD right, DistanceD top, DistanceD bottom)
 {
     double l = left.GetIn(unit);
     double t = top.GetIn(unit);
     return new Rectangle2d(x + l, y + t, w - l - right.GetIn(unit), h - t - bottom.GetIn(unit), unit);
 }