예제 #1
0
        public static void bisectrix(line_parameters l1,
                                     line_parameters l2,
                                     out int x, out int y)
        {
            double k  = (double)(l2.len) / (double)(l1.len);
            double tx = l2.x2 - (l2.x1 - l1.x1) * k;
            double ty = l2.y2 - (l2.y1 - l1.y1) * k;

            //All bisectrices must be on the right of the line
            //If the next point is on the left (l1 => l2.2)
            //then the bisectix should be rotated by 180 degrees.
            if ((double)(l2.x2 - l2.x1) * (double)(l2.y1 - l1.y1) <
                (double)(l2.y2 - l2.y1) * (double)(l2.x1 - l1.x1) + 100.0)
            {
                tx -= (tx - l2.x1) * 2.0;
                ty -= (ty - l2.y1) * 2.0;
            }

            // Check if the bisectrix is too short
            double dx = tx - l2.x1;
            double dy = ty - l2.y1;

            if ((int)Math.Sqrt(dx * dx + dy * dy) < line_subpixel_scale)
            {
                x = (l2.x1 + l2.x1 + (l2.y1 - l1.y1) + (l2.y2 - l2.y1)) >> 1;
                y = (l2.y1 + l2.y1 - (l2.x1 - l1.x1) - (l2.x2 - l2.x1)) >> 1;
                return;
            }

            x = agg_basics.iround(tx);
            y = agg_basics.iround(ty);
        }
예제 #2
0
        public void line3_no_clip(line_parameters lp,
                                  int sx, int sy, int ex, int ey)
        {
            throw new NotImplementedException();

            /*
             *                                  if(lp.len > LineAABasics.line_max_length)
             *                                  {
             *                                          line_parameters lp1, lp2;
             *                                          lp.divide(lp1, lp2);
             *                                          int mx = lp1.x2 + (lp1.y2 - lp1.y1);
             *                                          int my = lp1.y2 - (lp1.x2 - lp1.x1);
             *                                          line3_no_clip(lp1, (lp.x1 + sx) >> 1, (lp.y1 + sy) >> 1, mx, my);
             *                                          line3_no_clip(lp2, mx, my, (lp.x2 + ex) >> 1, (lp.y2 + ey) >> 1);
             *                                          return;
             *                                  }
             *
             *                                  LineAABasics.fix_degenerate_bisectrix_start(lp, ref sx, ref sy);
             *                                  LineAABasics.fix_degenerate_bisectrix_end(lp, ref ex, ref ey);
             *                                  line_interpolator_image li = new line_interpolator_image(this, lp,
             *                                                                                                            sx, sy,
             *                                                                                                            ex, ey,
             *                                                                                                            m_start, m_scale_x);
             *                                  if(li.vertical())
             *                                  {
             *                                          while(li.step_ver());
             *                                  }
             *                                  else
             *                                  {
             *                                          while(li.step_hor());
             *                                  }
             *                                  m_start += uround(lp.len / m_scale_x);
             */
        }
예제 #3
0
        public static void fix_degenerate_bisectrix_end(line_parameters lp,
                                                        ref int x, ref int y)
        {
            int d = agg_basics.iround(((double)(x - lp.x2) * (double)(lp.y2 - lp.y1) -
                                       (double)(y - lp.y2) * (double)(lp.x2 - lp.x1)) / lp.len);

            if (d < line_subpixel_scale / 2)
            {
                x = lp.x2 + (lp.y2 - lp.y1);
                y = lp.y2 - (lp.x2 - lp.x1);
            }
        }
예제 #4
0
        //---------------------------------------------------------------------
        public void divide(out line_parameters lp1, out line_parameters lp2)
        {
            int xmid = (x1 + x2) >> 1;
            int ymid = (y1 + y2) >> 1;
            int len2 = len >> 1;

            lp1 = this; // it is a struct so this is a copy
            lp2 = this; // it is a struct so this is a copy

            lp1.x2  = xmid;
            lp1.y2  = ymid;
            lp1.len = len2;
            lp1.dx  = Math.Abs(lp1.x2 - lp1.x1);
            lp1.dy  = Math.Abs(lp1.y2 - lp1.y1);

            lp2.x1  = xmid;
            lp2.y1  = ymid;
            lp2.len = len2;
            lp2.dx  = Math.Abs(lp2.x2 - lp2.x1);
            lp2.dy  = Math.Abs(lp2.y2 - lp2.y1);
        }
예제 #5
0
        //---------------------------------------------------------------------
        public line_interpolator_image(renderer_outline_aa ren, line_parameters lp,
                                       int sx, int sy, int ex, int ey,
                                       int pattern_start,
                                       double scale_x)
        {
            throw new NotImplementedException();

/*
 *          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_di = new distance_interpolator4(lp.x1, lp.y1, lp.x2, lp.y2, sx, sy, ex, ey, lp.len, scale_x,
 *               lp.x1 & ~LineAABasics.line_subpixel_mask, lp.y1 & ~LineAABasics.line_subpixel_mask);
 *          m_ren=ren;
 *          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 >> (LineAABasics.line_subpixel_shift - 2));
 *          m_max_extent = ((m_width + LineAABasics.line_subpixel_scale) >> LineAABasics.line_subpixel_shift);
 *          m_start=(pattern_start + (m_max_extent + 2) * ren.pattern_width());
 *          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);
 *
 *          uint i;
 *          int stop = m_width + LineAABasics.line_subpixel_scale * 2;
 *          for(i = 0; i < max_half_width; ++i)
 *          {
 *              m_dist_pos[i] = li.y();
 *              if(m_dist_pos[i] >= stop) break;
 ++li;
 *          }
 *          m_dist_pos[i] = 0x7FFF0000;
 *
 *          int dist1_start;
 *          int dist2_start;
 *          int npix = 1;
 *
 *          if(lp.vertical)
 *          {
 *              do
 *              {
 *                  --m_li;
 *                  m_y -= lp.inc;
 *                  m_x = (m_lp.x1 + m_li.y()) >> LineAABasics.line_subpixel_shift;
 *
 *                  if(lp.inc > 0) m_di.dec_y(m_x - m_old_x);
 *                  else           m_di.inc_y(m_x - m_old_x);
 *
 *                  m_old_x = m_x;
 *
 *                  dist1_start = dist2_start = m_di.dist_start();
 *
 *                  int dx = 0;
 *                  if(dist1_start < 0) ++npix;
 *                  do
 *                  {
 *                      dist1_start += m_di.dy_start();
 *                      dist2_start -= m_di.dy_start();
 *                      if(dist1_start < 0) ++npix;
 *                      if(dist2_start < 0) ++npix;
 ++dx;
 *                  }
 *                  while(m_dist_pos[dx] <= m_width);
 *                  if(npix == 0) break;
 *
 *                  npix = 0;
 *              }
 *              while(--m_step >= -m_max_extent);
 *          }
 *          else
 *          {
 *              do
 *              {
 *                  --m_li;
 *
 *                  m_x -= lp.inc;
 *                  m_y = (m_lp.y1 + m_li.y()) >> LineAABasics.line_subpixel_shift;
 *
 *                  if(lp.inc > 0) m_di.dec_x(m_y - m_old_y);
 *                  else           m_di.inc_x(m_y - m_old_y);
 *
 *                  m_old_y = m_y;
 *
 *                  dist1_start = dist2_start = m_di.dist_start();
 *
 *                  int dy = 0;
 *                  if(dist1_start < 0) ++npix;
 *                  do
 *                  {
 *                      dist1_start -= m_di.dx_start();
 *                      dist2_start += m_di.dx_start();
 *                      if(dist1_start < 0) ++npix;
 *                      if(dist2_start < 0) ++npix;
 ++dy;
 *                  }
 *                  while(m_dist_pos[dy] <= m_width);
 *                  if(npix == 0) break;
 *
 *                  npix = 0;
 *              }
 *              while(--m_step >= -m_max_extent);
 *          }
 *          m_li.adjust_forward();
 *          m_step -= m_max_extent;
 */
        }
예제 #6
0
		//typedef Renderer renderer_type;
		//typedef line_interpolator_aa_base<Renderer> base_type;

		//---------------------------------------------------------------------
		public line_interpolator_aa1(OutlineRenderer ren, line_parameters lp,
							  int sx, int sy)
			:
			base(ren, lp)
		{
			m_di = new distance_interpolator2(lp.x1, lp.y1, lp.x2, lp.y2, sx, sy,
				 lp.x1 & ~LineAABasics.line_subpixel_mask, lp.y1 & ~LineAABasics.line_subpixel_mask);

			int dist1_start;
			int dist2_start;

			int npix = 1;

			if (lp.vertical)
			{
				do
				{
					base.m_li.Prev();
					base.m_y -= lp.inc;
					base.m_x = (base.m_lp.x1 + base.m_li.y()) >> LineAABasics.line_subpixel_shift;

					if (lp.inc > 0) m_di.dec_y(base.m_x - base.m_old_x);
					else m_di.inc_y(base.m_x - base.m_old_x);

					base.m_old_x = base.m_x;

					dist1_start = dist2_start = m_di.dist_start();

					int dx = 0;
					if (dist1_start < 0) ++npix;
					do
					{
						dist1_start += m_di.dy_start();
						dist2_start -= m_di.dy_start();
						if (dist1_start < 0) ++npix;
						if (dist2_start < 0) ++npix;
						++dx;
					}
					while (base.m_dist[dx] <= base.m_width);
					--base.m_step;
					if (npix == 0) break;
					npix = 0;
				}
				while (base.m_step >= -base.m_max_extent);
			}
			else
			{
				do
				{
					base.m_li.Prev();
					base.m_x -= lp.inc;
					base.m_y = (base.m_lp.y1 + base.m_li.y()) >> LineAABasics.line_subpixel_shift;

					if (lp.inc > 0) m_di.dec_x(base.m_y - base.m_old_y);
					else m_di.inc_x(base.m_y - base.m_old_y);

					base.m_old_y = base.m_y;

					dist1_start = dist2_start = m_di.dist_start();

					int dy = 0;
					if (dist1_start < 0) ++npix;
					do
					{
						dist1_start -= m_di.dx_start();
						dist2_start += m_di.dx_start();
						if (dist1_start < 0) ++npix;
						if (dist2_start < 0) ++npix;
						++dy;
					}
					while (base.m_dist[dy] <= base.m_width);
					--base.m_step;
					if (npix == 0) break;
					npix = 0;
				}
				while (base.m_step >= -base.m_max_extent);
			}
			base.m_li.adjust_forward();
		}
예제 #7
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;
		}
예제 #8
0
		public void line3_no_clip(line_parameters lp,
						   int sx, int sy, int ex, int ey)
		{
			if (lp.len > LineAABasics.line_max_length)
			{
				line_parameters lp1, lp2;
				lp.divide(out lp1, out lp2);
				int mx = lp1.x2 + (lp1.y2 - lp1.y1);
				int my = lp1.y2 - (lp1.x2 - lp1.x1);
				line3_no_clip(lp1, (lp.x1 + sx) >> 1, (lp.y1 + sy) >> 1, mx, my);
				line3_no_clip(lp2, mx, my, (lp.x2 + ex) >> 1, (lp.y2 + ey) >> 1);
				return;
			}

			LineAABasics.fix_degenerate_bisectrix_start(lp, ref sx, ref sy);
			LineAABasics.fix_degenerate_bisectrix_end(lp, ref ex, ref ey);
			line_interpolator_aa3 li = new line_interpolator_aa3(this, lp, sx, sy, ex, ey);
			if (li.vertical())
			{
				while (li.step_ver()) ;
			}
			else
			{
				while (li.step_hor()) ;
			}
		}
예제 #9
0
		public override void line0(line_parameters lp)
		{
			if (doClipping)
			{
				int x1 = lp.x1;
				int y1 = lp.y1;
				int x2 = lp.x2;
				int y2 = lp.y2;
				int flags = ClipLiangBarsky.clip_line_segment(ref x1, ref y1, ref x2, ref y2, clippingRectangle);
				if ((flags & 4) == 0)
				{
					if (flags != 0)
					{
						line_parameters lp2 = new line_parameters(x1, y1, x2, y2,
										   agg_basics.uround(agg_math.calc_distance(x1, y1, x2, y2)));
						line0_no_clip(lp2);
					}
					else
					{
						line0_no_clip(lp);
					}
				}
			}
			else
			{
				line0_no_clip(lp);
			}
		}
예제 #10
0
		public abstract void line3(line_parameters lp, int sx, int sy, int ex, int ey);
예제 #11
0
		public override void line2(line_parameters lp, int ex, int ey)
		{
		}
예제 #12
0
		public override void line1(line_parameters lp, int sx, int sy)
		{
		}
예제 #13
0
		public override void line0(line_parameters lp)
		{
		}
예제 #14
0
        //---------------------------------------------------------------------
        public line_interpolator_image(renderer_outline_aa ren, line_parameters lp,
                                int sx, int sy, int ex, int ey,
                                int pattern_start,
                                double scale_x)
        {
            throw new NotImplementedException();
/*
            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_di = new distance_interpolator4(lp.x1, lp.y1, lp.x2, lp.y2, sx, sy, ex, ey, lp.len, scale_x,
                 lp.x1 & ~LineAABasics.line_subpixel_mask, lp.y1 & ~LineAABasics.line_subpixel_mask);
            m_ren=ren;
            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 >> (LineAABasics.line_subpixel_shift - 2));
            m_max_extent = ((m_width + LineAABasics.line_subpixel_scale) >> LineAABasics.line_subpixel_shift);
            m_start=(pattern_start + (m_max_extent + 2) * ren.pattern_width());
            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);

            uint i;
            int stop = m_width + LineAABasics.line_subpixel_scale * 2;
            for(i = 0; i < max_half_width; ++i)
            {
                m_dist_pos[i] = li.y();
                if(m_dist_pos[i] >= stop) break;
                ++li;
            }
            m_dist_pos[i] = 0x7FFF0000;

            int dist1_start;
            int dist2_start;
            int npix = 1;

            if(lp.vertical)
            {
                do
                {
                    --m_li;
                    m_y -= lp.inc;
                    m_x = (m_lp.x1 + m_li.y()) >> LineAABasics.line_subpixel_shift;

                    if(lp.inc > 0) m_di.dec_y(m_x - m_old_x);
                    else           m_di.inc_y(m_x - m_old_x);

                    m_old_x = m_x;

                    dist1_start = dist2_start = m_di.dist_start();

                    int dx = 0;
                    if(dist1_start < 0) ++npix;
                    do
                    {
                        dist1_start += m_di.dy_start();
                        dist2_start -= m_di.dy_start();
                        if(dist1_start < 0) ++npix;
                        if(dist2_start < 0) ++npix;
                        ++dx;
                    }
                    while(m_dist_pos[dx] <= m_width);
                    if(npix == 0) break;

                    npix = 0;
                }
                while(--m_step >= -m_max_extent);
            }
            else
            {
                do
                {
                    --m_li;

                    m_x -= lp.inc;
                    m_y = (m_lp.y1 + m_li.y()) >> LineAABasics.line_subpixel_shift;

                    if(lp.inc > 0) m_di.dec_x(m_y - m_old_y);
                    else           m_di.inc_x(m_y - m_old_y);

                    m_old_y = m_y;

                    dist1_start = dist2_start = m_di.dist_start();

                    int dy = 0;
                    if(dist1_start < 0) ++npix;
                    do
                    {
                        dist1_start -= m_di.dx_start();
                        dist2_start += m_di.dx_start();
                        if(dist1_start < 0) ++npix;
                        if(dist2_start < 0) ++npix;
                        ++dy;
                    }
                    while(m_dist_pos[dy] <= m_width);
                    if(npix == 0) break;

                    npix = 0;
                }
                while(--m_step >= -m_max_extent);
            }
            m_li.adjust_forward();
            m_step -= m_max_extent;
 */
        }
예제 #15
0
		public override void line3(line_parameters lp,
				   int sx, int sy, int ex, int ey)
		{
			throw new NotImplementedException();
			/*
						if(m_clipping)
						{
							int x1 = lp.x1;
							int y1 = lp.y1;
							int x2 = lp.x2;
							int y2 = lp.y2;
							uint flags = clip_line_segment(&x1, &y1, &x2, &y2, m_clip_box);
							int start = m_start;
							if((flags & 4) == 0)
							{
								if(flags)
								{
									line_parameters lp2(x1, y1, x2, y2,
													   uround(calc_distance(x1, y1, x2, y2)));
									if(flags & 1)
									{
										m_start += uround(calc_distance(lp.x1, lp.y1, x1, y1) / m_scale_x);
										sx = x1 + (y2 - y1);
										sy = y1 - (x2 - x1);
									}
									else
									{
										while(Math.Abs(sx - lp.x1) + Math.Abs(sy - lp.y1) > lp2.len)
										{
											sx = (lp.x1 + sx) >> 1;
											sy = (lp.y1 + sy) >> 1;
										}
									}
									if(flags & 2)
									{
										ex = x2 + (y2 - y1);
										ey = y2 - (x2 - x1);
									}
									else
									{
										while(Math.Abs(ex - lp.x2) + Math.Abs(ey - lp.y2) > lp2.len)
										{
											ex = (lp.x2 + ex) >> 1;
											ey = (lp.y2 + ey) >> 1;
										}
									}
									line3_no_clip(lp2, sx, sy, ex, ey);
								}
								else
								{
									line3_no_clip(lp, sx, sy, ex, ey);
								}
							}
							m_start = start + uround(lp.len / m_scale_x);
						}
						else
						{
							line3_no_clip(lp, sx, sy, ex, ey);
						}
			 */
		}
예제 #16
0
 public override void line1(line_parameters lp, int sx, int sy)
 {
 }
예제 #17
0
		public void line3_no_clip(line_parameters lp,
						   int sx, int sy, int ex, int ey)
		{
			throw new NotImplementedException();
			/*
						if(lp.len > LineAABasics.line_max_length)
						{
							line_parameters lp1, lp2;
							lp.divide(lp1, lp2);
							int mx = lp1.x2 + (lp1.y2 - lp1.y1);
							int my = lp1.y2 - (lp1.x2 - lp1.x1);
							line3_no_clip(lp1, (lp.x1 + sx) >> 1, (lp.y1 + sy) >> 1, mx, my);
							line3_no_clip(lp2, mx, my, (lp.x2 + ex) >> 1, (lp.y2 + ey) >> 1);
							return;
						}

						LineAABasics.fix_degenerate_bisectrix_start(lp, ref sx, ref sy);
						LineAABasics.fix_degenerate_bisectrix_end(lp, ref ex, ref ey);
						line_interpolator_image li = new line_interpolator_image(this, lp,
															  sx, sy,
															  ex, ey,
															  m_start, m_scale_x);
						if(li.vertical())
						{
							while(li.step_ver());
						}
						else
						{
							while(li.step_hor());
						}
						m_start += uround(lp.len / m_scale_x);
			 */
		}
예제 #18
0
		//---------------------------------------------------------------------
		public bool same_diagonal_quadrant(line_parameters lp)
		{
			return s_diagonal_quadrant[octant] == s_diagonal_quadrant[lp.octant];
		}
예제 #19
0
		public void line0_no_clip(line_parameters lp)
		{
			if (lp.len > LineAABasics.line_max_length)
			{
				line_parameters lp1, lp2;
				lp.divide(out lp1, out lp2);
				line0_no_clip(lp1);
				line0_no_clip(lp2);
				return;
			}

			line_interpolator_aa0 li = new line_interpolator_aa0(this, lp);
			if (li.count() != 0)
			{
				if (li.vertical())
				{
					while (li.step_ver()) ;
				}
				else
				{
					while (li.step_hor()) ;
				}
			}
		}
예제 #20
0
		//---------------------------------------------------------------------
		public void divide(out line_parameters lp1, out line_parameters lp2)
		{
			int xmid = (x1 + x2) >> 1;
			int ymid = (y1 + y2) >> 1;
			int len2 = len >> 1;

			lp1 = this; // it is a struct so this is a copy
			lp2 = this; // it is a struct so this is a copy

			lp1.x2 = xmid;
			lp1.y2 = ymid;
			lp1.len = len2;
			lp1.dx = Math.Abs(lp1.x2 - lp1.x1);
			lp1.dy = Math.Abs(lp1.y2 - lp1.y1);

			lp2.x1 = xmid;
			lp2.y1 = ymid;
			lp2.len = len2;
			lp2.dx = Math.Abs(lp2.x2 - lp2.x1);
			lp2.dy = Math.Abs(lp2.y2 - lp2.y1);
		}
예제 #21
0
		public void line2_no_clip(line_parameters lp, int ex, int ey)
		{
			if (lp.len > LineAABasics.line_max_length)
			{
				line_parameters lp1, lp2;
				lp.divide(out lp1, out lp2);
				line2_no_clip(lp1, lp1.x2 + (lp1.y2 - lp1.y1), lp1.y2 - (lp1.x2 - lp1.x1));
				line2_no_clip(lp2, (lp.x2 + ex) >> 1, (lp.y2 + ey) >> 1);
				return;
			}

			LineAABasics.fix_degenerate_bisectrix_end(lp, ref ex, ref ey);
			line_interpolator_aa2 li = new line_interpolator_aa2(this, lp, ex, ey);
			if (li.vertical())
			{
				while (li.step_ver()) ;
			}
			else
			{
				while (li.step_hor()) ;
			}
		}
예제 #22
0
		public static void bisectrix(line_parameters l1,
				   line_parameters l2,
				   out int x, out int y)
		{
			double k = (double)(l2.len) / (double)(l1.len);
			double tx = l2.x2 - (l2.x1 - l1.x1) * k;
			double ty = l2.y2 - (l2.y1 - l1.y1) * k;

			//All bisectrices must be on the right of the line
			//If the next point is on the left (l1 => l2.2)
			//then the bisectix should be rotated by 180 degrees.
			if ((double)(l2.x2 - l2.x1) * (double)(l2.y1 - l1.y1) <
			   (double)(l2.y2 - l2.y1) * (double)(l2.x1 - l1.x1) + 100.0)
			{
				tx -= (tx - l2.x1) * 2.0;
				ty -= (ty - l2.y1) * 2.0;
			}

			// Check if the bisectrix is too short
			double dx = tx - l2.x1;
			double dy = ty - l2.y1;
			if ((int)Math.Sqrt(dx * dx + dy * dy) < line_subpixel_scale)
			{
				x = (l2.x1 + l2.x1 + (l2.y1 - l1.y1) + (l2.y2 - l2.y1)) >> 1;
				y = (l2.y1 + l2.y1 - (l2.x1 - l1.x1) - (l2.x2 - l2.x1)) >> 1;
				return;
			}

			x = agg_basics.iround(tx);
			y = agg_basics.iround(ty);
		}
예제 #23
0
		public override void line3(line_parameters lp,
				   int sx, int sy, int ex, int ey)
		{
			if (doClipping)
			{
				int x1 = lp.x1;
				int y1 = lp.y1;
				int x2 = lp.x2;
				int y2 = lp.y2;
				int flags = ClipLiangBarsky.clip_line_segment(ref x1, ref y1, ref x2, ref y2, clippingRectangle);
				if ((flags & 4) == 0)
				{
					if (flags != 0)
					{
						line_parameters lp2 = new line_parameters(x1, y1, x2, y2,
							agg_basics.uround(agg_math.calc_distance(x1, y1, x2, y2)));
						if ((flags & 1) != 0)
						{
							sx = x1 + (y2 - y1);
							sy = y1 - (x2 - x1);
						}
						else
						{
							while (Math.Abs(sx - lp.x1) + Math.Abs(sy - lp.y1) > lp2.len)
							{
								sx = (lp.x1 + sx) >> 1;
								sy = (lp.y1 + sy) >> 1;
							}
						}
						if ((flags & 2) != 0)
						{
							ex = x2 + (y2 - y1);
							ey = y2 - (x2 - x1);
						}
						else
						{
							while (Math.Abs(ex - lp.x2) + Math.Abs(ey - lp.y2) > lp2.len)
							{
								ex = (lp.x2 + ex) >> 1;
								ey = (lp.y2 + ey) >> 1;
							}
						}
						line3_no_clip(lp2, sx, sy, ex, ey);
					}
					else
					{
						line3_no_clip(lp, sx, sy, ex, ey);
					}
				}
			}
			else
			{
				line3_no_clip(lp, sx, sy, ex, ey);
			}
		}
예제 #24
0
		public static void fix_degenerate_bisectrix_end(line_parameters lp,
											 ref int x, ref int y)
		{
			int d = agg_basics.iround(((double)(x - lp.x2) * (double)(lp.y2 - lp.y1) -
							(double)(y - lp.y2) * (double)(lp.x2 - lp.x1)) / lp.len);
			if (d < line_subpixel_scale / 2)
			{
				x = lp.x2 + (lp.y2 - lp.y1);
				y = lp.y2 - (lp.x2 - lp.x1);
			}
		}
예제 #25
0
		//typedef Renderer renderer_type;
		//typedef line_interpolator_aa_base<Renderer> base_type;

		//---------------------------------------------------------------------
		public line_interpolator_aa0(OutlineRenderer ren, line_parameters lp)
			: base(ren, lp)
		{
			m_di = new distance_interpolator1(lp.x1, lp.y1, lp.x2, lp.y2,
				 lp.x1 & ~LineAABasics.line_subpixel_mask, lp.y1 & ~LineAABasics.line_subpixel_mask);

			m_li.adjust_forward();
		}
예제 #26
0
		//typedef Renderer renderer_type;
		//typedef line_interpolator_aa_base<Renderer> base_type;

		//---------------------------------------------------------------------
		public line_interpolator_aa2(OutlineRenderer ren, line_parameters lp,
							  int ex, int ey)
			:
			base(ren, lp)
		{
			m_di = new distance_interpolator2(lp.x1, lp.y1, lp.x2, lp.y2, ex, ey,
				 lp.x1 & ~LineAABasics.line_subpixel_mask, lp.y1 & ~LineAABasics.line_subpixel_mask,
				 0);
			base.m_li.adjust_forward();
			base.m_step -= base.m_max_extent;
		}
예제 #27
0
        public void render(bool close_polygon)
        {
            m_src_vertices.close(close_polygon);
            draw_vars      dv = new draw_vars();
            line_aa_vertex v;
            int            x1;
            int            y1;
            int            x2;
            int            y2;
            int            lprev;

            if (close_polygon)
            {
                if (m_src_vertices.size() >= 3)
                {
                    dv.idx = 2;

                    v     = m_src_vertices[m_src_vertices.size() - 1];
                    x1    = v.x;
                    y1    = v.y;
                    lprev = v.len;

                    v        = m_src_vertices[0];
                    x2       = v.x;
                    y2       = v.y;
                    dv.lcurr = v.len;
                    line_parameters prev = new line_parameters(x1, y1, x2, y2, lprev);

                    v        = m_src_vertices[1];
                    dv.x1    = v.x;
                    dv.y1    = v.y;
                    dv.lnext = v.len;
                    dv.curr  = new line_parameters(x2, y2, dv.x1, dv.y1, dv.lcurr);

                    v       = m_src_vertices[dv.idx];
                    dv.x2   = v.x;
                    dv.y2   = v.y;
                    dv.next = new line_parameters(dv.x1, dv.y1, dv.x2, dv.y2, dv.lnext);

                    dv.xb1 = 0;
                    dv.yb1 = 0;
                    dv.xb2 = 0;
                    dv.yb2 = 0;

                    switch (m_line_join)
                    {
                    case outline_aa_join_e.outline_no_join:
                        dv.flags = 3;
                        break;

                    case outline_aa_join_e.outline_miter_join:
                    case outline_aa_join_e.outline_round_join:
                        dv.flags =
                            (prev.diagonal_quadrant() == dv.curr.diagonal_quadrant() ? 1 : 0) |
                            ((dv.curr.diagonal_quadrant() == dv.next.diagonal_quadrant() ? 1 : 0) << 1);
                        break;

                    case outline_aa_join_e.outline_miter_accurate_join:
                        dv.flags = 0;
                        break;
                    }

                    if ((dv.flags & 1) == 0 && m_line_join != outline_aa_join_e.outline_round_join)
                    {
                        LineAABasics.bisectrix(prev, dv.curr, out dv.xb1, out dv.yb1);
                    }

                    if ((dv.flags & 2) == 0 && m_line_join != outline_aa_join_e.outline_round_join)
                    {
                        LineAABasics.bisectrix(dv.curr, dv.next, out dv.xb2, out dv.yb2);
                    }
                    draw(ref dv, 0, m_src_vertices.size());
                }
            }
            else
            {
                switch (m_src_vertices.size())
                {
                case 0:
                case 1:
                    break;

                case 2:
                {
                    v     = m_src_vertices[0];
                    x1    = v.x;
                    y1    = v.y;
                    lprev = v.len;
                    v     = m_src_vertices[1];
                    x2    = v.x;
                    y2    = v.y;
                    line_parameters lp = new line_parameters(x1, y1, x2, y2, lprev);
                    if (m_round_cap)
                    {
                        m_ren.semidot(cmp_dist_start, x1, y1, x1 + (y2 - y1), y1 - (x2 - x1));
                    }
                    m_ren.line3(lp,
                                x1 + (y2 - y1),
                                y1 - (x2 - x1),
                                x2 + (y2 - y1),
                                y2 - (x2 - x1));
                    if (m_round_cap)
                    {
                        m_ren.semidot(cmp_dist_end, x2, y2, x2 + (y2 - y1), y2 - (x2 - x1));
                    }
                }
                break;

                case 3:
                {
                    int x3, y3;
                    int lnext;
                    v     = m_src_vertices[0];
                    x1    = v.x;
                    y1    = v.y;
                    lprev = v.len;
                    v     = m_src_vertices[1];
                    x2    = v.x;
                    y2    = v.y;
                    lnext = v.len;
                    v     = m_src_vertices[2];
                    x3    = v.x;
                    y3    = v.y;
                    line_parameters lp1 = new line_parameters(x1, y1, x2, y2, lprev);
                    line_parameters lp2 = new line_parameters(x2, y2, x3, y3, lnext);

                    if (m_round_cap)
                    {
                        m_ren.semidot(cmp_dist_start, x1, y1, x1 + (y2 - y1), y1 - (x2 - x1));
                    }

                    if (m_line_join == outline_aa_join_e.outline_round_join)
                    {
                        m_ren.line3(lp1, x1 + (y2 - y1), y1 - (x2 - x1),
                                    x2 + (y2 - y1), y2 - (x2 - x1));

                        m_ren.pie(x2, y2, x2 + (y2 - y1), y2 - (x2 - x1),
                                  x2 + (y3 - y2), y2 - (x3 - x2));

                        m_ren.line3(lp2, x2 + (y3 - y2), y2 - (x3 - x2),
                                    x3 + (y3 - y2), y3 - (x3 - x2));
                    }
                    else
                    {
                        LineAABasics.bisectrix(lp1, lp2, out dv.xb1, out dv.yb1);
                        m_ren.line3(lp1, x1 + (y2 - y1), y1 - (x2 - x1),
                                    dv.xb1, dv.yb1);

                        m_ren.line3(lp2, dv.xb1, dv.yb1,
                                    x3 + (y3 - y2), y3 - (x3 - x2));
                    }
                    if (m_round_cap)
                    {
                        m_ren.semidot(cmp_dist_end, x3, y3, x3 + (y3 - y2), y3 - (x3 - x2));
                    }
                }
                break;

                default:
                {
                    dv.idx = 3;

                    v     = m_src_vertices[0];
                    x1    = v.x;
                    y1    = v.y;
                    lprev = v.len;

                    v        = m_src_vertices[1];
                    x2       = v.x;
                    y2       = v.y;
                    dv.lcurr = v.len;
                    line_parameters prev = new line_parameters(x1, y1, x2, y2, lprev);

                    v        = m_src_vertices[2];
                    dv.x1    = v.x;
                    dv.y1    = v.y;
                    dv.lnext = v.len;
                    dv.curr  = new line_parameters(x2, y2, dv.x1, dv.y1, dv.lcurr);

                    v       = m_src_vertices[dv.idx];
                    dv.x2   = v.x;
                    dv.y2   = v.y;
                    dv.next = new line_parameters(dv.x1, dv.y1, dv.x2, dv.y2, dv.lnext);

                    dv.xb1 = 0;
                    dv.yb1 = 0;
                    dv.xb2 = 0;
                    dv.yb2 = 0;

                    switch (m_line_join)
                    {
                    case outline_aa_join_e.outline_no_join:
                        dv.flags = 3;
                        break;

                    case outline_aa_join_e.outline_miter_join:
                    case outline_aa_join_e.outline_round_join:
                        dv.flags =
                            (prev.diagonal_quadrant() == dv.curr.diagonal_quadrant() ? 1 : 0) |
                            ((dv.curr.diagonal_quadrant() == dv.next.diagonal_quadrant() ? 1 : 0) << 1);
                        break;

                    case outline_aa_join_e.outline_miter_accurate_join:
                        dv.flags = 0;
                        break;
                    }

                    if (m_round_cap)
                    {
                        m_ren.semidot(cmp_dist_start, x1, y1, x1 + (y2 - y1), y1 - (x2 - x1));
                    }
                    if ((dv.flags & 1) == 0)
                    {
                        if (m_line_join == outline_aa_join_e.outline_round_join)
                        {
                            m_ren.line3(prev, x1 + (y2 - y1), y1 - (x2 - x1),
                                        x2 + (y2 - y1), y2 - (x2 - x1));
                            m_ren.pie(prev.x2, prev.y2,
                                      x2 + (y2 - y1), y2 - (x2 - x1),
                                      dv.curr.x1 + (dv.curr.y2 - dv.curr.y1),
                                      dv.curr.y1 - (dv.curr.x2 - dv.curr.x1));
                        }
                        else
                        {
                            LineAABasics.bisectrix(prev, dv.curr, out dv.xb1, out dv.yb1);
                            m_ren.line3(prev, x1 + (y2 - y1), y1 - (x2 - x1),
                                        dv.xb1, dv.yb1);
                        }
                    }
                    else
                    {
                        m_ren.line1(prev,
                                    x1 + (y2 - y1),
                                    y1 - (x2 - x1));
                    }
                    if ((dv.flags & 2) == 0 && m_line_join != outline_aa_join_e.outline_round_join)
                    {
                        LineAABasics.bisectrix(dv.curr, dv.next, out dv.xb2, out dv.yb2);
                    }

                    draw(ref dv, 1, m_src_vertices.size() - 2);

                    if ((dv.flags & 1) == 0)
                    {
                        if (m_line_join == outline_aa_join_e.outline_round_join)
                        {
                            m_ren.line3(dv.curr,
                                        dv.curr.x1 + (dv.curr.y2 - dv.curr.y1),
                                        dv.curr.y1 - (dv.curr.x2 - dv.curr.x1),
                                        dv.curr.x2 + (dv.curr.y2 - dv.curr.y1),
                                        dv.curr.y2 - (dv.curr.x2 - dv.curr.x1));
                        }
                        else
                        {
                            m_ren.line3(dv.curr, dv.xb1, dv.yb1,
                                        dv.curr.x2 + (dv.curr.y2 - dv.curr.y1),
                                        dv.curr.y2 - (dv.curr.x2 - dv.curr.x1));
                        }
                    }
                    else
                    {
                        m_ren.line2(dv.curr,
                                    dv.curr.x2 + (dv.curr.y2 - dv.curr.y1),
                                    dv.curr.y2 - (dv.curr.x2 - dv.curr.x1));
                    }
                    if (m_round_cap)
                    {
                        m_ren.semidot(cmp_dist_end, dv.curr.x2, dv.curr.y2,
                                      dv.curr.x2 + (dv.curr.y2 - dv.curr.y1),
                                      dv.curr.y2 - (dv.curr.x2 - dv.curr.x1));
                    }
                }
                break;
                }
            }
            m_src_vertices.remove_all();
        }
예제 #28
0
		public abstract void line0(line_parameters lp);
예제 #29
0
        public override void line3(line_parameters lp,
                                   int sx, int sy, int ex, int ey)
        {
            throw new NotImplementedException();

            /*
             *                                  if(m_clipping)
             *                                  {
             *                                          int x1 = lp.x1;
             *                                          int y1 = lp.y1;
             *                                          int x2 = lp.x2;
             *                                          int y2 = lp.y2;
             *                                          uint flags = clip_line_segment(&x1, &y1, &x2, &y2, m_clip_box);
             *                                          int start = m_start;
             *                                          if((flags & 4) == 0)
             *                                          {
             *                                                  if(flags)
             *                                                  {
             *                                                          line_parameters lp2(x1, y1, x2, y2,
             *                                                                                             uround(calc_distance(x1, y1, x2, y2)));
             *                                                          if(flags & 1)
             *                                                          {
             *                                                                  m_start += uround(calc_distance(lp.x1, lp.y1, x1, y1) / m_scale_x);
             *                                                                  sx = x1 + (y2 - y1);
             *                                                                  sy = y1 - (x2 - x1);
             *                                                          }
             *                                                          else
             *                                                          {
             *                                                                  while(Math.Abs(sx - lp.x1) + Math.Abs(sy - lp.y1) > lp2.len)
             *                                                                  {
             *                                                                          sx = (lp.x1 + sx) >> 1;
             *                                                                          sy = (lp.y1 + sy) >> 1;
             *                                                                  }
             *                                                          }
             *                                                          if(flags & 2)
             *                                                          {
             *                                                                  ex = x2 + (y2 - y1);
             *                                                                  ey = y2 - (x2 - x1);
             *                                                          }
             *                                                          else
             *                                                          {
             *                                                                  while(Math.Abs(ex - lp.x2) + Math.Abs(ey - lp.y2) > lp2.len)
             *                                                                  {
             *                                                                          ex = (lp.x2 + ex) >> 1;
             *                                                                          ey = (lp.y2 + ey) >> 1;
             *                                                                  }
             *                                                          }
             *                                                          line3_no_clip(lp2, sx, sy, ex, ey);
             *                                                  }
             *                                                  else
             *                                                  {
             *                                                          line3_no_clip(lp, sx, sy, ex, ey);
             *                                                  }
             *                                          }
             *                                          m_start = start + uround(lp.len / m_scale_x);
             *                                  }
             *                                  else
             *                                  {
             *                                          line3_no_clip(lp, sx, sy, ex, ey);
             *                                  }
             */
        }
예제 #30
0
		public abstract void line1(line_parameters lp, int sx, int sy);
예제 #31
0
 public override void line0(line_parameters lp)
 {
 }
예제 #32
0
		public abstract void line2(line_parameters lp, int ex, int ey);
예제 #33
0
 public override void line2(line_parameters lp, int ex, int ey)
 {
 }
예제 #34
0
 //---------------------------------------------------------------------
 public bool same_diagonal_quadrant(line_parameters lp)
 {
     return(s_diagonal_quadrant[octant] == s_diagonal_quadrant[lp.octant]);
 }