コード例 #1
0
ファイル: PathState.cs プロジェクト: iamr8/IoTGateway
        /// <summary>
        /// Sets a new spline vertex
        /// </summary>
        /// <param name="X">X-coordinate</param>
        /// <param name="Y">Y-coordinate</param>
        /// <returns>Dynamic spline curve</returns>
        public PathSpline SetSplineVertex(float X, float Y)
        {
            if (this.path is null)
            {
                this.Set(X, Y);
                return(null);
            }
            else
            {
                if (this.currentSpline is null)
                {
                    this.currentSpline = new PathSpline(this.x, this.y);
                }

                this.currentSpline.Add(X, Y);
                this.drawingSpline = true;

                if (X != this.x || Y != this.y)
                {
                    this.xPrev = this.x;
                    this.x     = X;

                    this.yPrev = this.y;
                    this.y     = Y;

                    this.angle = null;

                    this.pathDef?.IncludePoint(X, Y);
                }

                return(this.currentSpline);
            }
        }
コード例 #2
0
ファイル: PathState.cs プロジェクト: iamr8/IoTGateway
        /// <summary>
        /// Closes an ongoing spline curve (if one open).
        /// </summary>
        public void FlushSpline()
        {
            if (this.drawingSpline)
            {
                this.drawingSpline = false;

                Spline.CreateSpline(this.path, this.currentSpline.ToArray());
                this.currentSpline = null;
                this.nonSpline     = false;
            }
        }
コード例 #3
0
ファイル: PathState.cs プロジェクト: iamr8/IoTGateway
        /// <summary>
        /// Closes the current contour, using a spline, creating a closed smooth loop.
        /// </summary>
        public void CloseLoop()
        {
            if (this.drawingSpline)
            {
                if (this.nonSpline)
                {
                    this.AddSplineVertex(this.x0, this.y0);
                    this.FlushSpline();
                    this.path?.Close();
                    this.nonSpline = false;
                }
                else
                {
                    Loop.CreateLoop(this.path, this.currentSpline.ToArray());
                    this.currentSpline = null;
                }

                this.drawingSpline = false;
            }
            else
            {
                this.CloseLine();
            }
        }