コード例 #1
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();
		}
コード例 #2
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();
		}
コード例 #3
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;
		}
コード例 #4
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;
		}
コード例 #5
0
ファイル: lion_outline.cs プロジェクト: glocklueng/agg-sharp
		public override void OnDraw(Graphics2D graphics2D)
		{
			ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());

			int width = (int)widgetsSubImage.Width;
			int height = (int)widgetsSubImage.Height;

			ImageBuffer clippedSubImage = new ImageBuffer();
			clippedSubImage.Attach(widgetsSubImage, new BlenderBGRA());
			ImageClippingProxy imageClippingProxy = new ImageClippingProxy(clippedSubImage);
			imageClippingProxy.clear(new RGBA_Floats(1, 1, 1));

			Affine transform = Affine.NewIdentity();
			transform *= Affine.NewTranslation(-lionShape.Center.x, -lionShape.Center.y);
			transform *= Affine.NewScaling(lionScale, lionScale);
			transform *= Affine.NewRotation(angle + Math.PI);
			transform *= Affine.NewSkewing(skewX / 1000.0, skewY / 1000.0);
			transform *= Affine.NewTranslation(width / 2, height / 2);

			if (renderAsScanlineCheckBox.Checked)
			{
				rasterizer.SetVectorClipBox(0, 0, width, height);

				Stroke stroke = new Stroke(lionShape.Path);
				stroke.width(widthSlider.Value);
				stroke.line_join(LineJoin.Round);
				VertexSourceApplyTransform trans = new VertexSourceApplyTransform(stroke, transform);
				ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
				scanlineRenderer.RenderSolidAllPaths(imageClippingProxy, rasterizer, scanlineCache, trans, lionShape.Colors, lionShape.PathIndex, lionShape.NumPaths);
			}
			else
			{
				double w = widthSlider.Value * transform.GetScale();

				LineProfileAnitAlias lineProfile = new LineProfileAnitAlias(w, new gamma_none());
				OutlineRenderer outlineRenderer = new OutlineRenderer(imageClippingProxy, lineProfile);
				rasterizer_outline_aa rasterizer = new rasterizer_outline_aa(outlineRenderer);

				rasterizer.line_join(renderAccurateJoinsCheckBox.Checked ?
					rasterizer_outline_aa.outline_aa_join_e.outline_miter_accurate_join
					: rasterizer_outline_aa.outline_aa_join_e.outline_round_join);
				rasterizer.round_cap(true);

				VertexSourceApplyTransform trans = new VertexSourceApplyTransform(lionShape.Path, transform);

				rasterizer.RenderAllPaths(trans, lionShape.Colors, lionShape.PathIndex, lionShape.NumPaths);
			}

			base.OnDraw(graphics2D);
		}