當前位置: 首頁>>代碼示例>>C#>>正文


C# Rect.Intersects方法代碼示例

本文整理匯總了C#中System.Drawing.Rect.Intersects方法的典型用法代碼示例。如果您正苦於以下問題:C# Rect.Intersects方法的具體用法?C# Rect.Intersects怎麽用?C# Rect.Intersects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Drawing.Rect的用法示例。


在下文中一共展示了Rect.Intersects方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: PickVertices

        private SelVertex[] PickVertices(int x, int y, int w = 0, int h = 0)
        {
            List<SelVertex> result = new List<SelVertex>();
            if (this.allObjSel == null)
                return result.ToArray();
            IEnumerable<SelPolyShape> shapes = this.allObjSel.OfType<SelPolyShape>();

            foreach (SelPolyShape shape in shapes)
            {
                PolyShapeInfo polygon = shape.ActualObject as PolyShapeInfo;
                if (polygon == null)
                    continue;

                Transform transform = polygon.Parent.GameObj.Transform;
                if (polygon.Parent == null || polygon.Parent.GameObj == null || polygon.Parent.GameObj.Transform == null)
                    continue;

                Vector3 worldCoord = this.GetSpaceCoord(new Vector3(x, y, transform.Pos.Z));
                float scale = GetScaleAtZ(transform.Pos.Z);
                Rect selectionRect = new Rect(worldCoord.X, worldCoord.Y, w/scale, h/scale);

                float size = VertexSize/scale;

                for (int i = 0; i < polygon.Vertices.Length; i++)
                {

                    Vector2 vertexPosition = transform.GetWorldPoint(polygon.Vertices[i]);
                    Rect vertexRect = new Rect(vertexPosition.X - size/2, vertexPosition.Y - size/2, size, size);

                    if (selectionRect.Intersects(vertexRect))
                    {
                        result.Add(new SelVertex(polygon, i));
                    }
                }
            }
            return result.ToArray();
        }
開發者ID:BraveSirAndrew,項目名稱:duality,代碼行數:37,代碼來源:RigidBodyEditorCamViewState.cs


注:本文中的System.Drawing.Rect.Intersects方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。