示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Rectangled"/> using the specified location and size.
 /// </summary>
 /// <param name="location">The lower-left corner of the rectangle.</param>
 /// <param name="size">The size of the rectangle.</param>
 public Rectangled(Point2d location, Size2d size)
 {
     X      = location.X;
     Y      = location.Y;
     Width  = size.Width;
     Height = size.Height;
 }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Size3d"/> using the specified size and value.
 /// </summary>
 /// <param name="value">A size containing the values with which to initialize the Width and Height components</param>
 /// <param name="depth">Value for the Depth component of the size.</param>
 public Size3d(Size2d value, double depth)
 {
     Contract.Requires(0 <= depth);
     Width  = value.Width;
     Height = value.Height;
     Depth  = depth;
 }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Ellipsed"/> using the specified location and radius.
 /// </summary>
 /// <param name="center">The center of the ellipse.</param>
 /// <param name="size">The size of the ellipse.</param>
 public Ellipsed(Point2d center, Size2d size)
 {
     X      = center.X;
     Y      = center.Y;
     Width  = size.Width;
     Height = size.Height;
 }
示例#4
0
 /// <summary>
 /// Constrains each component to a given range.
 /// </summary>
 /// <param name="value">A size to constrain.</param>
 /// <param name="min">The minimum values for each component.</param>
 /// <param name="max">The maximum values for each component.</param>
 /// <returns>A size with each component constrained to the given range.</returns>
 public static Size2d Clamp(Size2d value, Size2d min, Size2d max)
 {
     return(new Size2d(Functions.Clamp(value.Width, min.Width, max.Width), Functions.Clamp(value.Height, min.Height, max.Height)));
 }
示例#5
0
 /// <summary>
 /// Returns a size where each component is rounded to the nearest integral value.
 /// </summary>
 /// <param name="value">A size.</param>
 /// <param name="digits">The number of fractional digits in the return value.</param>
 /// <param name="mode">Specification for how to round value if it is midway between two other numbers.</param>
 /// <returns>The result of rounding value.</returns>
 public static Size2d Round(Size2d value, int digits, MidpointRounding mode)
 {
     return(new Size2d(Functions.Round(value.Width, digits, mode), Functions.Round(value.Height, digits, mode)));
 }
示例#6
0
 /// <summary>
 /// Returns a size where each component is rounded to the nearest integral value.
 /// </summary>
 /// <param name="value">A size.</param>
 /// <param name="digits">The number of fractional digits in the return value.</param>
 /// <returns>The result of rounding value.</returns>
 public static Size2d Round(Size2d value, int digits)
 {
     return(new Size2d(Functions.Round(value.Width, digits), Functions.Round(value.Height, digits)));
 }
示例#7
0
 /// <summary>
 /// Returns a size where each component is rounded to the nearest integral value.
 /// </summary>
 /// <param name="value">A size.</param>
 /// <returns>The result of rounding value.</returns>
 public static Size2d Round(Size2d value)
 {
     return(new Size2d(Functions.Round(value.Width), Functions.Round(value.Height)));
 }
示例#8
0
 /// <summary>
 /// Returns a size where each component is the fractional part of the specified component.
 /// </summary>
 /// <param name="value">A size.</param>
 /// <returns>The fractional of value.</returns>
 public static Size2d Fractional(Size2d value)
 {
     return(new Size2d(Functions.Fractional(value.Width), Functions.Fractional(value.Height)));
 }
示例#9
0
 /// <summary>
 /// Returns a size where each component is the integral part of the specified component.
 /// </summary>
 /// <param name="value">A size.</param>
 /// <returns>The integral of value.</returns>
 public static Size2d Truncate(Size2d value)
 {
     return(new Size2d(Functions.Truncate(value.Width), Functions.Truncate(value.Height)));
 }
示例#10
0
 /// <summary>
 /// Returns a size where each component is the largest integral value that
 /// is less than or equal to the specified component.
 /// </summary>
 /// <param name="value">A size.</param>
 /// <returns>The floor of value.</returns>
 public static Size2d Floor(Size2d value)
 {
     return(new Size2d(Functions.Floor(value.Width), Functions.Floor(value.Height)));
 }
示例#11
0
 /// <summary>
 /// Returns a size where each component is the smallest integral value that
 /// is greater than or equal to the specified component.
 /// </summary>
 /// <param name="value">A size.</param>
 /// <returns>The ceiling of value.</returns>
 public static Size2d Ceiling(Size2d value)
 {
     return(new Size2d(Functions.Ceiling(value.Width), Functions.Ceiling(value.Height)));
 }
示例#12
0
 /// <summary>
 /// Returns a size that contains the highest value from each pair of components.
 /// </summary>
 /// <param name="value1">The first size.</param>
 /// <param name="value2">The second size.</param>
 /// <returns>The highest of each component in left and the matching component in right.</returns>
 public static Size2d Max(Size2d value1, Size2d value2)
 {
     return(new Size2d(Functions.Max(value1.Width, value2.Width), Functions.Max(value1.Height, value2.Height)));
 }
示例#13
0
 /// <summary>
 /// Transforms the components of a size and returns the result.
 /// </summary>
 /// <param name="value">The size to transform.</param>
 /// <param name="transformer">A transform function to apply to each component.</param>
 /// <returns>The result of transforming each component of value.</returns>
 public static Size2i Transform(Size2d value, Func <double, int> transformer)
 {
     return(new Size2i(transformer(value.Width), transformer(value.Height)));
 }
示例#14
0
 /// <summary>
 /// Returns a value that indicates whether two sizes are equal.
 /// </summary>
 /// <param name="left">The first size to compare.</param>
 /// <param name="right">The second size to compare.</param>
 /// <returns>true if the left and right are equal; otherwise, false.</returns>
 public static bool Equals(Size2d left, Size2d right)
 {
     return(left == right);
 }
示例#15
0
 /// <summary>
 /// Divides a size by a scalar and returns the result.
 /// </summary>
 /// <param name="size">The size to be divided (the dividend).</param>
 /// <param name="scalar">The scalar to divide by (the divisor).</param>
 /// <returns>The result of dividing left by right (the quotient).</returns>
 public static Size2d Divide(Size2d size, double scalar)
 {
     Contract.Requires(0 <= scalar);
     return(new Size2d(size.Width / scalar, size.Height / scalar));
 }
示例#16
0
 /// <summary>
 /// Returns the product of a size and scalar.
 /// </summary>
 /// <param name="size">The size to multiply.</param>
 /// <param name="scalar">The scalar to multiply.</param>
 /// <returns>The product of the left and right parameters.</returns>
 public static Size2d Multiply(Size2d size, double scalar)
 {
     Contract.Requires(0 <= scalar);
     return(new Size2d(size.Width * scalar, size.Height * scalar));
 }
示例#17
0
 /// <summary>
 /// Writes the given <see cref="Size2d"/> to an <see cref="Ibasa.IO.BinaryWriter">.
 /// </summary>
 public static void Write(this Ibasa.IO.BinaryWriter writer, Size2d size)
 {
     writer.Write(size.Width);
     writer.Write(size.Height);
 }