Esempio n. 1
0
        //----------------------------------------------------------------
        public void begin(double x, double y, int len)
        {
            // Calculate transformed coordinates at x1,y1
            double xt = x;
            double yt = y;

            m_trans_dir.transform(ref xt, ref yt);
            int x1 = agg_basics.iround(xt * subpixel_scale);
            int y1 = agg_basics.iround(yt * subpixel_scale);

            double dx;
            double dy;
            double delta = 1 / (double)subpixel_scale;

            // Calculate scale by X at x1,y1
            dx = xt + delta;
            dy = yt;
            m_trans_inv.transform(ref dx, ref dy);
            dx -= x;
            dy -= y;
            int sx1 = (int)agg_basics.uround(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

            // Calculate scale by Y at x1,y1
            dx = xt;
            dy = yt + delta;
            m_trans_inv.transform(ref dx, ref dy);
            dx -= x;
            dy -= y;
            int sy1 = (int)agg_basics.uround(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

            // Calculate transformed coordinates at x2,y2
            x += len;
            xt = x;
            yt = y;
            m_trans_dir.transform(ref xt, ref yt);
            int x2 = agg_basics.iround(xt * subpixel_scale);
            int y2 = agg_basics.iround(yt * subpixel_scale);

            // Calculate scale by X at x2,y2
            dx = xt + delta;
            dy = yt;
            m_trans_inv.transform(ref dx, ref dy);
            dx -= x;
            dy -= y;
            int sx2 = (int)agg_basics.uround(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

            // Calculate scale by Y at x2,y2
            dx = xt;
            dy = yt + delta;
            m_trans_inv.transform(ref dx, ref dy);
            dx -= x;
            dy -= y;
            int sy2 = (int)agg_basics.uround(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

            // Initialize the interpolators
            m_coord_x = new dda2_line_interpolator(x1, x2, (int)len);
            m_coord_y = new dda2_line_interpolator(y1, y2, (int)len);
            m_scale_x = new dda2_line_interpolator(sx1, sx2, (int)len);
            m_scale_y = new dda2_line_interpolator(sy1, sy2, (int)len);
        }
Esempio n. 2
0
        //----------------------------------------------------------------
        public void resynchronize(double xe, double ye, int len)
        {
            // Assume x1,y1 are equal to the ones at the previous end point
            int x1  = m_coord_x.y();
            int y1  = m_coord_y.y();
            int sx1 = m_scale_x.y();
            int sy1 = m_scale_y.y();

            // Calculate transformed coordinates at x2,y2
            double xt = xe;
            double yt = ye;

            m_trans_dir.transform(ref xt, ref yt);
            int x2 = agg_basics.iround(xt * subpixel_scale);
            int y2 = agg_basics.iround(yt * subpixel_scale);

            double delta = 1 / (double)subpixel_scale;
            double dx;
            double dy;

            // Calculate scale by X at x2,y2
            dx = xt + delta;
            dy = yt;
            m_trans_inv.transform(ref dx, ref dy);
            dx -= xe;
            dy -= ye;
            int sx2 = (int)agg_basics.uround(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

            // Calculate scale by Y at x2,y2
            dx = xt;
            dy = yt + delta;
            m_trans_inv.transform(ref dx, ref dy);
            dx -= xe;
            dy -= ye;
            int sy2 = (int)agg_basics.uround(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

            // Initialize the interpolators
            m_coord_x = new dda2_line_interpolator(x1, x2, (int)len);
            m_coord_y = new dda2_line_interpolator(y1, y2, (int)len);
            m_scale_x = new dda2_line_interpolator(sx1, sx2, (int)len);
            m_scale_y = new dda2_line_interpolator(sy1, sy2, (int)len);
        }
Esempio n. 3
0
        //----------------------------------------------------------------
        public void begin(double x, double y, int len)
        {
            double tx;
            double ty;

            tx = x;
            ty = y;
            m_trans.transform(ref tx, ref ty);
            int x1 = agg_basics.iround(tx * (double)subpixel_scale_e.subpixel_scale);
            int y1 = agg_basics.iround(ty * (double)subpixel_scale_e.subpixel_scale);

            tx = x + len;
            ty = y;
            m_trans.transform(ref tx, ref ty);
            int x2 = agg_basics.iround(tx * (double)subpixel_scale_e.subpixel_scale);
            int y2 = agg_basics.iround(ty * (double)subpixel_scale_e.subpixel_scale);

            m_li_x = new dda2_line_interpolator(x1, x2, (int)len);
            m_li_y = new dda2_line_interpolator(y1, y2, (int)len);
        }
Esempio n. 4
0
        //--------------------------------------------------------------------
        public line_bresenham_interpolator(int x1, int y1, int x2, int y2)
        {
            m_x1_lr = (line_lr(x1));
            m_y1_lr = (line_lr(y1));
            m_x2_lr = (line_lr(x2));
            m_y2_lr = (line_lr(y2));
            m_ver   = (Math.Abs(m_x2_lr - m_x1_lr) < Math.Abs(m_y2_lr - m_y1_lr));
            if (m_ver)
            {
                m_len = (int)Math.Abs(m_y2_lr - m_y1_lr);
            }
            else
            {
                m_len = (int)Math.Abs(m_x2_lr - m_x1_lr);
            }

            m_inc          = (m_ver ? ((y2 > y1) ? 1 : -1) : ((x2 > x1) ? 1 : -1));
            m_interpolator = new dda2_line_interpolator(m_ver ? x1 : y1,
                                                        m_ver ? x2 : y2,
                                                        (int)m_len);
        }
Esempio n. 5
0
 //----------------------------------------------------------------
 public void resynchronize(double xe, double ye, int len)
 {
     m_trans.transform(ref xe, ref ye);
     m_li_x = new dda2_line_interpolator(m_li_x.y(), agg_basics.iround(xe * (double)subpixel_scale_e.subpixel_scale), (int)len);
     m_li_y = new dda2_line_interpolator(m_li_y.y(), agg_basics.iround(ye * (double)subpixel_scale_e.subpixel_scale), (int)len);
 }
Esempio n. 6
0
 //--------------------------------------------------------------------
 public line_bresenham_interpolator(int x1, int y1, int x2, int y2)
 {
     m_x1_lr=(line_lr(x1));
     m_y1_lr=(line_lr(y1));
     m_x2_lr=(line_lr(x2));
     m_y2_lr=(line_lr(y2));
     m_ver=(Math.Abs(m_x2_lr - m_x1_lr) < Math.Abs(m_y2_lr - m_y1_lr));
     if (m_ver)
     {
         m_len = (int)Math.Abs(m_y2_lr - m_y1_lr);
     }
     else
     {
         m_len = (int)Math.Abs(m_x2_lr - m_x1_lr);
     }
     
     m_inc=(m_ver ? ((y2 > y1) ? 1 : -1) : ((x2 > x1) ? 1 : -1));
     m_interpolator= new dda2_line_interpolator(m_ver ? x1 : y1,
                    m_ver ? x2 : y2,
                    (int)m_len);
 }
 //----------------------------------------------------------------
 public void resynchronize(double xe, double ye, int len)
 {
     m_trans.transform(ref xe, ref ye);
     m_li_x = new dda2_line_interpolator(m_li_x.y(), agg_basics.iround(xe * (double)subpixel_scale_e.subpixel_scale), (int)len);
     m_li_y = new dda2_line_interpolator(m_li_y.y(), agg_basics.iround(ye * (double)subpixel_scale_e.subpixel_scale), (int)len);
 }
        //----------------------------------------------------------------
        public void begin(double x, double y, int len)
        {
            double tx;
            double ty;

            tx = x;
            ty = y;
            m_trans.transform(ref tx, ref ty);
            int x1 = agg_basics.iround(tx * (double)subpixel_scale_e.subpixel_scale);
            int y1 = agg_basics.iround(ty * (double)subpixel_scale_e.subpixel_scale);

            tx = x + len;
            ty = y;
            m_trans.transform(ref tx, ref ty);
            int x2 = agg_basics.iround(tx * (double)subpixel_scale_e.subpixel_scale);
            int y2 = agg_basics.iround(ty * (double)subpixel_scale_e.subpixel_scale);

            m_li_x = new dda2_line_interpolator(x1, x2, (int)len);
            m_li_y = new dda2_line_interpolator(y1, y2, (int)len);
        }
		//----------------------------------------------------------------
		public void resynchronize(double xe, double ye, int len)
		{
			// Assume x1,y1 are equal to the ones at the previous end point
			int x1 = m_coord_x.y();
			int y1 = m_coord_y.y();
			int sx1 = m_scale_x.y();
			int sy1 = m_scale_y.y();

			// Calculate transformed coordinates at x2,y2
			double xt = xe;
			double yt = ye;
			m_trans_dir.transform(ref xt, ref yt);
			int x2 = agg_basics.iround(xt * subpixel_scale);
			int y2 = agg_basics.iround(yt * subpixel_scale);

			double delta = 1 / (double)subpixel_scale;
			double dx;
			double dy;

			// Calculate scale by X at x2,y2
			dx = xt + delta;
			dy = yt;
			m_trans_inv.transform(ref dx, ref dy);
			dx -= xe;
			dy -= ye;
			int sx2 = (int)agg_basics.uround(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

			// Calculate scale by Y at x2,y2
			dx = xt;
			dy = yt + delta;
			m_trans_inv.transform(ref dx, ref dy);
			dx -= xe;
			dy -= ye;
			int sy2 = (int)agg_basics.uround(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

			// Initialize the interpolators
			m_coord_x = new dda2_line_interpolator(x1, x2, (int)len);
			m_coord_y = new dda2_line_interpolator(y1, y2, (int)len);
			m_scale_x = new dda2_line_interpolator(sx1, sx2, (int)len);
			m_scale_y = new dda2_line_interpolator(sy1, sy2, (int)len);
		}
		//----------------------------------------------------------------
		public void begin(double x, double y, int len)
		{
			// Calculate transformed coordinates at x1,y1
			double xt = x;
			double yt = y;
			m_trans_dir.transform(ref xt, ref yt);
			int x1 = agg_basics.iround(xt * subpixel_scale);
			int y1 = agg_basics.iround(yt * subpixel_scale);

			double dx;
			double dy;
			double delta = 1 / (double)subpixel_scale;

			// Calculate scale by X at x1,y1
			dx = xt + delta;
			dy = yt;
			m_trans_inv.transform(ref dx, ref dy);
			dx -= x;
			dy -= y;
			int sx1 = (int)agg_basics.uround(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

			// Calculate scale by Y at x1,y1
			dx = xt;
			dy = yt + delta;
			m_trans_inv.transform(ref dx, ref dy);
			dx -= x;
			dy -= y;
			int sy1 = (int)agg_basics.uround(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

			// Calculate transformed coordinates at x2,y2
			x += len;
			xt = x;
			yt = y;
			m_trans_dir.transform(ref xt, ref yt);
			int x2 = agg_basics.iround(xt * subpixel_scale);
			int y2 = agg_basics.iround(yt * subpixel_scale);

			// Calculate scale by X at x2,y2
			dx = xt + delta;
			dy = yt;
			m_trans_inv.transform(ref dx, ref dy);
			dx -= x;
			dy -= y;
			int sx2 = (int)agg_basics.uround(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

			// Calculate scale by Y at x2,y2
			dx = xt;
			dy = yt + delta;
			m_trans_inv.transform(ref dx, ref dy);
			dx -= x;
			dy -= y;
			int sy2 = (int)agg_basics.uround(subpixel_scale / Math.Sqrt(dx * dx + dy * dy)) >> subpixel_shift;

			// Initialize the interpolators
			m_coord_x = new dda2_line_interpolator(x1, x2, (int)len);
			m_coord_y = new dda2_line_interpolator(y1, y2, (int)len);
			m_scale_x = new dda2_line_interpolator(sx1, sx2, (int)len);
			m_scale_y = new dda2_line_interpolator(sy1, sy2, (int)len);
		}
Esempio n. 11
0
		public line_interpolator_aa_base(OutlineRenderer ren, line_parameters lp)
		{
			m_lp = lp;
			m_li = new dda2_line_interpolator(lp.vertical ? LineAABasics.line_dbl_hr(lp.x2 - lp.x1) : LineAABasics.line_dbl_hr(lp.y2 - lp.y1),
				lp.vertical ? Math.Abs(lp.y2 - lp.y1) : Math.Abs(lp.x2 - lp.x1) + 1);
			m_ren = ren;
			m_len = ((lp.vertical == (lp.inc > 0)) ? -lp.len : lp.len);
			m_x = (lp.x1 >> LineAABasics.line_subpixel_shift);
			m_y = (lp.y1 >> LineAABasics.line_subpixel_shift);
			m_old_x = (m_x);
			m_old_y = (m_y);
			m_count = ((lp.vertical ? Math.Abs((lp.y2 >> LineAABasics.line_subpixel_shift) - m_y) :
								   Math.Abs((lp.x2 >> LineAABasics.line_subpixel_shift) - m_x)));
			m_width = (ren.subpixel_width());
			//m_max_extent(m_width >> (line_subpixel_shift - 2));
			m_max_extent = ((m_width + LineAABasics.line_subpixel_mask) >> LineAABasics.line_subpixel_shift);
			m_step = 0;

			dda2_line_interpolator li = new dda2_line_interpolator(0,
				lp.vertical ? (lp.dy << LineAABasics.line_subpixel_shift) : (lp.dx << LineAABasics.line_subpixel_shift),
				lp.len);

			int i;
			int stop = m_width + LineAABasics.line_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;
		}