Esempio n. 1
0
        public LineInterpolatorAAData(OutlineRenderer ren, LineParameters lp)
        {
            _ren = ren;
            //TODO: consider resuable array
            _dist   = ren.GetFreeDistArray(); // new int[MAX_HALF_WIDTH + 1];
            _covers = ren.GetFreeConvArray(); // new byte[MAX_HALF_WIDTH * 2 + 4];


            _li = new LineInterpolatorDDA2(
                lp.vertical ? LineAA.DblHr(lp.x2 - lp.x1) :
                LineAA.DblHr(lp.y2 - lp.y1),
                lp.vertical ? Math.Abs(lp.y2 - lp.y1) :
                Math.Abs(lp.x2 - lp.x1) + 1);

            //---------------------------------------------------------
            _lp     = lp;
            _len    = ((lp.vertical == (lp.inc > 0)) ? -lp.len : lp.len);
            m_x     = (lp.x1 >> LineAA.SUBPIXEL_SHIFT);
            m_y     = (lp.y1 >> LineAA.SUBPIXEL_SHIFT);
            m_old_x = (m_x);
            m_old_y = (m_y);
            _count  = ((lp.vertical ? Math.Abs((lp.y2 >> LineAA.SUBPIXEL_SHIFT) - m_y) :
                        Math.Abs((lp.x2 >> LineAA.SUBPIXEL_SHIFT) - m_x)));
            _width = (ren.SubPixelWidth);
            //m_max_extent(m_width >> (line_subpixel_shift - 2));
            _max_extent = ((_width + LineAA.SUBPIXEL_MARK) >> LineAA.SUBPIXEL_SHIFT);
            m_step      = 0;

            //-------------------
            var li = new LineInterpolatorDDA2S(0, lp.vertical ?
                                               (lp.dy << LineAA.SUBPIXEL_SHIFT) :
                                               (lp.dx << LineAA.SUBPIXEL_SHIFT),
                                               lp.len);

            int i;
            int stop = _width + LineAA.SUBPIXEL_SCALE * 2;

            for (i = 0; i < MAX_HALF_WIDTH; ++i)
            {
                //assign and eval
                //#if DEBUG
                //                if (li.Y == 194)
                //                {
                //                }
                //#endif
                if ((_dist[i] = li.Y) >= stop)
                {
                    break;
                }
                li.Next();
            }
            _dist[i++] = 0x7FFF0000;
        }
        public void Begin(double x, double y, int len)
        {
            double tx = x;
            double ty = y;

            Transformer.Transform(ref tx, ref ty);
            int x1 = AggMath.iround(tx * SUB_PIXEL_SCALE);
            int y1 = AggMath.iround(ty * SUB_PIXEL_SCALE);

            //
            tx = x + len; //***
            ty = y;       //**
            Transformer.Transform(ref tx, ref ty);
            int x2 = AggMath.iround(tx * SUB_PIXEL_SCALE);
            int y2 = AggMath.iround(ty * SUB_PIXEL_SCALE);

            //

            _li_x = new LineInterpolatorDDA2S(x1, x2, len);
            _li_y = new LineInterpolatorDDA2S(y1, y2, len);
        }