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


C# Stroke.GetPoints方法代码示例

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


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

示例1: SegmentizeStroke

    //
    // Implementation
    private static Point[] SegmentizeStroke(Stroke stroke, double tolerance, out int[] indices)
    {
        // Grab the ink points.
        Point[] points = stroke.GetPoints();
        int n = points.Length;

        // Segmentize at desired tolerance, to produce array of vertices.
        ArrayList vertexIndices = new ArrayList();
        vertexIndices.Add(0);
        SegmentizeSquiggle(vertexIndices,points,0,n-1,tolerance);
        // populates vertexIndices list

        indices = vertexIndices.ToArray(typeof(int)) as int[];

        int nv = indices.Length;
        Point[] vertices = new Point[nv];

        for (int i=0; i < nv; ++i)
        {
            int index = indices[i];
            vertices[i] = points[index];
        }

        return vertices;
    }
开发者ID:pichiliani,项目名称:CoPhysicsSimulator,代码行数:27,代码来源:StrokeAnalyzer.cs

示例2: MakeBodyFromClosedStroke

    private RigidBodyBase MakeBodyFromClosedStroke(Stroke stroke, Point[] vertices)
    {
        // Form a new body -- ellipse or polygon?
        RigidBodyBase newbody = null;

        Point[] points = stroke.GetPoints();
        Ellipse elli = Ellipse.FromRegression(points);
        if (!elli.IsEmpty && elli.IsFit(points))
        {
            dbg.WriteLine("new EllipticalBody");

            newbody = new EllipticalBody();
            EllipticalBody body = newbody as EllipticalBody;

            body.CenterPoint = elli.Center;
            body.MajorAxis = elli.MajorAxis;
            body.MinorAxis = elli.MinorAxis;
            body.Orientation = elli.Orientation;

            // Close to circle? Snap to it.
            if ((float)elli.MajorAxis/(float)elli.MinorAxis < 1.25)
            {
                int r = (elli.MajorAxis+elli.MinorAxis)/2;
                body.MajorAxis = body.MinorAxis = r;
                body.Orientation = 0;
            }
        }
        else
        {
            dbg.WriteLine("new PolygonalBody");

            newbody = new PolygonalBody();
            PolygonalBody body = newbody as PolygonalBody;
            body.Vertices = vertices;
        }

        dbg.WriteLine(String.Format("Mass={0}, I={1}",newbody.Mass,newbody.I));

        newbody.strokeid = stroke.Id;
        doc.Bodies.Add(newbody);

        return newbody;
    }
开发者ID:pichiliani,项目名称:CoPhysicsSimulator,代码行数:43,代码来源:MainForm.cs

示例3: 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

示例4: CopyStroke

 //Creates a deep copy of the stroke s
 public static Stroke CopyStroke(Stroke s)
 {
     Point[] p = s.GetPoints();
     return s.Ink.CreateStroke(p);
 }
开发者ID:mdayaram,项目名称:graph-animator,代码行数:6,代码来源:StrokeManager.cs

示例5: StrokeLength

 //Gets the length of a stroke
 public static double StrokeLength(Stroke e)
 {
     double dist = 0;
     Point[] points = e.GetPoints();
     for(int i=0; i<points.Length-1; i++)
     {
         dist += StrokeManager.Distance(points[i], points[i+1]);
     }
     return dist;
 }
开发者ID:mdayaram,项目名称:graph-animator,代码行数:11,代码来源:StrokeManager.cs

示例6: ifEdgeGetNodes

        /* Determines whether the following stroke could be interpreted as
         * an edge (or edges) and if so, returns all the consecutive nodes that the
         * stroke has gone through in order.
         */
        public static Nodes ifEdgeGetNodes(Stroke s, Graph g)
        {
            Point[] sPoints = s.GetPoints();
            Nodes strokeHitNodes = new Nodes();
            Node prev = null;
            for(int i=0; i<sPoints.Length; i++)
            {
                for(int j=0; j<g.Nodes.Length(); j++)
                {
                    Node n = g.Nodes[j];
                    Rectangle r = n.Stroke.GetBoundingBox();

                    if(s.HitTest(n.CenterPoint,Math.Max(r.Width/2, r.Height/2)) && r.Contains(sPoints[i]) && !n.Equals(prev))
                    {
                        strokeHitNodes.Add(n);
                        prev = n;
                        break;
                    }
                }
            }
            //If stroke hit one or less nodes, it is clearly not an edge.
            if(strokeHitNodes.Length() < 2)
            {
                return null;
            }
            return strokeHitNodes;
        }
开发者ID:mdayaram,项目名称:graph-animator,代码行数:31,代码来源:StrokeManager.cs

示例7: HitObjects

 /* Gets all the objects, nodes and edges, from graph g
  * hit by this stroke and returns an arraylist containing them all
  */
 public static ArrayList HitObjects(Stroke s, Graph g)
 {
     ArrayList objs = new ArrayList();
     Point[] points = s.GetPoints();
     for(int j=0; j<g.Edges.Length(); j++)
     {
         for(int i=0; i<points.Length; i++)
         {
             if(g.Edges[j].Stroke.HitTest(points[i],1))
             {
                 objs.Add(g.Edges[j]);
             }
         }
     }
     for(int j=0; j<g.Nodes.Length(); j++)
     {
         for(int i=0; i<points.Length; i++)
         {
             if(g.Nodes[j].Stroke.HitTest(points[i],1))
             {
                 objs.Add(g.Nodes[j]);
             }
         }
     }
     return objs;
 }
开发者ID:mdayaram,项目名称:graph-animator,代码行数:29,代码来源:StrokeManager.cs


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