示例#1
0
 // copy constructor
 public RectangleR(RectangleR r)
 {
     _x      = r.X;
     _y      = r.Y;
     _width  = r.Width;
     _height = r.Height;
 }
示例#2
0
		// copy constructor
		public RectangleR(RectangleR r)
		{
			_x = r.X;
			_y = r.Y;
			_width = r.Width;
			_height = r.Height;
		}
示例#3
0
 public override bool Equals(object obj)
 {
     if (obj is RectangleR)
     {
         RectangleR r = (RectangleR)obj;
         return(X == r.X && Y == r.Y && Width == r.Width && Height == r.Height);
     }
     return(false);
 }
示例#4
0
        // scales the points so that the length of their shorter side
        // matches the length of the shorter side of the given box.
        // thus, both dimensions are warped proportionally, rather than
        // independently, like in the function ScaleTo.
        public static ArrayList ScaleToMin(ArrayList points, RectangleR box)
        {
            ArrayList  newPoints = new ArrayList(points.Count);
            RectangleR r         = FindBox(points);

            for (int i = 0; i < points.Count; i++)
            {
                PointR p = (PointR)points[i];
                p.X *= (box.MinSide / r.MinSide);
                p.Y *= (box.MinSide / r.MinSide);
                newPoints.Add(p);
            }
            return(newPoints);
        }
示例#5
0
        // scales by the percentages contained in the 'sz' parameter. values of 1.0 would result in the
        // identity scale (that is, no change).
        public static ArrayList ScaleBy(ArrayList points, SizeR sz)
        {
            ArrayList  newPoints = new ArrayList(points.Count);
            RectangleR r         = FindBox(points);

            for (int i = 0; i < points.Count; i++)
            {
                PointR p = (PointR)points[i];
                p.X *= sz.Width;
                p.Y *= sz.Height;
                newPoints.Add(p);
            }
            return(newPoints);
        }
示例#6
0
        // translates the points so that the upper-left corner of their bounding box lies at 'toPt'
        public static ArrayList TranslateBBoxTo(ArrayList points, PointR toPt)
        {
            ArrayList  newPoints = new ArrayList(points.Count);
            RectangleR r         = Utils.FindBox(points);

            for (int i = 0; i < points.Count; i++)
            {
                PointR p = (PointR)points[i];
                p.X += (toPt.X - r.X);
                p.Y += (toPt.Y - r.Y);
                newPoints.Add(p);
            }
            return(newPoints);
        }
示例#7
0
        // scales the points so that they form the size given. does not restore the
        // origin of the box.
        public static ArrayList ScaleTo(ArrayList points, SizeR sz)
        {
            ArrayList  newPoints = new ArrayList(points.Count);
            RectangleR r         = FindBox(points);

            for (int i = 0; i < points.Count; i++)
            {
                PointR p = (PointR)points[i];
                if (r.Width != 0d)
                {
                    p.X *= (sz.Width / r.Width);
                }
                if (r.Height != 0d)
                {
                    p.Y *= (sz.Height / r.Height);
                }
                newPoints.Add(p);
            }
            return(newPoints);
        }
示例#8
0
 // scales the points so that the length of their shorter side
 // matches the length of the shorter side of the given box.
 // thus, both dimensions are warped proportionally, rather than
 // independently, like in the function ScaleTo.
 public static ArrayList ScaleToMin(ArrayList points, RectangleR box)
 {
     ArrayList newPoints = new ArrayList(points.Count);
     RectangleR r = FindBox(points);
     for (int i = 0; i < points.Count; i++)
     {
         PointR p = (PointR) points[i];
         p.X *= (box.MinSide / r.MinSide);
         p.Y *= (box.MinSide / r.MinSide);
         newPoints.Add(p);
     }
     return newPoints;
 }