当前位置: 首页>>代码示例>>C#>>正文


C# BoundingRectangle类代码示例

本文整理汇总了C#中BoundingRectangle的典型用法代码示例。如果您正苦于以下问题:C# BoundingRectangle类的具体用法?C# BoundingRectangle怎么用?C# BoundingRectangle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BoundingRectangle类属于命名空间,在下文中一共展示了BoundingRectangle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestHoldValue

        public void TestHoldValue()
        {
            BoundingRectangle boundingRectangle0 = new BoundingRectangle();
            Assert.AreEqual(boundingRectangle0.Left, 0);
            Assert.AreEqual(boundingRectangle0.Bottom, 0);
            Assert.AreEqual(boundingRectangle0.Right, 0);
            Assert.AreEqual(boundingRectangle0.Top, 0);
            Assert.AreEqual(boundingRectangle0.Height, 0);
            Assert.AreEqual(boundingRectangle0.Width, 0);

            Assert.AreEqual(BoundingRectangle.Empty.Left, 0);
            Assert.AreEqual(BoundingRectangle.Empty.Bottom, 0);
            Assert.AreEqual(BoundingRectangle.Empty.Right, 0);
            Assert.AreEqual(BoundingRectangle.Empty.Top, 0);
            Assert.AreEqual(BoundingRectangle.Empty.Height, 0);
            Assert.AreEqual(BoundingRectangle.Empty.Width, 0);

            BoundingRectangle boundingRectangle1 = new BoundingRectangle(1, 2, 3, 4);
            Assert.AreEqual(boundingRectangle1.Left, 1);
            Assert.AreEqual(boundingRectangle1.Bottom, 2);
            Assert.AreEqual(boundingRectangle1.Right, 3);
            Assert.AreEqual(boundingRectangle1.Top, 4);
            Assert.AreEqual(boundingRectangle1.Height, 2);
            Assert.AreEqual(boundingRectangle1.Width, 2);
        }
开发者ID:AnalyticalGraphicsInc,项目名称:czml-writer,代码行数:25,代码来源:TestBoundingRectangle.cs

示例2: RenderRaster

        public void RenderRaster(Graphics g, Bitmap bitmap, RasterStyle style, BoundingRectangle viewBox, BoundingRectangle bitmapBounds, double scaleFactor)
        {
            ICoordinate minPoint = bitmapBounds.Min;
            ICoordinate maxPoint = bitmapBounds.Max;

            if (viewBox.Intersects(bitmapBounds))
            {
                Point minP = new Point((int)((minPoint.X - viewBox.MinX) * scaleFactor),
                                       (int)((viewBox.MaxY - minPoint.Y) * scaleFactor));

                Point maxP = new Point((int)((maxPoint.X - viewBox.MinX) * scaleFactor),
                           (int)((viewBox.MaxY - maxPoint.Y) * scaleFactor));

                g.InterpolationMode = style.InterpolationMode;

                Rectangle r = new Rectangle(minP.X, maxP.Y, maxP.X - minP.X, minP.Y - maxP.Y);

                using (ImageAttributes imageAttributes = new ImageAttributes())
                {
                    imageAttributes.SetColorMatrix(style.ColorAdjustmentMatrix,
                                                   ColorMatrixFlag.Default,
                                                   ColorAdjustType.Bitmap);

                    g.DrawImage(bitmap, r, 0, 0, bitmap.Width, bitmap.Height,
                                GraphicsUnit.Pixel, imageAttributes);
                }
            }
        }
开发者ID:gkrsu,项目名称:maparound.core,代码行数:28,代码来源:RasterRendering.cs

示例3: Read

        /// <summary>
        /// Читает запись представляющую коллекцию точек.
        /// </summary>
        /// <param name="file">Входной поток</param>
        /// <param name="record">Запись Shape-файла в которую будет помещена прочитанная информация</param>
        /// <param name="bounds">Ограничивающий прямоугольник, с которым должен пересекаться ограничивающий прямоугольник записи</param>
        public override bool Read(Stream file, BoundingRectangle bounds, ShapeFileRecord record)
        {
            try
            {
                record.MinX = file.ReadDouble();// ShapeFile.ReadDouble64_LE(stream);
                record.MinY = file.ReadDouble();// ShapeFile.ReadDouble64_LE(stream);
                record.MaxX = file.ReadDouble();// ShapeFile.ReadDouble64_LE(stream);
                record.MaxY = file.ReadDouble();// ShapeFile.ReadDouble64_LE(stream);

                int numPoints = file.ReadInt32();// ShapeFile.ReadInt32_LE(stream);

                if (!ShapeHandler.IsRecordInView(bounds, record))
                {
                    file.Seek((long)numPoints * 16, SeekOrigin.Current);
                    return false;
                }

                for (int i = 0; i < numPoints; i++)
                {
                    ICoordinate p =
                        PlanimetryEnvironment.NewCoordinate(
                        file.ReadDouble(),//ShapeFile.ReadDouble64_LE(stream),
                        file.ReadDouble());//ShapeFile.ReadDouble64_LE(stream));

                    record.Points.Add(p);
                }

                return true;
            }
            catch { throw; }
        }
开发者ID:gkrsu,项目名称:maparound.core,代码行数:37,代码来源:MultiPointHandler.cs

示例4: WriteBoundingRectangle

 /// <summary>
 /// Writes a <see cref="BoundingRectangle"/> value as an array in X, Y, Width, Height order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="value">The value to write.</param>
 public static void WriteBoundingRectangle(CesiumOutputStream output, BoundingRectangle value)
 {
     output.WriteStartSequence();
     output.WriteValue(value.Left);
     output.WriteValue(value.Bottom);
     output.WriteValue(value.Width);
     output.WriteValue(value.Height);
     output.WriteEndSequence();
 }
开发者ID:AnalyticalGraphicsInc,项目名称:czml-writer,代码行数:14,代码来源:CesiumWritingHelper.cs

示例5: Init

 public void Init()
 {
     circle1 = new BoundingCircle(Vector2D.YAxis, 2);
     circle2 = new BoundingCircle(Vector2D.XAxis, 2);
     rect1 = BoundingRectangle.FromCircle(circle1);
     circle3 = BoundingCircle.FromRectangle(rect1);
     rect2 = BoundingRectangle.FromCircle(circle3);
     polygon1 = new BoundingPolygon(rect1.Corners());
 }
开发者ID:bsvercl,项目名称:physics2d,代码行数:9,代码来源:BoundingCircleTest.cs

示例6: TestGetHashCode

        public void TestGetHashCode()
        {
            BoundingRectangle boundingRectangle1 = new BoundingRectangle(1, 2, 3, 4);
            BoundingRectangle boundingRectangle2 = new BoundingRectangle(1, 2, 3, 4);
            BoundingRectangle boundingRectangle3 = new BoundingRectangle(2, 3, 4, 5);

            Assert.AreEqual(boundingRectangle1.GetHashCode(), boundingRectangle2.GetHashCode());
            Assert.AreNotEqual(boundingRectangle1.GetHashCode(), boundingRectangle3.GetHashCode());
        }
开发者ID:AnalyticalGraphicsInc,项目名称:czml-writer,代码行数:9,代码来源:TestBoundingRectangle.cs

示例7: TestEqualsEpsilon

        public void TestEqualsEpsilon()
        {
            BoundingRectangle boundingRectangle = new BoundingRectangle(1000, 2000, 3000, 4000);
            BoundingRectangle similarBoundingRectangle = new BoundingRectangle(1010, 2010, 3010, 4010);

            Assert.IsTrue(boundingRectangle.EqualsEpsilon(similarBoundingRectangle, 1000));
            Assert.IsTrue(boundingRectangle.EqualsEpsilon(similarBoundingRectangle, 100));
            Assert.IsTrue(boundingRectangle.EqualsEpsilon(similarBoundingRectangle, 10));
            Assert.IsFalse(boundingRectangle.EqualsEpsilon(similarBoundingRectangle, 1));
        }
开发者ID:AnalyticalGraphicsInc,项目名称:czml-writer,代码行数:10,代码来源:TestBoundingRectangle.cs

示例8: IsRecordInView

 /// <summary>Проверка записи на нахождение границ фигуры в указанной области</summary>
 /// <param name="bounds">Границы области</param>
 /// <param name="record">Запись shape-файла</param>
 /// <returns></returns>
 protected static bool IsRecordInView(BoundingRectangle bounds, ShapeFileRecord record)
 {
     if (bounds != null && !bounds.IsEmpty())
     {
         if (!bounds.Intersects(
             new BoundingRectangle(PlanimetryEnvironment.NewCoordinate(record.MinX, record.MinY),
                                   PlanimetryEnvironment.NewCoordinate(record.MaxX, record.MaxY))))
             return false;
     }
     return true;
 }
开发者ID:gkrsu,项目名称:maparound.core,代码行数:15,代码来源:ShapeHandler.cs

示例9: ContainsPoint

 public void ContainsPoint()
 {
     BoundingRectangle rect = new BoundingRectangle(0, 0, 2, 2);
     Assert.AreEqual(ContainmentType.Contains, rect.Contains(new Vector2D(1, 1)), "1");
     Assert.AreEqual(ContainmentType.Contains, rect.Contains(new Vector2D(2, 2)), "2");
     Assert.AreEqual(ContainmentType.Contains, rect.Contains(new Vector2D(0, 2)), "3");
     Assert.AreEqual(ContainmentType.Contains, rect.Contains(new Vector2D(0, 0)), "4");
     Assert.AreEqual(ContainmentType.Disjoint, rect.Contains(new Vector2D(2, 3)), "5");
     Assert.AreEqual(ContainmentType.Disjoint, rect.Contains(new Vector2D(-1, 0)), "6");
     Assert.AreEqual(ContainmentType.Disjoint, rect.Contains(new Vector2D(-.0001f, 0)), "7");
     Assert.AreEqual(ContainmentType.Disjoint, rect.Contains(new Vector2D(3, 1)), "8");
     Assert.AreEqual(ContainmentType.Disjoint, rect.Contains(new Vector2D(1, -1)), "9");
 }
开发者ID:bsvercl,项目名称:physics2d,代码行数:13,代码来源:BoundingRectangleTest.cs

示例10: Open

        protected override void Open()
        {
            dispose += DemoHelper.BasicDemoSetup(DemoInfo);


            Scene.Engine.AddLogic(new LineFluidLogic(new Line(0, -1, -400), 1.95f, .02f, new Vector2D(0, 0), new Lifespan()));
            Scene.Engine.AddLogic(new GravityField(new Vector2D(0, 1000), new Lifespan()));

            Rectangle rect1 = Viewport.Rectangle;


            BoundingRectangle rect = new BoundingRectangle(rect1.Left, rect1.Top, rect1.Right, rect1.Bottom);
            rect.Min.X -= 75;
            rect.Min.Y -= 75;
            rect.Max.X += 75;
            rect.Max.Y += 75;
            DemoHelper.AddShell(DemoInfo, rect, 100, Scalar.PositiveInfinity).ForEach(delegate(Body b) { b.IgnoresGravity = true; });

            DemoHelper.AddRagDoll(DemoInfo, new Vector2D(340, 300));
            DemoHelper.AddRagDoll(DemoInfo, new Vector2D(640, 300));
            IShape shape = ShapeFactory.CreateSprite(Cache<SurfacePolygons>.GetItem("fighter.png"), 3, 16, 4);

            DemoHelper.AddShape(DemoInfo, shape, 200, new ALVector2D(0, new Vector2D(200, 300)));
            DemoHelper.AddShape(DemoInfo, shape, 100, new ALVector2D(0, new Vector2D(500, 300)));
            DemoHelper.AddRectangle(DemoInfo, 20, 200, 25 / 5, new ALVector2D(0, 600, 600));
            DemoHelper.AddRectangle(DemoInfo, 20, 200, 25 / 5, new ALVector2D(0, 600, 620));
            DemoHelper.AddRectangle(DemoInfo, 50, 100, 50, new ALVector2D(0, 200, 400));
            DemoHelper.AddRectangle(DemoInfo, 50, 100, 50, new ALVector2D(0, 400, 200));

            Vector2D[] waterVertexes = new Vector2D[4]
            {
                 new Vector2D(-10, 400),
                 new Vector2D(10000, 400),
                 new Vector2D(10000, 1000),
                 new Vector2D(-10, 1000)
            };
            ScalarColor3[] waterColor = new ScalarColor3[4]
            {
                new ScalarColor3(0,0,1),
                new ScalarColor3(0,0,1),
                new ScalarColor3(0,0,1),
                new ScalarColor3(0,0,1)
            };
            Colored3VertexesDrawable drawable = new Colored3VertexesDrawable(Gl.GL_QUADS, waterVertexes, waterColor);

            Graphic graphic = new Graphic(drawable, Matrix2x3.Identity, new Lifespan());
            graphic.ZOrder = -1;
            Scene.AddGraphic(graphic);
        }
开发者ID:timdetering,项目名称:Physics2D.Net,代码行数:49,代码来源:FluidDragBuoyancyDemo.cs

示例11: TransformBoundingRectangle

        /// <summary>
        /// Transforms coordinates of the bounding rectangle.
        /// </summary>
        /// <param name="box">Rectangle to transform</param>
        /// <param name="transform">The transformation to apply</param>
        /// <returns>The transformed rectangle</returns>
        public static BoundingRectangle TransformBoundingRectangle(BoundingRectangle box, IMathTransform transform)
        {
            if (box == null)
                return null;
            ICoordinate[] corners = new ICoordinate[4];
            corners[0] = PlanimetryEnvironment.NewCoordinate(transform.Transform(box.Min.Values()));
            corners[1] = PlanimetryEnvironment.NewCoordinate(transform.Transform(box.Max.Values()));
            corners[2] = PlanimetryEnvironment.NewCoordinate(transform.Transform(PlanimetryEnvironment.NewCoordinate(box.MinX, box.MaxY).Values()));
            corners[3] = PlanimetryEnvironment.NewCoordinate(transform.Transform(PlanimetryEnvironment.NewCoordinate(box.MaxX, box.MinY).Values())); 

            BoundingRectangle result = new BoundingRectangle();
            for (int i = 0; i < 4; i++)
                result.Join(corners[i]);
            return result;
        }
开发者ID:gkrsu,项目名称:maparound.core,代码行数:21,代码来源:Transformers.cs

示例12: EqualityTest

        public void EqualityTest()
        {
            BoundingRectangle boundingRectangle = new BoundingRectangle(1, 2, 3, 4);
            BoundingRectangle sameBoundingRectangle = new BoundingRectangle(1, 2, 3, 4);
            BoundingRectangle diffBoundingRectangle = new BoundingRectangle(2, 3, 4, 5);

            Assert.IsTrue(boundingRectangle.Equals(sameBoundingRectangle));
            Assert.IsFalse(boundingRectangle.Equals(diffBoundingRectangle));
            Assert.IsTrue(boundingRectangle == sameBoundingRectangle);
            Assert.IsTrue(boundingRectangle != diffBoundingRectangle);

            object nonBoundingRectangleObject = new object();
            Assert.IsFalse(boundingRectangle.Equals(nonBoundingRectangleObject));

            object boundingRectangleObject = boundingRectangle;
            Assert.IsTrue(boundingRectangle.Equals(boundingRectangleObject));
        }
开发者ID:AnalyticalGraphicsInc,项目名称:czml-writer,代码行数:17,代码来源:TestBoundingRectangle.cs

示例13: Read

        /// <summary>
        /// Читает запись представляющую точку.
        /// </summary>
        /// <param name="file">Входной поток</param>
        /// <param name="record">Запись Shape-файла в которую будет помещена прочитанная информация</param>
        /// <param name="bounds">Ограничивающий прямоугольник, с которым должен пересекаться ограничивающий прямоугольник записи</param>
        public override bool Read(/*BigEndianBinaryReader*/Stream file, BoundingRectangle bounds, ShapeFileRecord record)
        {

            ICoordinate p = PlanimetryEnvironment.NewCoordinate(0, 0);
            p.X = file.ReadDouble();// ShapeFile.ReadDouble64_LE(stream);
            p.Y = file.ReadDouble();// ShapeFile.ReadDouble64_LE(stream);

            if (bounds != null && !bounds.IsEmpty() && !bounds.ContainsPoint(p))
                return false;

            record.Points.Add(p);

            record.MinX = p.X;
            record.MinY = p.Y;
            record.MaxX = record.MinX;
            record.MaxY = record.MinY;

            return true;
        }
开发者ID:gkrsu,项目名称:maparound.core,代码行数:25,代码来源:PointHandler.cs

示例14: Open

        protected override void Open()
        {
            dispose += DemoHelper.BasicDemoSetup(DemoInfo);

            Rectangle rect1 = Viewport.Rectangle;
            BoundingRectangle rect = new BoundingRectangle(rect1.Left, rect1.Top, rect1.Right, rect1.Bottom);
            rect.Min.X -= 75;
            rect.Min.Y -= 75;
            rect.Max.X += 75;
            rect.Max.Y += 75;
            DemoHelper.AddShell(DemoInfo, rect, 100, Scalar.PositiveInfinity).ForEach(delegate(Body b) { b.IgnoresGravity = true; });
            rect.Min.X += 110;
            rect.Min.Y += 110;
            rect.Max.X -= 110;
            rect.Max.Y -= 110;
            IShape shape = ShapeFactory.CreateColoredCircle(3, 7);
            DemoHelper.AddGrid(DemoInfo, shape, 40,
                rect,
                1, 1).ForEach(delegate(Body b) { b.State.Velocity.Linear = new Vector2D(DemoHelper.Rand.Next(-100, 100), DemoHelper.Rand.Next(-100, 100)); });
        }
开发者ID:bsvercl,项目名称:physics2d,代码行数:20,代码来源:CirclesContainedStressDemo.cs

示例15: GetBoundsFromPath

        public static BoundingRectangle GetBoundsFromPath(List<PathInfo> list)
        {
            // Only support simple paths
            if (list.First().segmentType != SegmentType.Move)
            {
                return null;
            }
            if (list.Last().segmentType != SegmentType.Close)
            {
                return null;
            }
            if (list.Skip(1).Take(list.Count - 2).Any(p => p.segmentType != SegmentType.Line))
            {
                return null;
            }

            BoundingRectangle ret = new BoundingRectangle();
            foreach (var i in list.Take(list.Count - 1))
            {
                ret.UpdateBounds(i.point);
            }

            return ret;
        }
开发者ID:jcookems,项目名称:freezing-ninja,代码行数:24,代码来源:BoundingRectangle.cs


注:本文中的BoundingRectangle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。