Exemplo n.º 1
0
        /// <summary>
        /// we do NOT store snap ***
        /// </summary>
        /// <param name="snap"></param>
        public void AddPath(VertexStoreSnap snap)
        {
            //-----------------------------------------------------
            //*** we extract vertext command and coord(x,y) from
            //the snap but not store the snap inside rasterizer
            //-----------------------------------------------------

            double x = 0;
            double y = 0;

            if (m_cellAARas.Sorted)
            {
                Reset();
            }
            float offsetOrgX = OffsetOriginX;
            float offsetOrgY = OffsetOriginY;


            VertexSnapIter snapIter = snap.GetVertexSnapIter();
            VertexCmd      cmd;

#if DEBUG
            int dbugVertexCount = 0;
#endif

            if (ExtendX3ForSubPixelRendering)
            {
                while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.NoMore)
                {
#if DEBUG
                    dbugVertexCount++;
#endif
                    //---------------------------------------------
                    //NOTE: we scale horizontal 3 times.
                    //subpixel renderer will shrink it to 1
                    //---------------------------------------------
                    AddVertex(cmd, (x + offsetOrgX) * 3, y + offsetOrgY);
                }
            }
            else
            {
                while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.NoMore)
                {
#if DEBUG
                    dbugVertexCount++;
#endif

                    AddVertex(cmd, x + offsetOrgX, y + offsetOrgY);
                }
            }


            //            if (snap.VxsHasMoreThanOnePart)
            //            {
            //                //****

            //                //render all parts
            //                VertexStore vxs = snap.GetInternalVxs();
            //                int j = vxs.Count;

            //                if (UseSubPixelRendering)
            //                {
            //                    for (int i = 0; i < j; ++i)
            //                    {
            //                        var cmd = vxs.GetVertex(i, out x, out y);
            //                        if (cmd != VertexCmd.Stop)
            //                        {
            //                            //AddVertext 1 of 4
            //                            AddVertex(cmd, (x + offsetOrgX) * 3, y + offsetOrgY);
            //                        }
            //                    }
            //                }
            //                else
            //                {
            //                    for (int i = 0; i < j; ++i)
            //                    {
            //                        var cmd = vxs.GetVertex(i, out x, out y);
            //                        if (cmd != VertexCmd.Stop)
            //                        {
            //                            //AddVertext 2 of 4
            //                            AddVertex(cmd, x + offsetOrgX, y + offsetOrgY);
            //                        }
            //                    }
            //                }
            //            }
            //            else
            //            {
            //                VertexSnapIter snapIter = snap.GetVertexSnapIter();
            //                VertexCmd cmd;
            //#if DEBUG
            //                int dbugVertexCount = 0;
            //#endif
            //                if (UseSubPixelRendering)
            //                {
            //                    while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.Stop)
            //                    {
            //#if DEBUG
            //                        dbugVertexCount++;
            //#endif
            //                        //AddVertext 3 of 4
            //                        AddVertex(cmd, (x + offsetOrgX) * 3, y + offsetOrgY);
            //                    }

            //                }
            //                else
            //                {

            //                    while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.Stop)
            //                    {
            //#if DEBUG
            //                        dbugVertexCount++;
            //#endif
            //                        //AddVertext 4 of 4
            //                        AddVertex(cmd, x + offsetOrgX, y + offsetOrgY);
            //                    }
            //                }
            //            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// fill with BitmapBufferExtension lib
        /// </summary>
        void FillWithBxt(VertexStoreSnap snap)
        {
            //transate the vxs/snap to command
            double x          = 0;
            double y          = 0;
            double offsetOrgX = this.OriginX;
            double offsetOrgY = this.OriginY;

            VertexSnapIter snapIter = snap.GetVertexSnapIter();
            VertexCmd      cmd;

            int latestMoveToX = 0, latestMoveToY = 0;
            int latestX = 0, latestY = 0;


            bool closed = false;

            _reusablePolygonList.Clear();

            while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.NoMore)
            {
                x += offsetOrgX;
                y += offsetOrgY;

                switch (cmd)
                {
                case VertexCmd.MoveTo:
                {
                    if (_reusablePolygonList.Count > 0)
                    {
                        //no drawline
                        _reusablePolygonList.Clear();
                    }

                    closed = false;
                    _reusablePolygonList.Add(latestMoveToX = latestX = (int)Math.Round(x));
                    _reusablePolygonList.Add(latestMoveToY = latestY = (int)Math.Round(y));
                }
                break;

                case VertexCmd.LineTo:
                case VertexCmd.P2c:
                case VertexCmd.P3c:
                {
                    //collect to the polygon
                    _reusablePolygonList.Add(latestX = (int)Math.Round(x));
                    _reusablePolygonList.Add(latestY = (int)Math.Round(y));
                }
                break;

                case VertexCmd.Close:
                case VertexCmd.CloseAndEndFigure:
                {
                    if (_reusablePolygonList.Count > 0)
                    {
                        //flush by draw line
                        _reusablePolygonList.Add(latestX = latestMoveToX);
                        _reusablePolygonList.Add(latestY = latestMoveToY);

                        _bxt.FillPolygon(_reusablePolygonList.ToArray(),
                                         this.fillColor.ToARGB());
                    }

                    _reusablePolygonList.Clear();
                    closed = true;
                }
                break;

                default:
                    break;
                }
            }
            //---------------
            if (!closed && (_reusablePolygonList.Count > 0) &&
                (latestX == latestMoveToX) && (latestY == latestMoveToY))
            {
                //flush by draw line
                _reusablePolygonList.Add(latestMoveToX);
                _reusablePolygonList.Add(latestMoveToY);

                _bxt.FillPolygon(_reusablePolygonList.ToArray(),
                                 this.fillColor.ToARGB());
            }
        }