示例#1
0
        public override void OnDraw(Graphics2D graphics2D)
        {
            ImageClippingProxy ren_base = new ImageClippingProxy(graphics2D.DestImage);

            ren_base.clear(new RGBA_Floats(1.0, 1.0, .95));

            ScanlineRasterizer   ras = new ScanlineRasterizer();
            ScanlineCachePacked8 sl  = new ScanlineCachePacked8();

            // Pattern source. Must have an interface:
            // width() const
            // height() const
            // pixel(int x, int y) const
            // Any agg::renderer_base<> or derived
            // is good for the use as a source.
            //-----------------------------------
            pattern_src_brightness_to_alpha_RGBA_Bytes p1 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img0);
            pattern_src_brightness_to_alpha_RGBA_Bytes p2 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img1);
            pattern_src_brightness_to_alpha_RGBA_Bytes p3 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img2);
            pattern_src_brightness_to_alpha_RGBA_Bytes p4 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img3);
            pattern_src_brightness_to_alpha_RGBA_Bytes p5 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img4);
            pattern_src_brightness_to_alpha_RGBA_Bytes p6 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img5);
            pattern_src_brightness_to_alpha_RGBA_Bytes p7 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img6);
            pattern_src_brightness_to_alpha_RGBA_Bytes p8 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img7);
            pattern_src_brightness_to_alpha_RGBA_Bytes p9 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img8);

            //pattern_filter_bilinear_RGBA_Bytes fltr = new pattern_filter_bilinear_RGBA_Bytes();           // Filtering functor

            // agg::line_image_pattern is the main container for the patterns. It creates
            // a copy of the patterns extended according to the needs of the filter.
            // agg::line_image_pattern can operate with arbitrary image width, but if the
            // width of the pattern is power of 2, it's better to use the modified
            // version agg::line_image_pattern_pow2 because it works about 15-25 percent
            // faster than agg::line_image_pattern (because of using simple masking instead
            // of expensive '%' operation).

            //-- Create with specifying the source

            //-- Create uninitialized and set the source

            line_image_pattern patt    = new line_image_pattern(new pattern_filter_bilinear_RGBA_Bytes());
            ImageLineRenderer  ren_img = new ImageLineRenderer(ren_base, patt);

            rasterizer_outline_aa ras_img = new rasterizer_outline_aa(ren_img);

            draw_curve(patt, ras_img, ren_img, p1, m_curve1.curve());

            /*
             * draw_curve(patt, ras_img, ren_img, p2, m_curve2.curve());
             * draw_curve(patt, ras_img, ren_img, p3, m_curve3.curve());
             * draw_curve(patt, ras_img, ren_img, p4, m_curve4.curve());
             * draw_curve(patt, ras_img, ren_img, p5, m_curve5.curve());
             * draw_curve(patt, ras_img, ren_img, p6, m_curve6.curve());
             * draw_curve(patt, ras_img, ren_img, p7, m_curve7.curve());
             * draw_curve(patt, ras_img, ren_img, p8, m_curve8.curve());
             * draw_curve(patt, ras_img, ren_img, p9, m_curve9.curve());
             */

            base.OnDraw(graphics2D);
        }
示例#2
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 ColorF(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);

                foreach (var shape in lionShape.Shapes)
                {
                    Stroke stroke = new Stroke(shape.VertexStorage);
                    stroke.Width    = widthSlider.Value;
                    stroke.LineJoin = LineJoin.Round;
                    VertexSourceApplyTransform trans            = new VertexSourceApplyTransform(stroke, transform);
                    ScanlineRenderer           scanlineRenderer = new ScanlineRenderer();
                    rasterizer.add_path(trans);
                    scanlineRenderer.RenderSolid(imageClippingProxy, rasterizer, scanlineCache, shape.Color);
                }
            }
            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);

                foreach (var shape in lionShape.Shapes)
                {
                    VertexSourceApplyTransform trans = new VertexSourceApplyTransform(shape.VertexStorage, transform);
                    rasterizer.RenderAllPaths(trans, new Color[] { shape.Color }, new int[] { 0 }, 1);
                }
            }

            base.OnDraw(graphics2D);
        }
示例#3
0
 private void draw_curve(line_image_pattern patt, rasterizer_outline_aa ras, ImageLineRenderer ren,
                         pattern_src_brightness_to_alpha_RGBA_Bytes src, IVertexSource vs)
 {
     patt.create(src);
     ren.scale_x(m_scale_x.Value);
     ren.start_x(m_start_x.Value);
     ras.add_path(vs);
 }