//---------------------------------------------------------------- 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 = AggBasics.iround(xt * SUBPIXEL_SCALE); int y1 = AggBasics.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)AggBasics.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)AggBasics.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 = AggBasics.iround(xt * SUBPIXEL_SCALE); int y2 = AggBasics.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)AggBasics.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)AggBasics.uround(SUBPIXEL_SCALE / Math.Sqrt(dx * dx + dy * dy)) >> SUBPIXEL_SHIFT; // Initialize the interpolators m_coord_x = new LineInterpolatorDDA2(x1, x2, (int)len); m_coord_y = new LineInterpolatorDDA2(y1, y2, (int)len); m_scale_x = new LineInterpolatorDDA2(sx1, sx2, (int)len); m_scale_y = new LineInterpolatorDDA2(sy1, sy2, (int)len); }
public LineInterpolatorAABase(OutlineRenderer ren, LineParameters lp) { 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_ren = ren; 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 void ReSync(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 = AggBasics.iround(xt * SUBPIXEL_SCALE); int y2 = AggBasics.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)AggBasics.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)AggBasics.uround(SUBPIXEL_SCALE / Math.Sqrt(dx * dx + dy * dy)) >> SUBPIXEL_SHIFT; // Initialize the interpolators m_coord_x = new LineInterpolatorDDA2(x1, x2, (int)len); m_coord_y = new LineInterpolatorDDA2(y1, y2, (int)len); m_scale_x = new LineInterpolatorDDA2(sx1, sx2, (int)len); m_scale_y = new LineInterpolatorDDA2(sy1, sy2, (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 = AggBasics.iround(tx * (double)SUB_PIXEL_SCALE); int y1 = AggBasics.iround(ty * (double)SUB_PIXEL_SCALE); tx = x + len; ty = y; m_trans.Transform(ref tx, ref ty); int x2 = AggBasics.iround(tx * (double)SUB_PIXEL_SCALE); int y2 = AggBasics.iround(ty * (double)SUB_PIXEL_SCALE); m_li_x = new LineInterpolatorDDA2(x1, x2, (int)len); m_li_y = new LineInterpolatorDDA2(y1, y2, (int)len); }
//-------------------------------------------------------------------- public LineInterpolatorBresenham(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 LineInterpolatorDDA2(m_ver ? x1 : y1, m_ver ? x2 : y2, (int)m_len); }
//-------------------------------------------------------------------- public LineInterpolatorBresenham(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 LineInterpolatorDDA2(m_ver ? x1 : y1, m_ver ? x2 : y2, (int)m_len); }
//---------------------------------------------------------------- public void ReSync(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 = AggBasics.iround(xt * SUBPIXEL_SCALE); int y2 = AggBasics.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)AggBasics.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)AggBasics.uround(SUBPIXEL_SCALE / Math.Sqrt(dx * dx + dy * dy)) >> SUBPIXEL_SHIFT; // Initialize the interpolators m_coord_x = new LineInterpolatorDDA2(x1, x2, (int)len); m_coord_y = new LineInterpolatorDDA2(y1, y2, (int)len); m_scale_x = new LineInterpolatorDDA2(sx1, sx2, (int)len); m_scale_y = new LineInterpolatorDDA2(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 = AggBasics.iround(xt * SUBPIXEL_SCALE); int y1 = AggBasics.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)AggBasics.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)AggBasics.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 = AggBasics.iround(xt * SUBPIXEL_SCALE); int y2 = AggBasics.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)AggBasics.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)AggBasics.uround(SUBPIXEL_SCALE / Math.Sqrt(dx * dx + dy * dy)) >> SUBPIXEL_SHIFT; // Initialize the interpolators m_coord_x = new LineInterpolatorDDA2(x1, x2, (int)len); m_coord_y = new LineInterpolatorDDA2(y1, y2, (int)len); m_scale_x = new LineInterpolatorDDA2(sx1, sx2, (int)len); m_scale_y = new LineInterpolatorDDA2(sy1, sy2, (int)len); }
//---------------------------------------------------------------- public void ReSync(double xe, double ye, int len) { m_trans.Transform(ref xe, ref ye); m_li_x = new LineInterpolatorDDA2(m_li_x.Y, AggBasics.iround(xe * (double)SUB_PIXEL_SCALE), (int)len); m_li_y = new LineInterpolatorDDA2(m_li_y.Y, AggBasics.iround(ye * (double)SUB_PIXEL_SCALE), (int)len); }