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


C# Stroke.GetBoundingBox方法代码示例

本文整理汇总了C#中Stroke.GetBoundingBox方法的典型用法代码示例。如果您正苦于以下问题:C# Stroke.GetBoundingBox方法的具体用法?C# Stroke.GetBoundingBox怎么用?C# Stroke.GetBoundingBox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Stroke的用法示例。


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

示例1: Node

 public Node(Stroke stroke)
 {
     this.stroke = stroke;
     this.id = stroke.Id;
     Rectangle r = stroke.GetBoundingBox();
     //Determine whether this node is a rectangle or not
     isRect = r.Width*Math.PI < StrokeManager.StrokeLength(stroke);
     centerPoint = new Point(r.X + r.Width/2, r.Y + r.Height/2);
     fillColor = DEFAULT;
     edges = new Edges();
     textColor = TEXT_DEFAULT;
     text = "";
     //Set initial distance to infinity (max int)
     distance = Int32.MaxValue;
 }
开发者ID:mdayaram,项目名称:graph-animator,代码行数:15,代码来源:Node.cs

示例2: FitsCircleProperties

 /* Returns true if the stroke resembles a circle given a tolerance.
  * Accomplishes this by taking the perimeter of a circle that
  * would be bounded in the area the stroke is bounded and
  * comparing it to the length of the stroke.
  */
 public static bool FitsCircleProperties(Stroke e, double tolerance)
 {
     if(e == null) return false;
     Rectangle r = e.GetBoundingBox();
     double radius = StrokeManager.Avg(r.Height,r.Width) / 2.0;
     if(radius < MIN_WIDTH/2) return false;
     double perimeter = 2.0*radius*Math.PI;
     Point[] points = e.GetPoints();
     double strokeLength = StrokeManager.StrokeLength(e);
     return Math.Abs(perimeter-strokeLength) <= tolerance;
 }
开发者ID:mdayaram,项目名称:graph-animator,代码行数:16,代码来源:StrokeManager.cs

示例3: makeRect

 /* Makes a perfectly rectangular stroke out of the
  * given stroke by using its bounding area.
  */
 public static Stroke makeRect(InkOverlay i, Stroke s)
 {
     Rectangle r = s.GetBoundingBox();
     Point[] points = new Point[5];
     points[0] = new Point(r.X, r.Y + r.Height);
     points[1] = new Point(r.X + r.Width, points[0].Y);
     points[2] = new Point(points[1].X, r.Y);
     points[3] = new Point(points[0].X, points[2].Y);
     points[4] = new Point(points[0].X, points[0].Y);
     Stroke rectangle = s.Ink.CreateStroke(points);
     rectangle.DrawingAttributes = i.DefaultDrawingAttributes;
     return rectangle;
 }
开发者ID:mdayaram,项目名称:graph-animator,代码行数:16,代码来源:StrokeManager.cs

示例4: makeCircle

        /* Makes a perfectly circular stroke given another
         * stroke by using its bounding area as a reference for
         * radius.
         */
        public static Stroke makeCircle(InkOverlay i, Stroke s)
        {
            Point[] points = new Point[101];
            double theta = 2*Math.PI/100.0;
            Rectangle r = s.GetBoundingBox();
            double radius = (r.Width + r.Height)/4.0;
            int deltaX = r.X + r.Width/2;
            int deltaY = r.Y + r.Height/2;
            for(int k = 0; k < points.Length - 1; k++)
            {
                int x = (int) (radius*Math.Cos(k*theta) + deltaX);
                int y = (int) (radius*Math.Sin(k*theta) + deltaY);

                points[k] = new Point(x, y);
            }
            //Last point is the first point, i.e. it is a closed stroke
            points[100] = new Point(points[0].X, points[0].Y);
            Stroke circle = s.Ink.CreateStroke(points);
            circle.DrawingAttributes = i.DefaultDrawingAttributes;
            return circle;
        }
开发者ID:mdayaram,项目名称:graph-animator,代码行数:25,代码来源:StrokeManager.cs

示例5: isScratchOut

 /* Determines whether the stroke coule be interpreted as a
  * scratchout by checking that the length is greater than
  * three times the width of its bounding box, that it has
  * at least three self intersections, and its height is at
  * most three quarters of its width.
  */
 public static bool isScratchOut(Stroke s)
 {
     Rectangle rect = s.GetBoundingBox();
     double length = StrokeManager.StrokeLength(s);
     return length > 3*rect.Width && rect.Height <= rect.Width*3/4 && s.SelfIntersections.Length > 2 ;
 }
开发者ID:mdayaram,项目名称:graph-animator,代码行数:12,代码来源:StrokeManager.cs

示例6: HitNodeTest

 /* Checks if the given stroke is within the bounds of a
  * Node.  It accomplishes this by using the stroke hit test.
  */
 public static Node HitNodeTest(Stroke s, Graph g)
 {
     Rectangle rectS = s.GetBoundingBox();
     Point sCenter = new Point(rectS.X + rectS.Width/2, rectS.Y + rectS.Height/2);
     for(int i=0; i<g.Nodes.Length(); i++)
     {
         Node n = g.Nodes[i];
         Rectangle rectN =n.Stroke.GetBoundingBox();
         if(s.HitTest(n.CenterPoint, (float)Math.Max(rectN.Height/2.0, rectN.Width/2.0))
             ||n.Stroke.HitTest(sCenter, (float)Math.Max(rectS.Height/2.0, rectS.Width/2.0)))
         {
             return n;
         }
     }
     return null;
 }
开发者ID:mdayaram,项目名称:graph-animator,代码行数:19,代码来源:StrokeManager.cs

示例7: FitsRectProperties

 /* Returns true if the stroke resembles a rectangle given a tolerance.
  * Accomplishes this by taking the perimeter of a rectangle that
  * would be bounded in the area the stroke is bounded and
  * comparing it to the length of the stroke.
  */
 public static bool FitsRectProperties(Stroke e, double tolerance)
 {
     if (e == null || FitsCircleProperties(e,CIRCLE_TOLERANCE)) return false;
     Rectangle r = e.GetBoundingBox();
     if(r.Height < MIN_WIDTH || r.Width < MIN_WIDTH) return false;
     double perimeter = r.Height*2 + r.Width*2;
     double strokeLength = StrokeManager.StrokeLength(e);
     return Math.Abs(perimeter-strokeLength) <= tolerance;
 }
开发者ID:mdayaram,项目名称:graph-animator,代码行数:14,代码来源:StrokeManager.cs


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