コード例 #1
0
ファイル: RoixRectTest.cs プロジェクト: hsytkm/Roix
        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);
        }
コード例 #2
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);
        }
コード例 #3
0
ファイル: RoixSizeTest.cs プロジェクト: hsytkm/Roix
        public void Ctor(double w, double h)
        {
            var size = new RoixSize(w, h);

            size.IsEmpty.IsFalse();
            size.Width.Is(w);
            size.Height.Is(h);
        }
コード例 #4
0
ファイル: RoixPointTest.cs プロジェクト: hsytkm/Roix
        public void IsInside(double x, double y, bool isInside)
        {
            var canvs = new RoixSize(10, 10);
            var ip    = new RoixPoint(x, y);

            ip.IsInside(canvs).Is(isInside);
            ip.IsOutside(canvs).Is(!isInside);
        }
コード例 #5
0
ファイル: RoixRectTest.cs プロジェクト: hsytkm/Roix
        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);
        }
コード例 #6
0
ファイル: RoixSizeTest.cs プロジェクト: hsytkm/Roix
        public void Deconstruct()
        {
            var size = new RoixSize(1.1, 2.2);

            var(w, h) = size;
            w.Is(size.Width);
            h.Is(size.Height);
        }
コード例 #7
0
ファイル: RoixSizeTest.cs プロジェクト: hsytkm/Roix
        public void IsInside(double srcWidth, double srcHeight, double borderWidth, double borderHeight, bool isInside)
        {
            var src    = new RoixSize(srcWidth, srcHeight);
            var border = new RoixSize(borderWidth, borderHeight);

            src.IsInside(border).Is(isInside);
            src.IsOutside(border).Is(!isInside);
        }
コード例 #8
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);
        }
コード例 #9
0
        public void IsInside(double width1, double height1, double width2, double height2, bool isInside)
        {
            var size1 = new RoixSize(width1, height1);
            var size2 = new RoixSize(width2, height2);
            var bs1   = new RoixBorderSize(size1, size2);

            bs1.IsInsideBorder.Is(isInside);
            bs1.IsOutsideBorder.Is(!isInside);
        }
コード例 #10
0
ファイル: RoixGaugePointTest.cs プロジェクト: hsytkm/Roix
        public void Deconstruct()
        {
            var point = new RoixPoint(1.1, 2.2);
            var size  = new RoixSize(3.3, 4.4);
            var bp    = new RoixBorderPoint(point, size);

            var(roi, border) = bp;
            roi.Is(point);
            border.Is(size);
        }
コード例 #11
0
ファイル: RoixGaugeVectorTest.cs プロジェクト: hsytkm/Roix
        public void Deconstruct()
        {
            var vector = new RoixVector(1.1, 2.2);
            var size   = new RoixSize(3.3, 4.4);
            var bv     = new RoixBorderVector(vector, size);

            var(vec, border) = bv;
            vec.Is(vector);
            border.Is(size);
        }
コード例 #12
0
        public void Deconstruct()
        {
            var size1 = new RoixSize(1, 2);
            var size2 = new RoixSize(11, 22);
            var bs1   = new RoixBorderSize(size1, size2);

            var(size, border) = bs1;
            size.Is(size1);
            border.Is(size2);
        }
コード例 #13
0
ファイル: RoixIntSizeTest.cs プロジェクト: hsytkm/Roix
        public void ToRoix()
        {
            int      x = 1, y = 2;
            var      ris1 = new RoixIntSize(x, y);
            RoixSize rs1  = (RoixSize)ris1;

            rs1.IsEmpty.IsFalse();
            rs1.Width.Is(ris1.Width);
            rs1.Height.Is(ris1.Height);
        }
コード例 #14
0
        public void IsZero()
        {
            var size1 = new RoixSize(1, 0);
            var size2 = new RoixSize(10, 10);

            new RoixBorderSize(size1, size2).IsZero.IsFalse();
            new RoixBorderSize(size1, RoixSize.Zero).IsZero.IsFalse();
            new RoixBorderSize(RoixSize.Zero, size2).IsZero.IsFalse();
            new RoixBorderSize(RoixSize.Zero, RoixSize.Zero).IsZero.IsTrue();
            RoixBorderSize.Zero.IsZero.IsTrue();
        }
コード例 #15
0
ファイル: RoixGaugeVectorTest.cs プロジェクト: hsytkm/Roix
        public void IsZero()
        {
            var vector = new RoixVector(1, 0);
            var size   = new RoixSize(10, 10);

            new RoixBorderVector(vector, size).IsZero.IsFalse();
            new RoixBorderVector(vector, RoixSize.Zero).IsZero.IsFalse();
            new RoixBorderVector(RoixVector.Zero, size).IsZero.IsFalse();
            new RoixBorderVector(RoixVector.Zero, RoixSize.Zero).IsZero.IsTrue();
            RoixBorderVector.Zero.IsZero.IsTrue();
        }
コード例 #16
0
ファイル: RoixIntSizeTest.cs プロジェクト: hsytkm/Roix
        public void FromRoix()
        {
            double      x = 1.1, y = 2.2;
            var         rs1  = new RoixSize(x, y);
            RoixIntSize ris1 = rs1.ToRoixInt();

            ris1.Width.Is((int)Math.Round(rs1.Width));
            ris1.Height.Is((int)Math.Round(rs1.Height));

            Assert.Throws <ArgumentException>(() => RoixSize.Empty.ToRoixInt());
        }
コード例 #17
0
ファイル: RoixGaugePointTest.cs プロジェクト: hsytkm/Roix
        public void IsZero()
        {
            var point = new RoixPoint(1, 0);
            var size  = new RoixSize(10, 10);

            new RoixBorderPoint(point, size).IsZero.IsFalse();
            new RoixBorderPoint(point, RoixSize.Zero).IsZero.IsFalse();
            new RoixBorderPoint(RoixPoint.Zero, size).IsZero.IsFalse();
            new RoixBorderPoint(RoixPoint.Zero, RoixSize.Zero).IsZero.IsTrue();
            RoixBorderPoint.Zero.IsZero.IsTrue();
        }
コード例 #18
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();
        }
コード例 #19
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);
        }
コード例 #20
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);
        }
コード例 #21
0
        public void Ctor(double width1, double height1, double width2, double height2)
        {
            var size1 = new RoixSize(width1, height1);
            var size2 = new RoixSize(width2, height2);
            var bs1   = new RoixBorderSize(size1, size2);

            bs1.Size.Width.Is(width1);
            bs1.Size.Height.Is(height1);
            bs1.Border.Width.Is(width2);
            bs1.Border.Height.Is(height2);

            new RoixBorderSize(size1, RoixSize.Zero);     //OK
        }
コード例 #22
0
ファイル: RoixGaugeVectorTest.cs プロジェクト: hsytkm/Roix
        public void ConvertToNewBorder(double ratio)
        {
            var vector = new RoixVector(10, 20);
            var size   = new RoixSize(100, 100);
            var bv1    = new RoixBorderVector(vector, size);

            var newSize = new RoixSize(size.Width * ratio, size.Height * ratio);
            var bv2     = bv1.ConvertToNewBorder(newSize);

            bv2.Vector.Is(new RoixVector(vector.X * ratio, vector.Y * ratio));

            Assert.Throws <ArgumentException>(() => bv1.ConvertToNewBorder(RoixSize.Empty));
            Assert.Throws <ArgumentException>(() => bv1.ConvertToNewBorder(new RoixSize(0, 0)));
        }
コード例 #23
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);
        }
コード例 #24
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);
        }
コード例 #25
0
ファイル: RoixSizeTest.cs プロジェクト: hsytkm/Roix
        public void Operator��Z(double ratio)
        {
            var src = new RoixSize(100, 200);

            var size1 = src * ratio;

            size1.Width.Is(src.Width * ratio);
            size1.Height.Is(src.Height * ratio);

            (src * 0).Is(RoixSize.Zero);
            (RoixSize.Zero * ratio).Is(RoixSize.Zero);
            (RoixSize.Empty * ratio).Is(RoixSize.Empty);
            Assert.Throws <ArgumentException>(() => src / -ratio);
        }
コード例 #26
0
ファイル: RoixSizeTest.cs プロジェクト: hsytkm/Roix
        public void Operator���Z(double ratio)
        {
            var src = new RoixSize(100, 200);

            var size1 = src / ratio;

            size1.Width.Is(src.Width / ratio);
            size1.Height.Is(src.Height / ratio);

            (RoixSize.Zero / ratio).Is(RoixSize.Zero);
            (RoixSize.Empty / ratio).Is(RoixSize.Empty);
            Assert.Throws <ArgumentException>(() => src / -ratio);
            Assert.Throws <DivideByZeroException>(() => src / 0);
        }
コード例 #27
0
        public void ConvertToNewBorder(double ratio)
        {
            var size   = new RoixSize(10, 20);
            var border = new RoixSize(100, 100);
            var bs1    = new RoixBorderSize(size, border);

            var newBorder = new RoixSize(border.Width * ratio, border.Height * ratio);
            var bs2       = bs1.ConvertToNewBorder(newBorder);

            bs2.Size.Is(new RoixSize(size.Width * ratio, size.Height * ratio));

            Assert.Throws <ArgumentException>(() => bs1.ConvertToNewBorder(RoixSize.Empty));
            Assert.Throws <ArgumentException>(() => bs1.ConvertToNewBorder(new RoixSize(0, 0)));
        }
コード例 #28
0
ファイル: RoixGaugePointTest.cs プロジェクト: hsytkm/Roix
        public void ConvertToNewBorder(double ratio)
        {
            var point = new RoixPoint(10, 20);
            var size  = new RoixSize(100, 100);
            var bp1   = new RoixBorderPoint(point, size);

            var newSize = new RoixSize(size.Width * ratio, size.Height * ratio);
            var bp2     = bp1.ConvertToNewBorder(newSize);

            bp2.Point.Is(new RoixPoint(point.X * ratio, point.Y * ratio));

            Assert.Throws <ArgumentException>(() => bp1.ConvertToNewBorder(RoixSize.Empty));
            Assert.Throws <ArgumentException>(() => bp1.ConvertToNewBorder(new RoixSize(0, 0)));
        }
コード例 #29
0
        public void Equal()
        {
            var size1 = new RoixSize(1, 2);
            var size2 = new RoixSize(11, 22);
            var bs1   = new RoixBorderSize(size1, size2);
            var bs2   = new RoixBorderSize(size1, size2);

            bs1.Equals(bs2).IsTrue();
            (bs1 == bs2).IsTrue();
            (bs1 != bs2).IsFalse();

            var obj2 = (object)bs2;

            bs1.Equals(obj2).IsTrue();
        }
コード例 #30
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();
        }