Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public override void OnDraw(Graphics2D graphics2D)
        {
            ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());

            IImageByte backBuffer = widgetsSubImage;

            if (!didInit)
            {
                didInit = true;
                OnInitialize();
            }
            ImageBuffer image;

            if (backBuffer.BitDepth == 32)
            {
                image = new ImageBuffer();
                image.Attach(backBuffer, new BlenderBGRA());
            }
            else
            {
                if (backBuffer.BitDepth != 24)
                {
                    throw new System.NotSupportedException();
                }
                image = new ImageBuffer();
                image.Attach(backBuffer, new BlenderBGR());
            }
            ImageClippingProxy clippingProxy = new ImageClippingProxy(image);

            clippingProxy.clear(new RGBA_Floats(1, 1, 1));

            g_rasterizer.SetVectorClipBox(0, 0, Width, Height);

            ScanlineRenderer scanlineRenderer = new ScanlineRenderer();

            if (transformationTypeRadioButton.SelectedIndex == 0)
            {
                Bilinear tr = new Bilinear(lionShape.Bounds.Left, lionShape.Bounds.Bottom, lionShape.Bounds.Right, lionShape.Bounds.Top, quadPolygonControl.polygon());
                if (tr.is_valid())
                {
                    //--------------------------
                    // Render transformed lion
                    //
                    VertexSourceApplyTransform trans = new VertexSourceApplyTransform(lionShape.Path, tr);

                    scanlineRenderer.RenderSolidAllPaths(clippingProxy, g_rasterizer, g_scanline, trans, lionShape.Colors, lionShape.PathIndex, lionShape.NumPaths);
                    //--------------------------



                    //--------------------------
                    // Render transformed ellipse
                    //
                    VertexSource.Ellipse ell = new MatterHackers.Agg.VertexSource.Ellipse((lionShape.Bounds.Left + lionShape.Bounds.Right) * 0.5, (lionShape.Bounds.Bottom + lionShape.Bounds.Top) * 0.5,
                                                                                          (lionShape.Bounds.Right - lionShape.Bounds.Left) * 0.5, (lionShape.Bounds.Top - lionShape.Bounds.Bottom) * 0.5,
                                                                                          200);
                    Stroke ell_stroke = new Stroke(ell);
                    ell_stroke.width(3.0);
                    VertexSourceApplyTransform trans_ell = new VertexSourceApplyTransform(ell, tr);

                    VertexSourceApplyTransform trans_ell_stroke = new VertexSourceApplyTransform(ell_stroke, tr);

                    g_rasterizer.add_path(trans_ell);
                    scanlineRenderer.render_scanlines_aa_solid(clippingProxy, g_rasterizer, g_scanline, new RGBA_Bytes(0.5, 0.3, 0.0, 0.3));

                    g_rasterizer.add_path(trans_ell_stroke);
                    scanlineRenderer.render_scanlines_aa_solid(clippingProxy, g_rasterizer, g_scanline, new RGBA_Bytes(0.0, 0.3, 0.2, 1.0));
                }
            }
            else
            {
                Perspective tr = new Perspective(lionShape.Bounds.Left, lionShape.Bounds.Bottom, lionShape.Bounds.Right, lionShape.Bounds.Top, quadPolygonControl.polygon());
                if (tr.is_valid())
                {
                    // Render transformed lion
                    VertexSourceApplyTransform trans = new VertexSourceApplyTransform(lionShape.Path, tr);

                    scanlineRenderer.RenderSolidAllPaths(clippingProxy, g_rasterizer, g_scanline, trans, lionShape.Colors, lionShape.PathIndex, lionShape.NumPaths);

                    // Render transformed ellipse
                    VertexSource.Ellipse FilledEllipse = new MatterHackers.Agg.VertexSource.Ellipse((lionShape.Bounds.Left + lionShape.Bounds.Right) * 0.5, (lionShape.Bounds.Bottom + lionShape.Bounds.Top) * 0.5,
                                                                                                    (lionShape.Bounds.Right - lionShape.Bounds.Left) * 0.5, (lionShape.Bounds.Top - lionShape.Bounds.Bottom) * 0.5,
                                                                                                    200);

                    Stroke EllipseOutline = new Stroke(FilledEllipse);
                    EllipseOutline.width(3.0);
                    VertexSourceApplyTransform TransformedFilledEllipse = new VertexSourceApplyTransform(FilledEllipse, tr);

                    VertexSourceApplyTransform TransformedEllipesOutline = new VertexSourceApplyTransform(EllipseOutline, tr);

                    g_rasterizer.add_path(TransformedFilledEllipse);
                    scanlineRenderer.render_scanlines_aa_solid(clippingProxy, g_rasterizer, g_scanline, new RGBA_Bytes(0.5, 0.3, 0.0, 0.3));

                    g_rasterizer.add_path(TransformedEllipesOutline);
                    scanlineRenderer.render_scanlines_aa_solid(clippingProxy, g_rasterizer, g_scanline, new RGBA_Bytes(0.0, 0.3, 0.2, 1.0));
                }
            }

            //--------------------------
            // Render the "quad" tool and controls
            g_rasterizer.add_path(quadPolygonControl);
            scanlineRenderer.render_scanlines_aa_solid(clippingProxy, g_rasterizer, g_scanline, new RGBA_Bytes(0, 0.3, 0.5, 0.6));
            //m_trans_type.Render(g_rasterizer, g_scanline, clippingProxy);
            base.OnDraw(graphics2D);
        }
Exemplo n.º 3
0
        public override void OnDraw(Graphics2D graphics2D)
        {
            ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());

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

            if (numMasksSlider.Value != sliderValue)
            {
                generate_alpha_mask(width, height);
                sliderValue = numMasksSlider.Value;
            }

            rasterizer.SetVectorClipBox(0, 0, width, height);

            unsafe
            {
                alphaMaskImageBuffer.AttachBuffer(alphaByteArray, 0, width, height, width, 8, 1);

                MatterHackers.Agg.Image.AlphaMaskAdaptor imageAlphaMaskAdaptor = new MatterHackers.Agg.Image.AlphaMaskAdaptor(widgetsSubImage, alphaMask);
                ImageClippingProxy alphaMaskClippingProxy = new ImageClippingProxy(imageAlphaMaskAdaptor);
                ImageClippingProxy clippingProxy          = new ImageClippingProxy(widgetsSubImage);

                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);

                clippingProxy.clear(new ColorF(1, 1, 1));

                ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
                // draw a background to show how the mask is working better
                int RectWidth = 30;
                for (int i = 0; i < 40; i++)
                {
                    for (int j = 0; j < 40; j++)
                    {
                        if ((i + j) % 2 != 0)
                        {
                            VertexSource.RoundedRect rect = new VertexSource.RoundedRect(i * RectWidth, j * RectWidth, (i + 1) * RectWidth, (j + 1) * RectWidth, 0);
                            rect.normalize_radius();

                            // Drawing as an outline
                            rasterizer.add_path(rect);
                            scanlineRenderer.RenderSolid(clippingProxy, rasterizer, scanlineCache, new Color(.9, .9, .9));
                        }
                    }
                }

                //int x, y;

                // Render the lion
                VertexSourceApplyTransform trans = new VertexSourceApplyTransform(lionShape.Path, transform);
                scanlineRenderer.RenderSolidAllPaths(alphaMaskClippingProxy, rasterizer, scanlineCache, trans, lionShape.Colors, lionShape.PathIndex, lionShape.NumPaths);

                /*
                 * // Render random Bresenham lines and markers
                 * agg::renderer_markers<amask_ren_type> m(r);
                 * for(i = 0; i < 50; i++)
                 * {
                 *      m.line_color(agg::rgba8(randGenerator.Next() & 0x7F,
                 *                                                      randGenerator.Next() & 0x7F,
                 *                                                      randGenerator.Next() & 0x7F,
                 *                                                      (randGenerator.Next() & 0x7F) + 0x7F));
                 *      m.fill_color(agg::rgba8(randGenerator.Next() & 0x7F,
                 *                                                      randGenerator.Next() & 0x7F,
                 *                                                      randGenerator.Next() & 0x7F,
                 *                                                      (randGenerator.Next() & 0x7F) + 0x7F));
                 *
                 *      m.line(m.coord(randGenerator.Next() % width), m.coord(randGenerator.Next() % height),
                 *                 m.coord(randGenerator.Next() % width), m.coord(randGenerator.Next() % height));
                 *
                 *      m.marker(randGenerator.Next() % width, randGenerator.Next() % height, randGenerator.Next() % 10 + 5,
                 *                       agg::marker_e(randGenerator.Next() % agg::end_of_markers));
                 * }
                 *
                 * // Render random anti-aliased lines
                 * double w = 5.0;
                 * agg::line_profile_aa profile;
                 * profile.width(w);
                 *
                 * typedef agg::renderer_outline_aa<amask_ren_type> renderer_type;
                 * renderer_type ren(r, profile);
                 *
                 * typedef agg::rasterizer_outline_aa<renderer_type> rasterizer_type;
                 * rasterizer_type ras(ren);
                 * ras.round_cap(true);
                 *
                 * for(i = 0; i < 50; i++)
                 * {
                 *      ren.Color = agg::rgba8(randGenerator.Next() & 0x7F,
                 *                                               randGenerator.Next() & 0x7F,
                 *                                               randGenerator.Next() & 0x7F,
                 *                                               //255));
                 *                                               (randGenerator.Next() & 0x7F) + 0x7F);
                 *      ras.move_to_d(randGenerator.Next() % width, randGenerator.Next() % height);
                 *      ras.line_to_d(randGenerator.Next() % width, randGenerator.Next() % height);
                 *      ras.render(false);
                 * }
                 *
                 * // Render random circles with gradient
                 * typedef agg::gradient_linear_color<color_type> grad_color;
                 * typedef agg::gradient_circle grad_func;
                 * typedef agg::span_interpolator_linear<> interpolator_type;
                 * typedef agg::span_gradient<color_type,
                 *                                                interpolator_type,
                 *                                                grad_func,
                 *                                                grad_color> span_grad_type;
                 *
                 * agg::trans_affine grm;
                 * grad_func grf;
                 * grad_color grc(agg::rgba8(0,0,0), agg::rgba8(0,0,0));
                 * agg::ellipse ell;
                 * agg::span_allocator<color_type> sa;
                 * interpolator_type inter(grm);
                 * span_grad_type sg(inter, grf, grc, 0, 10);
                 * agg::renderer_scanline_aa<amask_ren_type,
                 *                                                agg::span_allocator<color_type>,
                 *                                                span_grad_type> rg(r, sa, sg);
                 * for(i = 0; i < 50; i++)
                 * {
                 *      x = randGenerator.Next() % width;
                 *      y = randGenerator.Next() % height;
                 *      double r = randGenerator.Next() % 10 + 5;
                 *      grm.reset();
                 *      grm *= agg::trans_affine_scaling(r / 10.0);
                 *      grm *= agg::trans_affine_translation(x, y);
                 *      grm.invert();
                 *      grc.colors(agg::rgba8(255, 255, 255, 0),
                 *                         agg::rgba8(randGenerator.Next() & 0x7F,
                 *                                                randGenerator.Next() & 0x7F,
                 *                                                randGenerator.Next() & 0x7F,
                 *                                                255));
                 *      sg.color_function(grc);
                 *      ell.init(x, y, r, r, 32);
                 *      g_rasterizer.add_path(ell);
                 *      agg::render_scanlines(g_rasterizer, g_scanline, rg);
                 * }
                 */

                //m_num_cb.Render(g_rasterizer, g_scanline, clippingProxy);
            }
            alphaMaskImageBuffer.DettachBuffer();
            base.OnDraw(graphics2D);
        }
Exemplo n.º 4
0
        public override void OnDraw(Graphics2D graphics2D)
        {
            ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());

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

            if (numMasksSlider.Value != sliderValue)
            {
                generate_alpha_mask(width, height);
                sliderValue = numMasksSlider.Value;
            }

            rasterizer.SetVectorClipBox(0, 0, width, height);

            unsafe
            {
                alphaMaskImageBuffer.AttachBuffer(alphaByteArray, 0, width, height, width, 8, 1);

                MatterHackers.Agg.Image.AlphaMaskAdaptor imageAlphaMaskAdaptor = new MatterHackers.Agg.Image.AlphaMaskAdaptor(widgetsSubImage, alphaMask);
                ImageClippingProxy alphaMaskClippingProxy = new ImageClippingProxy(imageAlphaMaskAdaptor);
                ImageClippingProxy clippingProxy = new ImageClippingProxy(widgetsSubImage);

                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);

                clippingProxy.clear(new RGBA_Floats(1, 1, 1));

                ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
                // draw a background to show how the mask is working better
                int RectWidth = 30;
                for (int i = 0; i < 40; i++)
                {
                    for (int j = 0; j < 40; j++)
                    {
                        if ((i + j) % 2 != 0)
                        {
                            VertexSource.RoundedRect rect = new VertexSource.RoundedRect(i * RectWidth, j * RectWidth, (i + 1) * RectWidth, (j + 1) * RectWidth, 0);
                            rect.normalize_radius();

                            // Drawing as an outline
                            rasterizer.add_path(rect);
                            scanlineRenderer.render_scanlines_aa_solid(clippingProxy, rasterizer, scanlineCache, new RGBA_Bytes(.9, .9, .9));
                        }
                    }
                }

                //int x, y;

                // Render the lion
                VertexSourceApplyTransform trans = new VertexSourceApplyTransform(lionShape.Path, transform);
                scanlineRenderer.RenderSolidAllPaths(alphaMaskClippingProxy, rasterizer, scanlineCache, trans, lionShape.Colors, lionShape.PathIndex, lionShape.NumPaths);

                /*
                // Render random Bresenham lines and markers
                agg::renderer_markers<amask_ren_type> m(r);
                for(i = 0; i < 50; i++)
                {
                    m.line_color(agg::rgba8(randGenerator.Next() & 0x7F, 
                                            randGenerator.Next() & 0x7F, 
                                            randGenerator.Next() & 0x7F, 
                                            (randGenerator.Next() & 0x7F) + 0x7F)); 
                    m.fill_color(agg::rgba8(randGenerator.Next() & 0x7F, 
                                            randGenerator.Next() & 0x7F, 
                                            randGenerator.Next() & 0x7F, 
                                            (randGenerator.Next() & 0x7F) + 0x7F));

                    m.line(m.coord(randGenerator.Next() % width), m.coord(randGenerator.Next() % height), 
                           m.coord(randGenerator.Next() % width), m.coord(randGenerator.Next() % height));

                    m.marker(randGenerator.Next() % width, randGenerator.Next() % height, randGenerator.Next() % 10 + 5,
                             agg::marker_e(randGenerator.Next() % agg::end_of_markers));
                }


                // Render random anti-aliased lines
                double w = 5.0;
                agg::line_profile_aa profile;
                profile.width(w);

                typedef agg::renderer_outline_aa<amask_ren_type> renderer_type;
                renderer_type ren(r, profile);

                typedef agg::rasterizer_outline_aa<renderer_type> rasterizer_type;
                rasterizer_type ras(ren);
                ras.round_cap(true);

                for(i = 0; i < 50; i++)
                {
                    ren.Color = agg::rgba8(randGenerator.Next() & 0x7F, 
                                         randGenerator.Next() & 0x7F, 
                                         randGenerator.Next() & 0x7F, 
                                         //255));
                                         (randGenerator.Next() & 0x7F) + 0x7F); 
                    ras.move_to_d(randGenerator.Next() % width, randGenerator.Next() % height);
                    ras.line_to_d(randGenerator.Next() % width, randGenerator.Next() % height);
                    ras.render(false);
                }


                // Render random circles with gradient
                typedef agg::gradient_linear_color<color_type> grad_color;
                typedef agg::gradient_circle grad_func;
                typedef agg::span_interpolator_linear<> interpolator_type;
                typedef agg::span_gradient<color_type, 
                                          interpolator_type, 
                                          grad_func, 
                                          grad_color> span_grad_type;

                agg::trans_affine grm;
                grad_func grf;
                grad_color grc(agg::rgba8(0,0,0), agg::rgba8(0,0,0));
                agg::ellipse ell;
                agg::span_allocator<color_type> sa;
                interpolator_type inter(grm);
                span_grad_type sg(inter, grf, grc, 0, 10);
                agg::renderer_scanline_aa<amask_ren_type, 
                                          agg::span_allocator<color_type>,
                                          span_grad_type> rg(r, sa, sg);
                for(i = 0; i < 50; i++)
                {
                    x = randGenerator.Next() % width;
                    y = randGenerator.Next() % height;
                    double r = randGenerator.Next() % 10 + 5;
                    grm.reset();
                    grm *= agg::trans_affine_scaling(r / 10.0);
                    grm *= agg::trans_affine_translation(x, y);
                    grm.invert();
                    grc.colors(agg::rgba8(255, 255, 255, 0),
                               agg::rgba8(randGenerator.Next() & 0x7F, 
                                          randGenerator.Next() & 0x7F, 
                                          randGenerator.Next() & 0x7F, 
                                          255));
                    sg.color_function(grc);
                    ell.init(x, y, r, r, 32);
                    g_rasterizer.add_path(ell);
                    agg::render_scanlines(g_rasterizer, g_scanline, rg);
                }
                 */

                //m_num_cb.Render(g_rasterizer, g_scanline, clippingProxy);
            }
            alphaMaskImageBuffer.DettachBuffer();
            base.OnDraw(graphics2D);
        }
Exemplo n.º 5
0
		public override void OnDraw(Graphics2D graphics2D)
		{
			ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());

			IImageByte backBuffer = widgetsSubImage;

			if (!didInit)
			{
				didInit = true;
				OnInitialize();
			}
			ImageBuffer image;
			if (backBuffer.BitDepth == 32)
			{
				image = new ImageBuffer();
				image.Attach(backBuffer, new BlenderBGRA());
			}
			else
			{
				if (backBuffer.BitDepth != 24)
				{
					throw new System.NotSupportedException();
				}
				image = new ImageBuffer();
				image.Attach(backBuffer, new BlenderBGR());
			}
			ImageClippingProxy clippingProxy = new ImageClippingProxy(image);
			clippingProxy.clear(new RGBA_Floats(1, 1, 1));

			g_rasterizer.SetVectorClipBox(0, 0, Width, Height);

			ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
			if (transformationTypeRadioButton.SelectedIndex == 0)
			{
				Bilinear tr = new Bilinear(lionShape.Bounds.Left, lionShape.Bounds.Bottom, lionShape.Bounds.Right, lionShape.Bounds.Top, quadPolygonControl.polygon());
				if (tr.is_valid())
				{
					//--------------------------
					// Render transformed lion
					//
					VertexSourceApplyTransform trans = new VertexSourceApplyTransform(lionShape.Path, tr);

					scanlineRenderer.RenderSolidAllPaths(clippingProxy, g_rasterizer, g_scanline, trans, lionShape.Colors, lionShape.PathIndex, lionShape.NumPaths);
					//--------------------------

					//--------------------------
					// Render transformed ellipse
					//
					VertexSource.Ellipse ell = new MatterHackers.Agg.VertexSource.Ellipse((lionShape.Bounds.Left + lionShape.Bounds.Right) * 0.5, (lionShape.Bounds.Bottom + lionShape.Bounds.Top) * 0.5,
									 (lionShape.Bounds.Right - lionShape.Bounds.Left) * 0.5, (lionShape.Bounds.Top - lionShape.Bounds.Bottom) * 0.5,
									 200);
					Stroke ell_stroke = new Stroke(ell);
					ell_stroke.width(3.0);
					VertexSourceApplyTransform trans_ell = new VertexSourceApplyTransform(ell, tr);

					VertexSourceApplyTransform trans_ell_stroke = new VertexSourceApplyTransform(ell_stroke, tr);

					g_rasterizer.add_path(trans_ell);
					scanlineRenderer.RenderSolid(clippingProxy, g_rasterizer, g_scanline, new RGBA_Bytes(0.5, 0.3, 0.0, 0.3));

					g_rasterizer.add_path(trans_ell_stroke);
					scanlineRenderer.RenderSolid(clippingProxy, g_rasterizer, g_scanline, new RGBA_Bytes(0.0, 0.3, 0.2, 1.0));
				}
			}
			else
			{
				Perspective tr = new Perspective(lionShape.Bounds.Left, lionShape.Bounds.Bottom, lionShape.Bounds.Right, lionShape.Bounds.Top, quadPolygonControl.polygon());
				if (tr.is_valid())
				{
					// Render transformed lion
					VertexSourceApplyTransform trans = new VertexSourceApplyTransform(lionShape.Path, tr);

					scanlineRenderer.RenderSolidAllPaths(clippingProxy, g_rasterizer, g_scanline, trans, lionShape.Colors, lionShape.PathIndex, lionShape.NumPaths);

					// Render transformed ellipse
					VertexSource.Ellipse FilledEllipse = new MatterHackers.Agg.VertexSource.Ellipse((lionShape.Bounds.Left + lionShape.Bounds.Right) * 0.5, (lionShape.Bounds.Bottom + lionShape.Bounds.Top) * 0.5,
									 (lionShape.Bounds.Right - lionShape.Bounds.Left) * 0.5, (lionShape.Bounds.Top - lionShape.Bounds.Bottom) * 0.5,
									 200);

					Stroke EllipseOutline = new Stroke(FilledEllipse);
					EllipseOutline.width(3.0);
					VertexSourceApplyTransform TransformedFilledEllipse = new VertexSourceApplyTransform(FilledEllipse, tr);

					VertexSourceApplyTransform TransformedEllipesOutline = new VertexSourceApplyTransform(EllipseOutline, tr);

					g_rasterizer.add_path(TransformedFilledEllipse);
					scanlineRenderer.RenderSolid(clippingProxy, g_rasterizer, g_scanline, new RGBA_Bytes(0.5, 0.3, 0.0, 0.3));

					g_rasterizer.add_path(TransformedEllipesOutline);
					scanlineRenderer.RenderSolid(clippingProxy, g_rasterizer, g_scanline, new RGBA_Bytes(0.0, 0.3, 0.2, 1.0));
				}
			}

			//--------------------------
			// Render the "quad" tool and controls
			g_rasterizer.add_path(quadPolygonControl);
			scanlineRenderer.RenderSolid(clippingProxy, g_rasterizer, g_scanline, new RGBA_Bytes(0, 0.3, 0.5, 0.6));
			//m_trans_type.Render(g_rasterizer, g_scanline, clippingProxy);
			base.OnDraw(graphics2D);
		}
Exemplo n.º 6
0
		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);
		}