//---------------------------------------------------------------------
 public LineInterpolatorAA0(OutlineRenderer ren, LineParameters lp)
 {
     this._ren = ren;
     _aa_data  = new LineInterpolatorAAData(ren, lp);
     _m_di     = new DistanceInterpolator1(lp.x1, lp.y1, lp.x2, lp.y2,
                                           lp.x1 & ~LineAA.SUBPIXEL_MARK, lp.y1 & ~LineAA.SUBPIXEL_MARK);
     _aa_data.m_li.adjust_forward();
 }
Ejemplo n.º 2
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 LineInterpolatorAA2(
     OutlineRenderer ren, LineParameters lp,
     int ex, int ey)
 {
     this._ren = ren;
     _aa_data  = new Lines.LineInterpolatorAAData(ren, lp);
     _m_di     = new DistanceInterpolator2(lp.x1, lp.y1, lp.x2, lp.y2, ex, ey,
                                           lp.x1 & ~LineAA.SUBPIXEL_MARK, lp.y1 & ~LineAA.SUBPIXEL_MARK,
                                           0);
     _aa_data.m_li.adjust_forward();
     _aa_data.m_step -= _aa_data.m_max_extent;
 }
        public LineInterpolatorAAData(OutlineRenderer ren, LineParameters lp)
        {
            m_dist   = new int[MAX_HALF_WIDTH + 1];
            m_covers = new byte[MAX_HALF_WIDTH * 2 + 4];

            m_lp = lp;
            m_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);

            m_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);
            m_count = ((lp.vertical ? Math.Abs((lp.y2 >> LineAA.SUBPIXEL_SHIFT) - m_y) :
                        Math.Abs((lp.x2 >> LineAA.SUBPIXEL_SHIFT) - m_x)));
            m_width = (ren.SubPixelWidth);
            //m_max_extent(m_width >> (line_subpixel_shift - 2));
            m_max_extent = ((m_width + LineAA.SUBPIXEL_MARK) >> LineAA.SUBPIXEL_SHIFT);
            m_step       = 0;
            LineInterpolatorDDA2 li = new LineInterpolatorDDA2(0,
                                                               lp.vertical ? (lp.dy << LineAA.SUBPIXEL_SHIFT) : (lp.dx << LineAA.SUBPIXEL_SHIFT),
                                                               lp.len);
            int i;
            int stop = m_width + LineAA.SUBPIXEL_SCALE * 2;

            for (i = 0; i < MAX_HALF_WIDTH; ++i)
            {
                m_dist[i] = li.Y;
                if (m_dist[i] >= stop)
                {
                    break;
                }
                li.Next();
            }
            m_dist[i++] = 0x7FFF0000;
        }
        public LineInterpolatorAA3(OutlineRenderer ren, LineParameters lp,
                                   int sx, int sy, int ex, int ey)
        {
            this._ren = ren;
            _aa_data  = new Lines.LineInterpolatorAAData(ren, lp);
            _m_di     = new DistanceInterpolator3(lp.x1, lp.y1, lp.x2, lp.y2, sx, sy, ex, ey,
                                                  lp.x1 & ~LineAA.SUBPIXEL_MARK, lp.y1 & ~LineAA.SUBPIXEL_MARK);
            int dist1_start;
            int dist2_start;
            int npix = 1;

            if (lp.vertical)
            {
                do
                {
                    _aa_data.m_li.Prev();
                    _aa_data.m_y -= lp.inc;
                    _aa_data.m_x  = (_aa_data.m_lp.x1 + _aa_data.m_li.Y) >> LineAA.SUBPIXEL_SHIFT;
                    if (lp.inc > 0)
                    {
                        _m_di.DecY(_aa_data.m_x - _aa_data.m_old_x);
                    }
                    else
                    {
                        _m_di.IncY(_aa_data.m_x - _aa_data.m_old_x);
                    }
                    _aa_data.m_old_x = _aa_data.m_x;
                    dist1_start      = dist2_start = _m_di.dist_start;
                    int dx = 0;
                    if (dist1_start < 0)
                    {
                        ++npix;
                    }
                    do
                    {
                        dist1_start += _m_di.DyStart;
                        dist2_start -= _m_di.DyStart;
                        if (dist1_start < 0)
                        {
                            ++npix;
                        }
                        if (dist2_start < 0)
                        {
                            ++npix;
                        }
                        ++dx;
                    }while (_aa_data.m_dist[dx] <= _aa_data.m_width);
                    if (npix == 0)
                    {
                        break;
                    }
                    npix = 0;
                }while (--_aa_data.m_step >= -_aa_data.m_max_extent);
            }
            else
            {
                do
                {
                    _aa_data.m_li.Prev();
                    _aa_data.m_x -= lp.inc;
                    _aa_data.m_y  = (_aa_data.m_lp.y1 + _aa_data.m_li.Y) >> LineAA.SUBPIXEL_SHIFT;
                    if (lp.inc > 0)
                    {
                        _m_di.DecX(_aa_data.m_y - _aa_data.m_old_y);
                    }
                    else
                    {
                        _m_di.IncX(_aa_data.m_y - _aa_data.m_old_y);
                    }
                    _aa_data.m_old_y = _aa_data.m_y;
                    dist1_start      = dist2_start = _m_di.dist_start;
                    int dy = 0;
                    if (dist1_start < 0)
                    {
                        ++npix;
                    }
                    do
                    {
                        dist1_start -= _m_di.DxStart;
                        dist2_start += _m_di.DxStart;
                        if (dist1_start < 0)
                        {
                            ++npix;
                        }
                        if (dist2_start < 0)
                        {
                            ++npix;
                        }
                        ++dy;
                    }while (_aa_data.m_dist[dy] <= _aa_data.m_width);
                    if (npix == 0)
                    {
                        break;
                    }
                    npix = 0;
                }while (--_aa_data.m_step >= -_aa_data.m_max_extent);
            }
            _aa_data.m_li.adjust_forward();
            _aa_data.m_step -= _aa_data.m_max_extent;
        }
Ejemplo n.º 6
0
 public LineInterpolatorAAData(OutlineRenderer ren, in LineParameters lp)