Exemplo n.º 1
0
        public void Ctor(double roiX, double roiY, double roiWidth, double roiHeight, double borderWidth, double borderHeight)
        {
            var point  = new RoixPoint(roiX, roiY);
            var size   = new RoixSize(roiWidth, roiHeight);
            var rect   = new RoixRect(point, size);
            var border = new RoixSize(borderWidth, borderHeight);

            var br1 = new RoixBorderRect(rect, border);

            br1.Roi.Is(rect);
            br1.Border.Is(border);
            new RoixBorderRect(rect, RoixSize.Zero);     //OK
            Assert.Throws <ArgumentException>(() => new RoixBorderRect(rect, RoixSize.Empty));

            var gpoint1 = new RoixBorderPoint(point, border);
            var gsize   = new RoixBorderSize(size, border);
            var br2     = new RoixBorderRect(gpoint1, gsize);

            br2.Roi.Is(rect);
            br2.Border.Is(border);
            Assert.Throws <ArgumentException>(() => new RoixBorderRect(gpoint1, RoixBorderSize.Zero));

            var gpoint2 = new RoixBorderPoint(point + (RoixVector)size, border);
            var br3     = new RoixBorderRect(gpoint1, gpoint2);

            br3.Roi.Is(rect);
            br3.Border.Is(border);
            Assert.Throws <ArgumentException>(() => new RoixBorderRect(gpoint1, RoixBorderPoint.Zero));

            var gvector = new RoixBorderVector((RoixVector)size, border);
            var br4     = new RoixBorderRect(gpoint1, gvector);

            br4.Roi.Is(rect);
            br4.Border.Is(border);
        }
Exemplo n.º 2
0
        public void Ctor(double x, double y, double width, double height)
        {
            var point = new RoixPoint(x, y);
            var size  = new RoixSize(width, height);

            var rect1 = new RoixRect(point, size);

            rect1.Location.X.Is(point.X);
            rect1.Location.Y.Is(point.Y);
            rect1.Size.Width.Is(size.Width);
            rect1.Size.Height.Is(size.Height);

            var rect2 = new RoixRect(x, y, width, height);

            rect2.Location.X.Is(point.X);
            rect2.Location.Y.Is(point.Y);
            rect2.Size.Width.Is(size.Width);
            rect2.Size.Height.Is(size.Height);

            var point3 = point + (RoixVector)size;
            var rect3  = new RoixRect(point, point3);

            rect3.Location.X.Is(point.X);
            rect3.Location.Y.Is(point.Y);
            rect3.Size.Width.Is(size.Width);
            rect3.Size.Height.Is(size.Height);

            var rect4 = new RoixRect(point, (RoixVector)size);

            rect4.X.Is(point.X);
            rect4.Y.Is(point.Y);
            rect4.Size.Width.Is(size.Width);
            rect4.Size.Height.Is(size.Height);
        }
Exemplo n.º 3
0
        public void IsInside(double roiX, double roiY, double roiWidth, double roiHeight, double borderWidth, double borderHeight, bool isInside)
        {
            var rect   = new RoixRect(roiX, roiY, roiWidth, roiHeight);
            var border = new RoixSize(borderWidth, borderHeight);

            rect.IsInside(border).Is(isInside);
            rect.IsOutside(border).Is(!isInside);
        }
Exemplo n.º 4
0
        public void IsInside(double roiX, double roiY, double roiWidth, double roiHeight, double borderWidth, double borderHeight, bool isInside)
        {
            var rect = new RoixRect(roiX, roiY, roiWidth, roiHeight);
            var size = new RoixSize(borderWidth, borderHeight);
            var bp   = new RoixBorderRect(rect, size);

            bp.IsInsideBorder.Is(isInside);
            bp.IsOutsideBorder.Is(!isInside);
        }
Exemplo n.º 5
0
        public void ToRoix(double x, double y, double width, double height)
        {
            var      wr1 = new System.Windows.Rect(x, y, width, height);
            RoixRect rr1 = (RoixRect)wr1;

            rr1.X.Is(wr1.X);
            rr1.Y.Is(wr1.Y);
            rr1.Width.Is(wr1.Width);
            rr1.Height.Is(wr1.Height);
        }
Exemplo n.º 6
0
        public void ToWindows(double x, double y, double width, double height)
        {
            var rr1 = new RoixRect(x, y, width, height);

            System.Windows.Rect wr1 = (System.Windows.Rect)rr1;
            wr1.X.Is(rr1.X);
            wr1.Y.Is(rr1.Y);
            wr1.Width.Is(rr1.Width);
            wr1.Height.Is(rr1.Height);
        }
Exemplo n.º 7
0
        public void FromRoix(int x, int y, int width, int height)
        {
            var         rr1  = new RoixRect(x, y, width, height);
            RoixIntRect rir1 = rr1.ToRoixInt();

            rir1.X.Is((int)Math.Round(rr1.X));
            rir1.Y.Is((int)Math.Round(rr1.Y));
            rir1.Width.Is((int)Math.Round(rr1.Width));
            rir1.Height.Is((int)Math.Round(rr1.Height));
        }
Exemplo n.º 8
0
        public void ToRoix(int x, int y, int width, int height)
        {
            var      rir1 = new RoixIntRect(new RoixIntPoint(x, y), new RoixIntSize(width, height));
            RoixRect rr1  = (RoixRect)rir1;

            rr1.X.Is(rir1.X);
            rr1.Y.Is(rir1.Y);
            rr1.Width.Is(rir1.Width);
            rr1.Height.Is(rir1.Height);
        }
Exemplo n.º 9
0
        public void ToPointCollectionOk(double p1x, double p1y, double p2x, double p2y)
        {
            var point1 = new RoixPoint(p1x, p1y);
            var point2 = new RoixPoint(p2x, p2y);
            var rect   = new RoixRect(point1, point2);
            var src    = new[] { rect.TopLeft, rect.TopRight, rect.BottomRight, rect.BottomLeft };

            var pc = rect.ToPointCollection();

            pc.Select(p => (RoixPoint)p).Is(src);
        }
Exemplo n.º 10
0
        public void IsZero()
        {
            var rect = new RoixRect(1, 2, 3, 4);
            var size = new RoixSize(10, 10);

            new RoixBorderRect(rect, size).IsZero.IsFalse();
            new RoixBorderRect(rect, RoixSize.Zero).IsZero.IsFalse();
            new RoixBorderRect(RoixRect.Zero, size).IsZero.IsFalse();
            new RoixBorderRect(RoixRect.Zero, RoixSize.Zero).IsZero.IsTrue();
            RoixBorderRect.Zero.IsZero.IsTrue();
        }
Exemplo n.º 11
0
        public void GetClippedRoiBySizePriority_2_1_そもそも収まっててOK(
            double roiX, double roiY, double roiWidth, double roiHeight)
        {
            var border = new RoixSize(10, 10);
            var roi    = new RoixRect(roiX, roiY, roiWidth, roiHeight);
            var broi   = new RoixBorderRect(roi, border);

            var clippedRect = broi.GetClippedBorderRect(isPointPriority: false);

            clippedRect.Roi.Is(roi);
            clippedRect.Border.Is(broi.Border);
        }
Exemplo n.º 12
0
        public void ToPointCollectionZero()
        {
            var rect = new RoixRect(0, 0, 0, 0);
            var src  = new[] { rect.TopLeft, rect.TopRight, rect.BottomRight, rect.BottomLeft };

            var answerRect = new RoixRect(0, 0, 1, 1);  // Size 0 -> 1
            var answer     = new[] { answerRect.TopLeft, answerRect.TopRight, answerRect.BottomRight, answerRect.BottomLeft };

            var pc = rect.ToPointCollection();

            pc.Select(p => (RoixPoint)p).Is(answer);
        }
Exemplo n.º 13
0
        public void Deconstruct()
        {
            var srcRect   = new RoixRect(1, 2, 3, 4);
            var srcBorder = new RoixSize(10, 10);

            var(roi, border) = new RoixBorderRect(srcRect, srcBorder);
            roi.X.Is(srcRect.X);
            roi.Y.Is(srcRect.Y);
            roi.Width.Is(srcRect.Width);
            roi.Height.Is(srcRect.Height);
            border.Width.Is(srcBorder.Width);
            border.Height.Is(srcBorder.Height);
        }
Exemplo n.º 14
0
        public void Deconstruct()
        {
            var rect = new RoixRect(1, 2, 3, 4);

            var(point, size) = rect;
            point.X.Is(rect.Location.X);
            point.Y.Is(rect.Location.Y);
            size.Width.Is(rect.Size.Width);
            size.Height.Is(rect.Size.Height);

            var(p, s) = rect;
            p.Is(rect.Location);
            s.Is(rect.Size);
        }
Exemplo n.º 15
0
        public void GetClippedRoiBySizePriority_2_2_枠の食み出しを位置制限してOK(
            double roiX, double roiY, double roiWidth, double roiHeight, double ansX, double ansY)
        {
            var border   = new RoixSize(10, 10);
            var roi      = new RoixRect(roiX, roiY, roiWidth, roiHeight);
            var ansPoint = new RoixPoint(ansX, ansY);

            var broi        = new RoixBorderRect(roi, border);
            var clippedRect = broi.GetClippedBorderRect(isPointPriority: false);

            clippedRect.Roi.TopLeft.Is(ansPoint);
            clippedRect.Roi.Size.Is(roi.Size);
            clippedRect.Border.Is(broi.Border);
        }
Exemplo n.º 16
0
        [InlineData(10, 10, 1, 1, 0, 0)]  // Size=Zero (OK)
        public void GetClippedRoiByPointPriority_1_2_枠の食み出しをサイズ制限してOK(
            double roiX, double roiY, double roiWidth, double roiHeight, double ansWidth, double ansHeight)
        {
            var border  = new RoixSize(10, 10);
            var roi     = new RoixRect(roiX, roiY, roiWidth, roiHeight);
            var ansSize = new RoixSize(ansWidth, ansHeight);

            var broi        = new RoixBorderRect(roi, border);
            var clippedRect = broi.GetClippedBorderRect(isPointPriority: true);

            clippedRect.Roi.Size.Is(ansSize);
            clippedRect.Roi.TopLeft.Is(roi.TopLeft);
            clippedRect.Border.Is(broi.Border);
        }
Exemplo n.º 17
0
        public void Equal()
        {
            var rect   = new RoixRect(1, 2, 3, 4);
            var border = new RoixSize(10, 10);

            var br1 = new RoixBorderRect(rect, border);
            var br2 = new RoixBorderRect(rect, border);

            br1.Equals(br2).IsTrue();
            (br1 == br2).IsTrue();
            (br1 != br2).IsFalse();

            var obj2 = (object)br2;

            br1.Equals(obj2).IsTrue();
        }
Exemplo n.º 18
0
        public void Equal()
        {
            double x = 1, y = 2, w = 3, h = 4;
            var    rect1 = new RoixRect(x, y, w, h);
            var    rect2 = new RoixRect(x, y, w, h);

            rect1.Equals(rect2).IsTrue();
            (rect1 == rect2).IsTrue();
            (rect1 != rect2).IsFalse();

            var obj2 = (object)rect2;

            rect1.Equals(obj2).IsTrue();

            rect1 = RoixRect.Empty;
            rect2 = RoixRect.Empty;
            rect1.Equals(rect2).IsTrue();
            (rect1 == rect2).IsTrue();
            (rect1 != rect2).IsFalse();
        }
Exemplo n.º 19
0
        public void Properties(double x, double y, double width, double height)
        {
            var point = new RoixPoint(x, y);
            var size  = new RoixSize(width, height);
            var r     = new RoixRect(point, size);

            r.X.Is(r.Location.X);
            r.Y.Is(r.Location.Y);
            r.Width.Is(r.Size.Width);
            r.Height.Is(r.Size.Height);

            r.Left.Is(r.X);
            r.Right.Is(r.X + r.Width);
            r.Top.Is(r.Y);
            r.Bottom.Is(r.Y + r.Height);

            r.TopLeft.Is(new(r.Left, r.Top));
            r.TopRight.Is(new(r.Right, r.Top));
            r.BottomLeft.Is(new(r.Left, r.Bottom));
            r.BottomRight.Is(new(r.Right, r.Bottom));
        }