private static void EndFigureImpl(IntPtr thisPtr, FigureEnd figureEnd)
            {
                var shadow   = ToShadow <ID2D1SimplifiedGeometrySinkShadow>(thisPtr);
                var callback = (ID2D1SimplifiedGeometrySink)shadow.Callback;

                callback.EndFigure(figureEnd);
            }
Пример #2
0
 public void EndFigure(FigureEnd figureEnd)
 {
     if (figureEnd == FigureEnd.Closed)
     {
         this._buffer.Append("Z ");
     }
 }
Пример #3
0
        public override void BeginFigure(Point startPoint, bool isFilled, bool isClosed)
        {
            this.figureEnd = isClosed ? FigureEnd.Closed : FigureEnd.Open;

            this.sink.BeginFigure(
                startPoint.ToSharpDX(),
                isFilled ? FigureBegin.Filled : FigureBegin.Hollow);
        }
Пример #4
0
 /// <summary>
 /// Ends the current figure; optionally, closes it.
 /// </summary>
 /// <param name="figureEnd">A value that indicates whether the current figure is closed. If the figure is closed, a line is drawn between the current point and the start point specified by {{BeginFigure}}.</param>
 /// <unmanaged>void EndFigure([None] D2D1_FIGURE_END figureEnd)</unmanaged>
 /// <remarks>
 /// Calling this method without a matching call to {{BeginFigure}} places the geometry sink in an error state; subsequent calls are ignored, and the overall failure will be returned when the {{Close}} method is called.
 /// </remarks>
 public void EndFigure(FigureEnd figureEnd)
 {
     if (m_currentPolygonBuilder.Count >= 3)
     {
         m_polygons2D.Add(new Polygon2D(m_currentPolygonBuilder.ToArray()));
         m_currentPolygonBuilder.Clear();
     }
 }
Пример #5
0
 public void EndFigure(FigureEnd figureEnd)
 {
     if (!isFigureOpened)
     {
         throw new InvalidOperationException("Figure was not opened.");
     }
     geometrySink.EndFigure(GetD2DFigureFlag(figureEnd));
     isFigureOpened = false;
 }
Пример #6
0
        private static SharpDX.Direct2D1.FigureEnd GetD2DFigureFlag(FigureEnd figureEnd)
        {
            switch (figureEnd)
            {
            case FigureEnd.Open:
                return(SharpDX.Direct2D1.FigureEnd.Open);

            case FigureEnd.Closed:
                return(SharpDX.Direct2D1.FigureEnd.Closed);

            default:
                throw new ArgumentOutOfRangeException("figureEnd");
            }
        }
Пример #7
0
        public void endOpenFigure(FigureEnd end = FigureEnd.Open)
        {
            if (_figure_ == null)
            {
                return;
            }

            var fill = end == FigureEnd.Open ? FigureBegin.Hollow : FigureBegin.Filled;

            _sink.BeginFigure(Import.Point(_startX, _startY), fill);
            var sinkTarget = new GeometrySinkFigureTarget(_sink);

            _figure_.Replay(sinkTarget);
            _sink.EndFigure(end);
            _figure_ = null;
        }
Пример #8
0
        public void EndFigure(FigureEnd figureEnd)
        {
            EnsureNotClosed();
            EnsureFigureBegun();

            _hasFigureBegun = false;

            if (_currentFigure.Count > 0)
            {
                var figure = new Figure(_currentOrigin, _currentFigure.ToArray(), figureEnd);

                _figures.Add(figure);
            }

            _currentFigure.Clear();
        }
Пример #9
0
        private void AddRandomFigure(IGeometrySink sink, int segmentCount)
        {
            previousPoint = null;
            sink.BeginFigure(
                RandomNearPoint(),
                CoinFlip ? FigureBegin.Filled : FigureBegin.Hollow);
            FigureEnd end = CoinFlip ? FigureEnd.Closed : FigureEnd.Closed;

            if (end == FigureEnd.Closed)
            {
                segmentCount--;
            }
            if (CoinFlip)
            {
                for (int i = 0; i < segmentCount; i++)
                {
                    AddRandomSegment(sink);
                }
            }
            else
            {
                double which = Random.NextDouble();
                if (which < 0.33)
                {
                    sink.AddLines(RandomLines(segmentCount));
                }
                else if (which < 0.67)
                {
                    sink.AddQuadraticBeziers(RandomQuadraticBeziers(segmentCount));
                }
                else
                {
                    sink.AddBeziers(RandomBeziers(segmentCount));
                }
            }
            sink.EndFigure(end);
        }
Пример #10
0
 private void Close(FigureEnd endType)
 {
     IsFigureOpen = false;
     _sink.EndFigure(endType);
 }
Пример #11
0
        public void EndFigure(FigureEnd figureEnd)
        {
            Vector2 front = m_figureVertices[0].pt;
            Vector2 back  = m_figureVertices[m_figureVertices.Count - 1].pt;

            if (front.X == back.X && front.Y == back.Y)
            {
                m_figureVertices.RemoveAt(m_figureVertices.Count - 1);
            }

            if (m_figureVertices.Count > 1)
            {
                //Snap and normals
                for (int i = 0; i < m_figureVertices.Count; i++)
                {
                    Vertex2D v = m_figureVertices[i];
                    v.norm = GetNormal(i);
                    m_figureVertices[i] = v;
                }

                //Interpolate normals
                for (int i = 0; i < m_figureVertices.Count; i++)
                {
                    int h = (i + m_figureVertices.Count - 1) % m_figureVertices.Count;

                    Vector2 n1 = m_figureVertices[h].norm;
                    Vector2 n2 = m_figureVertices[i].norm;

                    Vertex2D v = m_figureVertices[i];

                    if ((n1.X * n2.X + n1.Y * n2.Y) > .5f)
                    {
                        Vector2 sum = m_figureVertices[i].norm + m_figureVertices[h].norm;

                        v.inter1 = Vector2.Normalize(sum);
                        v.inter2 = v.inter1;
                    }
                    else
                    {
                        v.inter1 = m_figureVertices[h].norm;
                        v.inter2 = m_figureVertices[i].norm;
                    }
                    m_figureVertices[i] = v;
                }

                //Output triangles
                for (int i = 0; i < m_figureVertices.Count; i++)
                {
                    int j = (i + 1) % m_figureVertices.Count;

                    Vector2 pt     = m_figureVertices[i].pt;
                    Vector2 nextPt = m_figureVertices[j].pt;

                    Vector2 ptNorm3     = m_figureVertices[i].inter2;
                    Vector2 nextPtNorm2 = m_figureVertices[j].inter1;

                    vertices.Add(new Pos3Norm3VertexSDX()
                    {
                        Position = new Vector3(pt.X, pt.Y, m_height / 2), Normals = new Vector3(ptNorm3.X, ptNorm3.Y, 0.0f)
                    });
                    vertices.Add(new Pos3Norm3VertexSDX()
                    {
                        Position = new Vector3(pt.X, pt.Y, -m_height / 2), Normals = new Vector3(ptNorm3.X, ptNorm3.Y, 0.0f)
                    });
                    vertices.Add(new Pos3Norm3VertexSDX()
                    {
                        Position = new Vector3(nextPt.X, nextPt.Y, -m_height / 2), Normals = new Vector3(nextPtNorm2.X, nextPtNorm2.Y, 0.0f)
                    });
                    vertices.Add(new Pos3Norm3VertexSDX()
                    {
                        Position = new Vector3(nextPt.X, nextPt.Y, -m_height / 2), Normals = new Vector3(nextPtNorm2.X, nextPtNorm2.Y, 0.0f)
                    });
                    vertices.Add(new Pos3Norm3VertexSDX()
                    {
                        Position = new Vector3(nextPt.X, nextPt.Y, m_height / 2), Normals = new Vector3(nextPtNorm2.X, nextPtNorm2.Y, 0.0f)
                    });
                    vertices.Add(new Pos3Norm3VertexSDX()
                    {
                        Position = new Vector3(pt.X, pt.Y, m_height / 2), Normals = new Vector3(ptNorm3.X, ptNorm3.Y, 0.0f)
                    });
                }
            }
        }
Пример #12
0
 public void EndFigure(FigureEnd figureEnd)
 {
     m_geometrySink.EndFigure((SlimDX.Direct2D.FigureEnd)figureEnd);
 }
Пример #13
0
 internal Figure(Vector2 origin, [NotNull] GeometryElement[] elements, FigureEnd figureEnd)
 {
     Origin    = origin;
     Elements  = elements;
     FigureEnd = figureEnd;
 }
Пример #14
0
        public void endOpenFigure(FigureEnd end = FigureEnd.Open)
        {
            if (_figure_ == null)
                return;

            var fill = end == FigureEnd.Open ? FigureBegin.Hollow : FigureBegin.Filled;
            _sink.BeginFigure(Import.Point(_startX, _startY), fill);
            var sinkTarget = new GeometrySinkFigureTarget(_sink);
            _figure_.Replay(sinkTarget);
            _sink.EndFigure(end);
            _figure_ = null;
        }
Пример #15
0
        private PathGeometry CreateArc(float cx, float cy, float radius, float startAngle, float endAngle, FigureBegin begin, FigureEnd end)
        {
            var geometry = new PathGeometry(d2dFactory);

            using (var sink = geometry.Open())
            {
                var sa = -startAngle;
                var ea = -endAngle;

                sink.BeginFigure(
                    new Vector2(
                        cx + radius * (float)Math.Cos(sa),
                        cy + radius * (float)Math.Sin(sa)),
                    begin);

                var segment = new ArcSegment()
                {
                    Point = new Vector2(
                        cx + radius * (float)Math.Cos(ea),
                        cy + radius * (float)Math.Sin(ea)),
                    Size           = new DrawingSizeF(radius, radius),
                    SweepDirection = SweepDirection.CounterClockwise
                };
                sink.AddArc(segment);
                sink.EndFigure(end);
                sink.Close();
            }
            return(geometry);
        }
Пример #16
0
 public void EndFigure(FigureEnd figureEnd)
 {
 }
 public void EndFigure(FigureEnd figureEnd) => EndFigure_(figureEnd);
Пример #18
0
        public void EndFigure(FigureEnd figureEnd)
        {
            Vector2 front = m_figureVertices[0].pt;
            Vector2 back = m_figureVertices[m_figureVertices.Count - 1].pt;

            if (front.X == back.X && front.Y == back.Y)
            {
                m_figureVertices.RemoveAt(m_figureVertices.Count - 1);
            }

            if (m_figureVertices.Count > 1)
            {

                //Snap and normals
                for (int i = 0; i < m_figureVertices.Count; i++)
                {
                    Vertex2D v = m_figureVertices[i];
                    v.norm = GetNormal(i);
                    v.pt = PointSnapper.SnapPoint(v.pt);
                    m_figureVertices[i] = v;
                }

                //Interpolate normals
                for (int i = 0; i < m_figureVertices.Count; i++)
                {
                    int h = (i + m_figureVertices.Count - 1) % m_figureVertices.Count;

                    Vector2 n1 = m_figureVertices[h].norm;
                    Vector2 n2 = m_figureVertices[i].norm;

                    Vertex2D v = m_figureVertices[i];

                    if ((n1.X * n2.X + n1.Y * n2.Y) > .5f)
                    {
                        Vector2 sum = m_figureVertices[i].norm + m_figureVertices[h].norm;

                        v.inter1 = Vector2.Normalize(sum);
                        v.inter2 = v.inter1;
                    }
                    else
                    {
                        v.inter1 = m_figureVertices[h].norm;
                        v.inter2 = m_figureVertices[i].norm;
                    }
                    m_figureVertices[i] = v;
                }

                //Output triangles
                for (int i = 0; i < m_figureVertices.Count; i++)
                {
                    int j = (i + 1) % m_figureVertices.Count;

                    Vector2 pt = m_figureVertices[i].pt;
                    Vector2 nextPt = m_figureVertices[j].pt;

                    Vector2 ptNorm3 = m_figureVertices[i].inter2;
                    Vector2 nextPtNorm2 = m_figureVertices[j].inter1;

                    vertices.Add(new Pos3Norm3VertexSDX() { Position = new Vector3(pt.X, pt.Y, m_height / 2), Normals = new Vector3(ptNorm3.X, ptNorm3.Y, 0.0f) });
                    vertices.Add(new Pos3Norm3VertexSDX() { Position = new Vector3(pt.X, pt.Y, -m_height / 2), Normals = new Vector3(ptNorm3.X, ptNorm3.Y, 0.0f) });
                    vertices.Add(new Pos3Norm3VertexSDX() { Position = new Vector3(nextPt.X, nextPt.Y, -m_height / 2), Normals = new Vector3(nextPtNorm2.X, nextPtNorm2.Y, 0.0f) });
                    vertices.Add(new Pos3Norm3VertexSDX() { Position = new Vector3(nextPt.X, nextPt.Y, -m_height / 2), Normals = new Vector3(nextPtNorm2.X, nextPtNorm2.Y, 0.0f) });
                    vertices.Add(new Pos3Norm3VertexSDX() { Position = new Vector3(nextPt.X, nextPt.Y, m_height / 2), Normals = new Vector3(nextPtNorm2.X, nextPtNorm2.Y, 0.0f) });
                    vertices.Add(new Pos3Norm3VertexSDX() { Position = new Vector3(pt.X, pt.Y, m_height / 2), Normals = new Vector3(ptNorm3.X, ptNorm3.Y, 0.0f) });

                }
            }
        }
Пример #19
0
 void SimplifiedGeometrySink.EndFigure(FigureEnd figureEnd)
 {
     if(figureEnd == FigureEnd.Closed)
     {
         _Builder.Close();
     }
 }
Пример #20
0
 public void EndFigure(FigureEnd figureEnd)
 {
     if(figureEnd == FigureEnd.Closed)
         this._buffer.Append("Z ");
 }
Пример #21
0
 public void EndFigure(FigureEnd figureEnd)
 {
     base.innerRefT.EndFigure(figureEnd);
 }
 /// <summary>
 ///  Ends the current figure; optionally, closes it.
 /// </summary>
 /// <param name="figureEnd">A value that indicates whether the current figure is closed. If the figure is closed, a line is drawn between the current point and the start point specified by <strong>BeginFigure</strong>.</param>
 /// <remarks>
 /// Calling this method without a matching call to <strong>BeginFigure</strong> places the geometry sink in an error state; subsequent calls are ignored, and the overall failure will be returned when the <strong>Close</strong> method is called.
 /// </remarks>
 public void EndFigure(FigureEnd figureEnd)
 {
     EndFigure_(figureEnd);
 }
Пример #23
0
 public void EndFigure(FigureEnd fe)
 {
 }