Exemple #1
0
        VertexStore BuildVxsForGlyph(GlyphPathBuilder builder, char character, int size, int resolution)
        {
            //TODO: review here
            builder.Build(character, size);
            var txToVxs = new GlyphTranslatorToVxs();

            builder.ReadShapes(txToVxs);

            VectorToolBox.GetFreeVxs(out VertexStore v0, out VertexStore v1);
            txToVxs.WriteOutput(v0);
            var mat = PixelFarm.Agg.Transform.Affine.NewMatix(
                //translate
                new PixelFarm.Agg.Transform.AffinePlan(
                    PixelFarm.Agg.Transform.AffineMatrixCommand.Translate, 10, 10),
                //scale
                new PixelFarm.Agg.Transform.AffinePlan(
                    PixelFarm.Agg.Transform.AffineMatrixCommand.Scale, 1, 1)
                );


            VertexStore v2 = new VertexStore();

            mat.TransformToVxs(v0, v1);
            curveFlattener.MakeVxs(v0, v2);

            VectorToolBox.ReleaseVxs(ref v0, ref v1);
            return(v2);
        }
        /// <summary>
        /// we do NOT store vxs/vxsSnap
        /// </summary>
        /// <param name="vxsSnap"></param>
        /// <param name="color"></param>
        public void Render(VertexStoreSnap vxsSnap, Drawing.Color color)
        {
            //reset rasterizer before render each vertextSnap
            //-----------------------------
            sclineRas.Reset();
            Affine transform = this.CurrentTransformMatrix;

            if (!transform.IsIdentity())
            {
                VectorToolBox.GetFreeVxs(out var v1);
                transform.TransformToVxs(vxsSnap, v1);
                sclineRas.AddPath(v1);
                VectorToolBox.ReleaseVxs(ref v1);
                //-------------------------
                //since sclineRas do NOT store vxs
                //then we can reuse the vxs***
                //-------------------------
            }
            else
            {
                sclineRas.AddPath(vxsSnap);
            }
            _bmpRasterizer.RenderWithColor(destImageReaderWriter, sclineRas, sclinePack8, color);
            unchecked { destImageChanged++; };
            //-----------------------------
        }
Exemple #3
0
        public void Render(IBitmapSrc source, AffinePlan[] affinePlans)
        {
            VectorToolBox.GetFreeVxs(out var v1, out var v2);

            //BuildImageBoundsPath(source.Width, source.Height, affinePlans, v1);
            BuildOrgImgRectVxs(source.Width, source.Height, v1);


            //Affine destRectTransform = Affine.NewMatix(affinePlans);

            var destRectTransform = new AffineMat();

            destRectTransform.BuildFromAffinePlans(affinePlans);

            //TODO: review reusable span generator an interpolator ***
            var spanInterpolator = new SpanInterpolatorLinear();

            // We invert it because it is the transform to make the image go to the same position as the polygon. LBB [2/24/2004]

            _reuseableAffine.SetElements(destRectTransform.CreateInvert());
            spanInterpolator.Transformer = _reuseableAffine;//

            var imgSpanGen = new ImgSpanGenRGBA_BilinearClip(
                source,
                Drawing.Color.Transparent,
                spanInterpolator);

            TransformToVxs(ref destRectTransform, v1, v2);

            Render(v2, imgSpanGen);
            //
            VectorToolBox.ReleaseVxs(ref v1, ref v2);
        }
Exemple #4
0
 public static void Circle(this AggRenderSurface g, double x, double y, double radius, Color color)
 {
     ellipse.Set(x, y, radius, radius);
     VectorToolBox.GetFreeVxs(out var v1);
     g.Render(ellipse.MakeVxs(v1), color);
     VectorToolBox.ReleaseVxs(ref v1);
 }
Exemple #5
0
            public override RenderElement GetPrimaryRenderElement(RootGraphic rootgfx)
            {
                if (_lineRendeE == null)
                {
                    VertexStore strokeVxs = new VertexStore();
                    VectorToolBox.GetFreeVxs(out var vxs);
                    VectorToolBox.GetFreeStroke(out var stroke, 3);

                    vxs.AddMoveTo(p0.Left, p0.Top);
                    vxs.AddLineTo(p1.Left, p1.Top);

                    stroke.MakeVxs(vxs, strokeVxs);
                    //---
                    //convert data in vxs to GraphicPath
                    //---

                    _lineRendeE         = new LineRenderElement(rootgfx, 10, 10);
                    _lineRendeE._stroke = new VxsRenderVx(strokeVxs);

                    _lineRendeE.X0 = p0.Left;
                    _lineRendeE.Y0 = p0.Top;
                    _lineRendeE.X1 = p1.Left;
                    _lineRendeE.Y1 = p1.Top;


                    VectorToolBox.ReleaseVxs(ref vxs);

                    VectorToolBox.ReleaseStroke(ref stroke);
                }
                return(_lineRendeE);
            }
Exemple #6
0
        public override void OnDraw(Painter p)
        {
            p.FillColor = LineColor;

            VectorToolBox.GetFreeVxs(out var v1);
            p.Draw(new VertexStoreSnap(this.MakeVxs(v1)));
            VectorToolBox.ReleaseVxs(ref v1);
        }
        void generate_alpha_mask(ScanlineRasToDestBitmapRenderer sclineRasToBmp, ScanlinePacked8 sclnPack, ScanlineRasterizer rasterizer, int width, int height)
        {
            //create 1  8-bits chanel (grayscale8) bmp
            alphaBitmap = new ActualImage(width, height, PixelFormat.GrayScale8);
            var bmpReaderWrtier = new MyImageReaderWriter();

            bmpReaderWrtier.ReloadImage(alphaBitmap);
            alphaMaskImageBuffer = new SubImageRW(bmpReaderWrtier, new PixelBlenderGray(1));
            //create mask from alpahMaskImageBuffer
            alphaMask = new AlphaMaskByteClipped(alphaMaskImageBuffer, 1, 0);
#if USE_CLIPPING_ALPHA_MASK
            //alphaMaskImageBuffer.AttachBuffer(alphaBitmap.GetBuffer(), 20 * width + 20, width - 40, height - 40, width, 8, 1);
#else
            alphaMaskImageBuffer.attach(alphaByteArray, (int)cx, (int)cy, cx, 1);
#endif

            var            image         = new SubImageRW(alphaMaskImageBuffer, new PixelBlenderGray(1), 1, 0, 8);
            ClipProxyImage clippingProxy = new ClipProxyImage(image);
            clippingProxy.Clear(Drawing.Color.Black);
            VertexSource.Ellipse ellipseForMask = new PixelFarm.Agg.VertexSource.Ellipse();
            System.Random        randGenerator  = new Random(1432);
            int i;
            int num = (int)maskAlphaSliderValue;

            VectorToolBox.GetFreeVxs(out var v1);
            for (i = 0; i < num; i++)
            {
                if (i == num - 1)
                {
                    //for the last one
                    ellipseForMask.Reset(Width / 2, Height / 2, 110, 110, 100);
                    rasterizer.AddPath(ellipseForMask.MakeVertexSnap(v1));
                    v1.Clear();
                    sclineRasToBmp.RenderWithColor(clippingProxy, rasterizer, sclnPack, new Color(255, 0, 0, 0));
                    ellipseForMask.Reset(ellipseForMask.originX, ellipseForMask.originY, ellipseForMask.radiusX - 10, ellipseForMask.radiusY - 10, 100);
                    rasterizer.AddPath(ellipseForMask.MakeVertexSnap(v1));
                    v1.Clear();
                    sclineRasToBmp.RenderWithColor(clippingProxy, rasterizer, sclnPack, new Color(255, 255, 0, 0));
                }
                else
                {
                    ellipseForMask.Reset(randGenerator.Next() % width,
                                         randGenerator.Next() % height,
                                         randGenerator.Next() % 100 + 20,
                                         randGenerator.Next() % 100 + 20,
                                         100);
                    // set the color to draw into the alpha channel.
                    // there is not very much reason to set the alpha as you will get the amount of
                    // transparency based on the color you draw.  (you might want some type of different edeg effect but it will be minor).
                    rasterizer.AddPath(ellipseForMask.MakeVxs(v1));
                    v1.Clear();
                    sclineRasToBmp.RenderWithColor(clippingProxy, rasterizer, sclnPack,
                                                   ColorEx.Make((int)((float)i / (float)num * 255), 0, 0, 255));
                }
            }
            VectorToolBox.ReleaseVxs(ref v1);
        }
Exemple #8
0
        public override void Draw(Painter p)
        {
            //specific for agg

            if (p is PixelFarm.Agg.AggPainter)
            {
                var p2 = (PixelFarm.Agg.AggPainter)p;
                AggRenderSurface   aggsx      = p2.RenderSurface;
                ScanlineRasterizer rasterizer = aggsx.ScanlineRasterizer;


                var widgetsSubImage = ImageHelper.CreateSubImgRW(aggsx.DestImage, aggsx.GetClippingRect());
                aggsx.UseSubPixelRendering = false;
                PixelBlenderBGRA normalBlender = new PixelBlenderBGRA();
                PixelBlenderBGRA gammaBlender  = new PixelBlenderBGRA(); //TODO: revisit, and fix this again
                gammaBlender.GammaValue  = this.GammaValue;
                gammaBlender.EnableGamma = true;
                var            rasterGamma         = new SubImageRW(widgetsSubImage, gammaBlender);
                ClipProxyImage clippingProxyNormal = new ClipProxyImage(widgetsSubImage);
                ClipProxyImage clippingProxyGamma  = new ClipProxyImage(rasterGamma);
                clippingProxyNormal.Clear(Color.White);

                ScanlineUnpacked8 sl = new ScanlineUnpacked8();
                int size_mul         = (int)this.PixelSize;
                CustomScanlineRasToBmp_EnlargedSubPixelRendering ren_en = new CustomScanlineRasToBmp_EnlargedSubPixelRendering(size_mul, aggsx.DestActualImage);
                rasterizer.Reset();
                rasterizer.MoveTo(m_x[0] / size_mul, m_y[0] / size_mul);
                rasterizer.LineTo(m_x[1] / size_mul, m_y[1] / size_mul);
                rasterizer.LineTo(m_x[2] / size_mul, m_y[2] / size_mul);
                ren_en.RenderWithColor(clippingProxyGamma, rasterizer, sl, Color.Black);
                //----------------------------------------
                ScanlineRasToDestBitmapRenderer sclineRasToBmp = aggsx.ScanlineRasToDestBitmap;
                aggsx.UseSubPixelRendering = false;
                sclineRasToBmp.RenderWithColor(clippingProxyGamma, rasterizer, sl, Color.Black);
                rasterizer.ResetGamma(new GammaNone());
                aggsx.UseSubPixelRendering = false;
                //----------------------------------------
                PathWriter ps = new PathWriter();
                ps.Clear();
                ps.MoveTo(m_x[0], m_y[0]);
                ps.LineTo(m_x[1], m_y[1]);
                ps.LineTo(m_x[2], m_y[2]);
                ps.LineTo(m_x[0], m_y[0]);
                //----------------------------------------
                //Stroke stroke = new Stroke(ps);
                //stroke.Width = 2;
                //rasterizer.AddPath(stroke.MakeVxs(ps.MakeVxs()));

                VectorToolBox.GetFreeVxs(out var v1);
                rasterizer.AddPath(stroke.MakeVxs(ps.Vxs, v1));
                VectorToolBox.ReleaseVxs(ref v1);
                //----------------------------------------

                sclineRasToBmp.RenderWithColor(clippingProxyNormal, rasterizer, sl, new Color(200, 0, 150, 160));
            }
        }
Exemple #9
0
        //static SvgFontStore svgFontStore = new SvgFontStore();
        //public static void DrawString(this ImageGraphics2D gx,
        //    string text,
        //    double x,
        //    double y,
        //    double pointSize = 12,
        //    Justification justification = Justification.Left,
        //    Baseline baseline = Baseline.Text,
        //    Color color = new Color(),
        //    bool drawFromHintedCache = false,
        //    Color backgroundColor = new Color())
        //{
        //    ////use svg font
        //    var svgFont = svgFontStore.LoadFont(SvgFontStore.DEFAULT_SVG_FONTNAME, (int)pointSize);
        //    //TODO: review here
        //    //stringPrinter on each platform may not interchangeable ***
        //    if (stringPrinter == null)
        //    {
        //        stringPrinter = new MyTypeFacePrinter(gx.GfxPlatform);

        //    }

        //    stringPrinter.CurrentActualFont = svgFont;
        //    stringPrinter.DrawFromHintedCache = false;
        //    stringPrinter.LoadText(text);
        //    VertexStore vxs = stringPrinter.MakeVxs();
        //    vxs = Affine.NewTranslation(x, y).TransformToVxs(vxs);
        //    gx.Render(vxs, Color.Black);
        //}

        public static void Rectangle(this AggRenderSurface gx, double left, double bottom, double right, double top, Color color, double strokeWidth = 1)
        {
            stroke.Width = strokeWidth;
            simpleRect.SetRect(left + .5, bottom + .5, right - .5, top - .5);


            VectorToolBox.GetFreeVxs(out VertexStore v1, out VertexStore v2);

            gx.Render(stroke.MakeVxs(simpleRect.MakeVxs(v1), v2), color);

            VectorToolBox.ReleaseVxs(ref v1, ref v2);
        }
Exemple #10
0
        public static void FillRectangle(this AggRenderSurface gx, double left,
                                         double bottom, double right, double top, Color fillColor)
        {
            if (right < left || top < bottom)
            {
                throw new ArgumentException();
            }

            simpleRect.SetRect(left, bottom, right, top);

            VectorToolBox.GetFreeVxs(out var v1);
            gx.Render(simpleRect.MakeVertexSnap(v1), fillColor);
            VectorToolBox.ReleaseVxs(ref v1);
        }
Exemple #11
0
        public override void DrawEllipse(double left, double top, double width, double height)
        {
            //double ox = (left + right) * 0.5;
            //double oy = (left + right) * 0.5;
            //if (this._orientation == DrawBoardOrientation.LeftTop)
            //{
            //    //modified
            //    oy = this.Height - oy;
            //}
            //ellipse.Reset(ox,
            //              oy,
            //             (right - left) * 0.5,
            //             (top - bottom) * 0.5,
            //              ellipseGenNSteps);
            //var v1 = GetFreeVxs();
            //var v2 = GetFreeVxs();
            //_aggsx.Render(stroke.MakeVxs(ellipse.MakeVxs(v1), v2), this.strokeColor);
            //ReleaseVxs(ref v1);
            //ReleaseVxs(ref v2);



            double x  = (left + width / 2);
            double y  = (top + height / 2);
            double rx = Math.Abs(width / 2);
            double ry = Math.Abs(height / 2);



            if (this._orientation == DrawBoardOrientation.LeftTop)
            {
                y = _glsx.ViewportHeight - y; //set new y
            }

            ellipse.Reset(x, y, rx, ry);


            VectorToolBox.GetFreeVxs(out var v1, out var v2);
            ellipse.MakeVxs(v1);
            _aggStroke.MakeVxs(v1, v2);
            //***
            //we fill the stroke's path
            _glsx.FillGfxPath(_strokeColor, _igfxPathBuilder.CreateGraphicsPath(v2));

            VectorToolBox.ReleaseVxs(ref v1, ref v2);
        }
        public void Render(IImageReaderWriter source, AffinePlan[] affinePlans)
        {
            VectorToolBox.GetFreeVxs(out var v1, out var v2);

            Affine destRectTransform = BuildImageBoundsPath(source.Width, source.Height, affinePlans, v1);
            // We invert it because it is the transform to make the image go to the same position as the polygon. LBB [2/24/2004]
            Affine sourceRectTransform = destRectTransform.CreateInvert();
            var    imgSpanGen          = new ImgSpanGenRGBA_BilinearClip(
                source,
                Drawing.Color.Transparent,
                new SpanInterpolatorLinear(sourceRectTransform));

            destRectTransform.TransformToVxs(v1, v2);
            Render(v2, imgSpanGen);
            //

            VectorToolBox.ReleaseVxs(ref v1, ref v2);
        }
Exemple #13
0
        public override void Draw(Painter p)
        {
            //this specific for agg
            if (p is AggPainter)
            {
                AggPainter       p2     = (AggPainter)p;
                AggRenderSurface aggsx  = p2.RenderSurface;
                SubImageRW       subImg = ImageHelper.CreateSubImgRW(aggsx.DestImage, aggsx.GetClippingRect());

                //TODO: review here again
                PixelBlenderBGRA blenderWithGamma = new PixelBlenderBGRA();

                SubImageRW     rasterGamma         = new SubImageRW(subImg, blenderWithGamma);
                ClipProxyImage clippingProxyNormal = new ClipProxyImage(subImg);
                ClipProxyImage clippingProxyGamma  = new ClipProxyImage(rasterGamma);
                clippingProxyNormal.Clear(Color.White);
                ScanlineRasterizer rasterizer = aggsx.ScanlineRasterizer;
                var sl             = new ScanlineUnpacked8();
                int size_mul       = this.PixelSize;
                var sclineToBmpEn2 = new CustomScanlineRasToBmp_EnlargedV2(size_mul, aggsx.DestActualImage);
                rasterizer.Reset();
                rasterizer.MoveTo(m_x[0] / size_mul, m_y[0] / size_mul);
                rasterizer.LineTo(m_x[1] / size_mul, m_y[1] / size_mul);
                rasterizer.LineTo(m_x[2] / size_mul, m_y[2] / size_mul);
                sclineToBmpEn2.RenderWithColor(clippingProxyGamma, rasterizer, sl, Color.Black);
                ScanlineRasToDestBitmapRenderer sclineRasToBmp = aggsx.ScanlineRasToDestBitmap;
                sclineRasToBmp.RenderWithColor(clippingProxyGamma, rasterizer, sl, Color.Black);
                //-----------------------------------------------------------------------------------------------------------
                rasterizer.ResetGamma(new GammaNone());
                PathWriter ps = new PathWriter();
                ps.Clear();
                ps.MoveTo(m_x[0], m_y[0]);
                ps.LineTo(m_x[1], m_y[1]);
                ps.LineTo(m_x[2], m_y[2]);
                ps.LineTo(m_x[0], m_y[0]);

                VectorToolBox.GetFreeVxs(out var v1);
                rasterizer.AddPath((new Stroke(2)).MakeVxs(ps.Vxs, v1));
                sclineRasToBmp.RenderWithColor(clippingProxyNormal, rasterizer, sl, new Color(200, 0, 150, 160));
                VectorToolBox.ReleaseVxs(ref v1);
            }
        }
Exemple #14
0
        protected override RectD CalculateLocalBounds()
        {
            RectD localBounds = new RectD(double.PositiveInfinity, double.PositiveInfinity, double.NegativeInfinity, double.NegativeInfinity);

            this.RewindZero();


            VectorToolBox.GetFreeVxs(out VertexStore v1);
            this.MakeVxs(v1);
            int j = v1.Count;

            for (int i = 0; i < j; ++i)
            {
                double x, y;
                v1.GetVertexXY(i, out x, out y);
                localBounds.ExpandToInclude(x, y);
            }
            VectorToolBox.ReleaseVxs(ref v1);
            return(localBounds);

            throw new NotImplementedException();
        }
Exemple #15
0
        //------------------------------------

        public VertexStore ParseSvgPathDefinitionToVxs(char[] buffer)
        {
            //
            VectorToolBox.GetFreePathWriter(out PathWriter pathWriter);
            VectorToolBox.GetFreeVxs(out VertexStore flattenVxs);

            _svgPathDataParser.SetPathWriter(pathWriter);
            //tokenize the path definition data
            _svgPathDataParser.Parse(buffer);


            _curveFlattener.MakeVxs(pathWriter.Vxs, flattenVxs);
            //-------------------------------------------------

            //create a small copy of the vxs
            VertexStore vxs = flattenVxs.CreateTrim();

            VectorToolBox.ReleaseVxs(ref flattenVxs);
            VectorToolBox.ReleasePathWriter(ref pathWriter);



            return(vxs);
        }
Exemple #16
0
        public override void Draw(Painter p)
        {
            Painter painter = p;

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


            //-----------------------------------
            painter.Clear(Drawing.Color.White);
            //IImageReaderWriter backBuffer = ImageHelper.CreateChildImage(gx.DestImage, gx.GetClippingRect());
            //ChildImage image;
            //if (backBuffer.BitDepth == 32)
            //{
            //    image = new ChildImage(backBuffer, new PixelBlenderBGRA());
            //}
            //else
            //{
            //    if (backBuffer.BitDepth != 24)
            //    {
            //        throw new System.NotSupportedException();
            //    }
            //    image = new ChildImage(backBuffer, new PixelBlenderBGR());
            //}
            //ClipProxyImage dest = new ClipProxyImage(image);
            //gx.Clear(ColorRGBA.White);
            //gx.SetClippingRect(new RectInt(0, 0, Width, Height));
            //ScanlineRasToDestBitmapRenderer sclineRasToBmp = gx.ScanlineRasToDestBitmap;

            if (this.PerspectiveTransformType == Sample_Perspective.PerspectiveTransformType.Bilinear)
            {
                var      bound      = lionShape.Bounds;
                Bilinear txBilinear = Bilinear.RectToQuad(bound.Left,
                                                          bound.Bottom,
                                                          bound.Right,
                                                          bound.Top,
                                                          quadPolygonControl.GetInnerCoords());
                if (txBilinear.IsValid)
                {
                    VectorToolBox.GetFreeVxs(out var v3);
                    lionShape.ApplyTransform(txBilinear);
                    lionShape.Paint(painter);
                    RectD   lionBound = lionShape.Bounds;
                    Ellipse ell       = new Ellipse((lionBound.Left + lionBound.Right) * 0.5,
                                                    (lionBound.Bottom + lionBound.Top) * 0.5,
                                                    (lionBound.Right - lionBound.Left) * 0.5,
                                                    (lionBound.Top - lionBound.Bottom) * 0.5,
                                                    200);
                    VectorToolBox.ReleaseVxs(ref v3);

                    //



                    VectorToolBox.GetFreeVxs(out var v1, out var trans_ell);

                    txBilinear.TransformToVxs(ell.MakeVxs(v1), trans_ell);
                    painter.FillColor = ColorEx.Make(0.5f, 0.3f, 0.0f, 0.3f);
                    painter.Fill(trans_ell);
                    //-------------------------------------------------------------
                    //outline
                    double prevStrokeWidth = painter.StrokeWidth;
                    painter.StrokeWidth = 3;
                    painter.StrokeColor = ColorEx.Make(0.0f, 0.3f, 0.2f, 1.0f);
                    painter.Draw(trans_ell);
                    painter.StrokeWidth = prevStrokeWidth;


                    VectorToolBox.ReleaseVxs(ref v1, ref trans_ell);
                }
            }
            else
            {
                RectD r = lionShape.Bounds;

                var txPerspective = new Perspective(
                    r.Left, r.Bottom, r.Right, r.Top,
                    quadPolygonControl.GetInnerCoords());
                if (txPerspective.IsValid)
                {
                    lionShape.Paint(p, txPerspective); //transform -> paint

                    //painter.PaintSeries(txPerspective.TransformToVxs(lionShape.Vxs, v1),
                    //  lionShape.Colors,
                    //  lionShape.PathIndexList,
                    //  lionShape.NumPaths);
                    //--------------------------------------------------------------------------------------
                    //filled Ellipse
                    //1. create original fill ellipse
                    RectD lionBound     = lionShape.Bounds;
                    var   filledEllipse = new Ellipse((lionBound.Left + lionBound.Right) * 0.5,
                                                      (lionBound.Bottom + lionBound.Top) * 0.5,
                                                      (lionBound.Right - lionBound.Left) * 0.5,
                                                      (lionBound.Top - lionBound.Bottom) * 0.5,
                                                      200);

                    VectorToolBox.GetFreeVxs(out var v2, out var transformedEll);

                    txPerspective.TransformToVxs(filledEllipse.MakeVxs(v2), transformedEll);
                    painter.FillColor = ColorEx.Make(0.5f, 0.3f, 0.0f, 0.3f);
                    painter.Fill(transformedEll);
                    //--------------------------------------------------------
                    var prevStrokeW = painter.StrokeWidth;
                    painter.StrokeWidth = 3;
                    painter.StrokeColor = ColorEx.Make(0.0f, 0.3f, 0.2f, 1.0f);
                    painter.Draw(transformedEll);
                    painter.StrokeWidth = prevStrokeW;


                    VectorToolBox.ReleaseVxs(ref v2, ref transformedEll);
                }
            }

            //--------------------------
            // Render the "quad" tool and controls
            painter.FillColor = ColorEx.Make(0f, 0.3f, 0.5f, 0.6f);

            VectorToolBox.GetFreeVxs(out var v4);
            painter.Fill(quadPolygonControl.MakeVxs(v4));
            VectorToolBox.ReleaseVxs(ref v4);
        }
Exemple #17
0
        //---------------------------------------------------------------------
        public void DrawArc(float fromX, float fromY, float endX, float endY,
                            float xaxisRotationAngleDec, float rx, float ry,
                            SvgArcSize arcSize, SvgArcSweep arcSweep)
        {
            //------------------
            //SVG Elliptical arc ...
            //from Apache Batik
            //-----------------

            CenterFormArc centerFormArc = new CenterFormArc();

            ComputeArc2(fromX, fromY, rx, ry,
                        DegToRad(xaxisRotationAngleDec),
                        arcSize == SvgArcSize.Large,
                        arcSweep == SvgArcSweep.Negative,
                        endX, endY, ref centerFormArc);
            _arcTool.Init(centerFormArc.cx, centerFormArc.cy, rx, ry,
                          centerFormArc.radStartAngle,
                          (centerFormArc.radStartAngle + centerFormArc.radSweepDiff));


            VectorToolBox.GetFreeVxs(out VertexStore v1);

            bool stopLoop = false;

            foreach (VertexData vertexData in _arcTool.GetVertexIter())
            {
                switch (vertexData.command)
                {
                case VertexCmd.NoMore:
                    stopLoop = true;
                    break;

                default:
                    v1.AddVertex(vertexData.x, vertexData.y, vertexData.command);
                    //yield return vertexData;
                    break;
                }
                //------------------------------
                if (stopLoop)
                {
                    break;
                }
            }

            double scaleRatio = 1;

            if (centerFormArc.scaleUp)
            {
                int    vxs_count = v1.Count;
                double px0, py0, px_last, py_last;
                v1.GetVertex(0, out px0, out py0);
                v1.GetVertex(vxs_count - 1, out px_last, out py_last);
                double distance1 = Math.Sqrt((px_last - px0) * (px_last - px0) + (py_last - py0) * (py_last - py0));
                double distance2 = Math.Sqrt((endX - fromX) * (endX - fromX) + (endY - fromY) * (endY - fromY));
                if (distance1 < distance2)
                {
                    scaleRatio = distance2 / distance1;
                }
                else
                {
                }
            }

            if (xaxisRotationAngleDec != 0)
            {
                //also  rotate
                if (centerFormArc.scaleUp)
                {
                    var mat = PixelFarm.Agg.Transform.Affine.NewMatix(
                        new PixelFarm.Agg.Transform.AffinePlan(PixelFarm.Agg.Transform.AffineMatrixCommand.Translate, -centerFormArc.cx, -centerFormArc.cy),
                        new PixelFarm.Agg.Transform.AffinePlan(PixelFarm.Agg.Transform.AffineMatrixCommand.Scale, scaleRatio, scaleRatio),
                        new PixelFarm.Agg.Transform.AffinePlan(PixelFarm.Agg.Transform.AffineMatrixCommand.Rotate, DegToRad(xaxisRotationAngleDec)),
                        new PixelFarm.Agg.Transform.AffinePlan(PixelFarm.Agg.Transform.AffineMatrixCommand.Translate, centerFormArc.cx, centerFormArc.cy));
                    VectorToolBox.GetFreeVxs(out VertexStore v2);
                    mat.TransformToVxs(v1, v2);
                    VectorToolBox.ReleaseVxs(ref v1);
                    v1 = v2;
                }
                else
                {
                    //not scalue
                    var mat = PixelFarm.Agg.Transform.Affine.NewMatix(
                        new PixelFarm.Agg.Transform.AffinePlan(PixelFarm.Agg.Transform.AffineMatrixCommand.Translate, -centerFormArc.cx, -centerFormArc.cy),
                        new PixelFarm.Agg.Transform.AffinePlan(PixelFarm.Agg.Transform.AffineMatrixCommand.Rotate, DegToRad(xaxisRotationAngleDec)),
                        new PixelFarm.Agg.Transform.AffinePlan(PixelFarm.Agg.Transform.AffineMatrixCommand.Translate, centerFormArc.cx, centerFormArc.cy));
                    VectorToolBox.GetFreeVxs(out VertexStore v2);
                    mat.TransformToVxs(v1, v2);
                    VectorToolBox.ReleaseVxs(ref v1);
                    v1 = v2;
                }
            }
            else
            {
                //no rotate
                if (centerFormArc.scaleUp)
                {
                    var mat = PixelFarm.Agg.Transform.Affine.NewMatix(
                        new PixelFarm.Agg.Transform.AffinePlan(PixelFarm.Agg.Transform.AffineMatrixCommand.Translate, -centerFormArc.cx, -centerFormArc.cy),
                        new PixelFarm.Agg.Transform.AffinePlan(PixelFarm.Agg.Transform.AffineMatrixCommand.Scale, scaleRatio, scaleRatio),
                        new PixelFarm.Agg.Transform.AffinePlan(PixelFarm.Agg.Transform.AffineMatrixCommand.Translate, centerFormArc.cx, centerFormArc.cy));

                    VectorToolBox.GetFreeVxs(out VertexStore v2);
                    mat.TransformToVxs(v1, v2);
                    VectorToolBox.ReleaseVxs(ref v1);

                    v1 = v2;
                }
            }

            _aggStroke.Width = this.StrokeWidth;


            VectorToolBox.GetFreeVxs(out VertexStore v3);
            _aggStroke.MakeVxs(v1, v3);

            _glsx.DrawGfxPath(_glsx.StrokeColor, _igfxPathBuilder.CreateGraphicsPath(v3));


            VectorToolBox.ReleaseVxs(ref v3);
            VectorToolBox.ReleaseVxs(ref v1);
        }
Exemple #18
0
        public override void FillEllipse(double left, double top, double width, double height)
        {
            //version 2:
            //agg's ellipse tools with smooth border

            double x  = (left + width / 2);
            double y  = (top + height / 2);
            double rx = Math.Abs(width / 2);
            double ry = Math.Abs(height / 2);



            if (this._orientation == DrawBoardOrientation.LeftTop)
            {
                y = _glsx.ViewportHeight - y; //set new y
            }

            ellipse.Reset(x, y, rx, ry);

            VectorToolBox.GetFreeVxs(out VertexStore vxs);
            ellipse.MakeVxs(vxs);
            //***
            //we fill
            _glsx.FillGfxPath(_strokeColor, _igfxPathBuilder.CreateGraphicsPath(vxs));
            VectorToolBox.ReleaseVxs(ref vxs);

            //-------------------------------------------------------------
            //
            //version 1,just triangular fans, no smooth border

            //double x = (left + right) / 2;
            //double y = (bottom + top) / 2;
            //double rx = Math.Abs(right - x);
            //double ry = Math.Abs(top - y);

            //if (this._orientation == DrawBoardOrientation.LeftTop)
            //{
            //    y = _glsx.ViewportHeight - y; //set new y
            //}

            //ellipse.Reset(x, y, rx, ry);
            //var v1 = GetFreeVxs();
            //ellipse.MakeVxs(v1);
            ////other mode
            //int n = v1.Count;
            ////make triangular fan***

            //float[] coords = new float[(n * 2) + 4];
            //int i = 0;
            //int nn = 0;
            //int npoints = 0;
            //double vx, vy;
            ////center
            //coords[nn++] = (float)x;
            //coords[nn++] = (float)y;
            //npoints++;
            //var cmd = v1.GetVertex(i, out vx, out vy);
            //while (i < n)
            //{
            //    switch (cmd)
            //    {
            //        case VertexCmd.MoveTo:
            //            {
            //                coords[nn++] = (float)vx;
            //                coords[nn++] = (float)vy;
            //                npoints++;
            //            }
            //            break;
            //        case VertexCmd.LineTo:
            //            {
            //                coords[nn++] = (float)vx;
            //                coords[nn++] = (float)vy;
            //                npoints++;
            //            }
            //            break;
            //        case VertexCmd.NoMore:
            //            {
            //            }
            //            break;
            //        default:
            //            {
            //            }
            //            break;
            //    }
            //    i++;
            //    cmd = v1.GetVertex(i, out vx, out vy);
            //}
            ////close circle
            //coords[nn++] = coords[2];
            //coords[nn++] = coords[3];
            //npoints++;
            ////----------------------------------------------
            //_glsx.FillTriangleFan(_fillColor, coords, npoints);
            //ReleaseVxs(ref v1);
            ////----------------------------------------------
        }
        public override void Draw(Painter p)
        {
            if (UseBitmapExt)
            {
                p.RenderQuality = RenderQualtity.Fast;
            }
            else
            {
                p.RenderQuality = RenderQualtity.HighQuality;
            }



            int width  = 800;
            int height = 600;

            //clear the image to white
            // draw a circle
            p.Clear(Drawing.Color.White);
            Ellipse ellipseVxsGen = new Ellipse(0, 0, 100, 50);

            for (double angleDegrees = 0; angleDegrees < 180; angleDegrees += 22.5)
            {
                var mat = Affine.NewMatix(
                    AffinePlan.Rotate(MathHelper.DegreesToRadians(angleDegrees)),
                    AffinePlan.Translate(width / 2, 150));


                VectorToolBox.GetFreeVxs(out var v1, out var v2, out var v3);
                mat.TransformToVxs(ellipseVxsGen.MakeVxs(v1), v2);

                p.FillColor = Drawing.Color.Yellow;
                p.Fill(v2);
                //------------------------------------
                //g.Render(sp1, ColorRGBA.Yellow);
                //Stroke ellipseOutline = new Stroke(sp1, 3);
                p.FillColor  = Drawing.Color.Blue;
                stroke.Width = 3;
                p.Fill(stroke.MakeVxs(v2, v3));
                //g.Render(StrokeHelp.MakeVxs(sp1, 3), ColorRGBA.Blue);
                VectorToolBox.ReleaseVxs(ref v1, ref v2, ref v3);
            }

            // and a little polygon
            PathWriter littlePoly = new PathWriter();

            littlePoly.MoveTo(50, 50);
            littlePoly.LineTo(150, 50);
            littlePoly.LineTo(200, 200);
            littlePoly.LineTo(50, 150);
            littlePoly.LineTo(50, 50);
            p.FillColor = Drawing.Color.Blue;
            p.Fill(littlePoly.MakeVertexSnap());


            //----
            //test draw img



            //
            //g.Render(littlePoly.MakeVertexSnap(), ColorRGBA.Cyan);
            // draw some text
            // draw some text

            //var textPrinter = new TextPrinter();
            //textPrinter.CurrentActualFont = svgFontStore.LoadFont(SvgFontStore.DEFAULT_SVG_FONTNAME, 30);
            //new TypeFacePrinter("Printing from a printer", 30, justification: Justification.Center);

            //VertexStore vxs = textPrinter.CreateVxs("Printing from a printer".ToCharArray());
            //var affTx = Affine.NewTranslation(width / 2, height / 4 * 3);
            //VertexStore s1 = affTx.TransformToVxs(vxs);
            //p.FillColor = Drawing.Color.Black;
            //p.Fill(s1);
            ////g.Render(s1, ColorRGBA.Black);
            //p.FillColor = Drawing.Color.Red;
            //p.Fill(StrokeHelp.MakeVxs(s1, 1));
            ////g.Render(StrokeHelp.MakeVxs(s1, 1), ColorRGBA.Red);
            //var aff2 = Affine.NewMatix(
            //    AffinePlan.Rotate(MathHelper.DegreesToRadians(90)),
            //    AffinePlan.Translate(40, height / 2));
            //p.FillColor = Drawing.Color.Black;
            //p.Fill(aff2.TransformToVertexSnap(vxs));
            ////g.Render(aff2.TransformToVertexSnap(vxs), ColorRGBA.Black);
        }
        public override void Draw(Painter p)
        {
            if (p is GdiPlusPainter)
            {
                DrawWithWinGdi((GdiPlusPainter)p);
                return;
            }
            AggPainter       p2      = (AggPainter)p;
            AggRenderSurface aggRdsf = p2.RenderSurface;
            var widgetsSubImage      = aggRdsf.DestImage;
            var scline = aggRdsf.ScanlinePacked8;
            int width  = (int)widgetsSubImage.Width;
            int height = (int)widgetsSubImage.Height;

            //change value ***
            if (isMaskSliderValueChanged)
            {
                generate_alpha_mask(aggRdsf.ScanlineRasToDestBitmap, aggRdsf.ScanlinePacked8, aggRdsf.ScanlineRasterizer, width, height);
                this.isMaskSliderValueChanged = false;
            }
            var rasterizer = aggRdsf.ScanlineRasterizer;

            rasterizer.SetClipBox(0, 0, width, height);
            //alphaMaskImageBuffer.AttachBuffer(alphaByteArray, 0, width, height, width, 8, 1);

            PixelFarm.Agg.Imaging.AlphaMaskAdaptor imageAlphaMaskAdaptor = new PixelFarm.Agg.Imaging.AlphaMaskAdaptor(widgetsSubImage, alphaMask);
            ClipProxyImage alphaMaskClippingProxy = new ClipProxyImage(imageAlphaMaskAdaptor);
            ClipProxyImage clippingProxy          = new ClipProxyImage(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);
            Affine transform = Affine.NewMatix(
                AffinePlan.Translate(-lionShape.Center.x, -lionShape.Center.y),
                AffinePlan.Scale(lionScale, lionScale),
                AffinePlan.Rotate(angle + Math.PI),
                AffinePlan.Skew(skewX / 1000.0, skewY / 1000.0),
                AffinePlan.Translate(width / 2, height / 2));

            clippingProxy.Clear(Drawing.Color.White);
            ScanlineRasToDestBitmapRenderer sclineRasToBmp = aggRdsf.ScanlineRasToDestBitmap;
            // draw a background to show how the mask is working better
            int rect_w = 30;

            VectorToolBox.GetFreeVxs(out var v1);
            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 * rect_w, j * rect_w, (i + 1) * rect_w, (j + 1) * rect_w, 0);
                        rect.NormalizeRadius();
                        // Drawing as an outline
                        rasterizer.AddPath(rect.MakeVxs(v1));
                        v1.Clear();
                        sclineRasToBmp.RenderWithColor(clippingProxy, rasterizer, scline, ColorEx.Make(.9f, .9f, .9f));
                    }
                }
            }
            VectorToolBox.ReleaseVxs(ref v1);

            ////int x, y;
            //// Render the lion
            ////VertexSourceApplyTransform trans = new VertexSourceApplyTransform(lionShape.Path, transform);

            ////var vxlist = new System.Collections.Generic.List<VertexData>();
            ////trans.DoTransform(vxlist);

            //var tmpVxs1 = new VertexStore();
            //lionShape.ApplyTransform(transform);

            throw new NotImplementedException();

            //sclineRasToBmp.RenderSolidAllPaths(alphaMaskClippingProxy,
            //       rasterizer,
            //       scline,
            //       tmpVxs1,
            //       lionShape.Colors,
            //       lionShape.PathIndexList,
            //       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);
        }
        void render_gpc(Painter p)
        {
            switch (this.PolygonSet)
            {
            case PolygonExampleSet.TwoSimplePaths:
            {
                //------------------------------------
                // Two simple paths
                //
                PathWriter ps1 = new PathWriter();
                PathWriter ps2 = new PathWriter();
                double     x   = m_x - Width / 2 + 100;
                double     y   = m_y - Height / 2 + 100;
                ps1.MoveTo(x + 140, y + 145);
                ps1.LineTo(x + 225, y + 44);
                ps1.LineTo(x + 296, y + 219);
                ps1.CloseFigure();
                //
                ps1.LineTo(x + 226, y + 289);
                ps1.LineTo(x + 82, y + 292);
                //
                ps1.MoveTo(x + 220, y + 222);
                ps1.LineTo(x + 363, y + 249);
                ps1.LineTo(x + 265, y + 331);
                ps1.MoveTo(x + 242, y + 243);
                ps1.LineTo(x + 268, y + 309);
                ps1.LineTo(x + 325, y + 261);
                ps1.MoveTo(x + 259, y + 259);
                ps1.LineTo(x + 273, y + 288);
                ps1.LineTo(x + 298, y + 266);
                ps1.CloseFigure();
                //
                ps2.MoveTo(100 + 32, 100 + 77);
                ps2.LineTo(100 + 473, 100 + 263);
                ps2.LineTo(100 + 351, 100 + 290);
                ps2.LineTo(100 + 354, 100 + 374);
                ps2.CloseFigure();
                p.FillColor = ColorEx.Make(0f, 0f, 0f, 0.1f);
                p.Fill(ps1.MakeVertexSnap());
                p.FillColor = ColorEx.Make(0f, 0.6f, 0f, 0.1f);
                p.Fill(ps2.MakeVertexSnap());
                CreateAndRenderCombined(p, ps1.MakeVertexSnap(), ps2.MakeVertexSnap());
            }
            break;

            case PolygonExampleSet.CloseStroke:
            {
                //------------------------------------
                // Closed stroke
                //
                PathWriter ps1    = new PathWriter();
                PathWriter ps2    = new PathWriter();
                Stroke     stroke = new Stroke(1);
                stroke.Width = 10;
                double x = m_x - Width / 2 + 100;
                double y = m_y - Height / 2 + 100;
                //-----------------------------------------
                ps1.MoveTo(x + 140, y + 145);
                ps1.LineTo(x + 225, y + 44);
                ps1.LineTo(x + 296, y + 219);
                ps1.CloseFigure();
                ps1.LineTo(x + 226, y + 289);
                ps1.LineTo(x + 82, y + 292);
                ps1.MoveTo(x + 220 - 50, y + 222);
                ps1.LineTo(x + 265 - 50, y + 331);
                ps1.LineTo(x + 363 - 50, y + 249);
                ps1.CloseFigureCCW();
                //-----------------------------------------


                ps2.MoveTo(100 + 32, 100 + 77);
                ps2.LineTo(100 + 473, 100 + 263);
                ps2.LineTo(100 + 351, 100 + 290);
                ps2.LineTo(100 + 354, 100 + 374);
                ps2.CloseFigure();
                p.FillColor = ColorEx.Make(0f, 0f, 0f, 0.1f);
                p.Fill(ps1.MakeVertexSnap());
                //graphics2D.Render(ps1.MakeVertexSnap(), ColorRGBAf.MakeColorRGBA(0f, 0f, 0f, 0.1f));
                var vxs = ps2.Vxs;
                //graphics2D.Render(stroke.MakeVxs(vxs), ColorRGBAf.MakeColorRGBA(0f, 0.6f, 0f, 0.1f));
                p.FillColor = ColorEx.Make(0f, 0.6f, 0f, 0.1f);

                VectorToolBox.GetFreeVxs(out var v1);
                p.Fill(stroke.MakeVxs(vxs, v1));
                VectorToolBox.ReleaseVxs(ref v1);
                CreateAndRenderCombined(p, ps1.MakeVertexSnap(), new VertexStoreSnap(vxs));
            }
            break;

            case PolygonExampleSet.GBAndArrow:
            {
                //------------------------------------
                // Great Britain and Arrows
                //
                PathWriter gb_poly = new PathWriter();
                PathWriter arrows  = new PathWriter();
                PixelFarm.Agg.Sample_PolygonClipping.GreatBritanPathStorage.Make(gb_poly);
                make_arrows(arrows);
                //Affine mtx1 = Affine.NewIdentity();
                //mtx1 *= Affine.NewTranslation(-1150, -1150);
                //mtx1 *= Affine.NewScaling(2.0);
                Affine mtx1 = Affine.NewMatix(
                    AffinePlan.Translate(-1150, -1150),
                    AffinePlan.Scale(2)
                    );
                //Affine.NewIdentity();
                //mtx2 = mtx1;
                //mtx2 *= Affine.NewTranslation(m_x - Width / 2, m_y - Height / 2);
                Affine mtx2 = mtx1 * Affine.NewTranslation(m_x - Width / 2, m_y - Height / 2);
                //VertexSourceApplyTransform trans_gb_poly = new VertexSourceApplyTransform(gb_poly, mtx1);
                //VertexSourceApplyTransform trans_arrows = new VertexSourceApplyTransform(arrows, mtx2);

                var trans_gb_poly = new VertexStore();
                mtx1.TransformToVxs(gb_poly.Vxs, trans_gb_poly);

                var trans_arrows = new VertexStore();
                mtx2.TransformToVxs(arrows.Vxs, trans_arrows);


                p.FillColor = ColorEx.Make(0.5f, 0.5f, 0f, 0.1f);
                p.Fill(trans_gb_poly);
                //graphics2D.Render(trans_gb_poly, ColorRGBAf.MakeColorRGBA(0.5f, 0.5f, 0f, 0.1f));
                //stroke_gb_poly.Width = 0.1;
                p.FillColor = ColorEx.Make(0, 0, 0);

                VectorToolBox.GetFreeVxs(out var v1);
                p.Fill(new Stroke(0.1).MakeVxs(trans_gb_poly, v1));
                VectorToolBox.ReleaseVxs(ref v1);
                //graphics2D.Render(new Stroke(0.1).MakeVxs(trans_gb_poly), ColorRGBAf.MakeColorRGBA(0, 0, 0));
                //graphics2D.Render(trans_arrows, ColorRGBAf.MakeColorRGBA(0f, 0.5f, 0.5f, 0.1f));
                p.FillColor = ColorEx.Make(0f, 0.5f, 0.5f, 0.1f);
                p.Fill(trans_arrows);
                CreateAndRenderCombined(p, new VertexStoreSnap(trans_gb_poly), new VertexStoreSnap(trans_arrows));
            }
            break;

            case PolygonExampleSet.GBAndSpiral:
            {
                //------------------------------------
                // Great Britain and a Spiral
                //
                spiral     sp      = new spiral(m_x, m_y, 10, 150, 30, 0.0);
                PathWriter gb_poly = new PathWriter();
                PixelFarm.Agg.Sample_PolygonClipping.GreatBritanPathStorage.Make(gb_poly);
                Affine mtx = Affine.NewMatix(
                    AffinePlan.Translate(-1150, -1150),
                    AffinePlan.Scale(2));
                //

                VectorToolBox.GetFreeVxs(out var s1, out var v1);
                VectorToolBox.GetFreeVxs(out var v2, out var v3);

                mtx.TransformToVxs(gb_poly.Vxs, s1);
                p.FillColor = ColorEx.Make(0.5f, 0.5f, 0f, 0.1f);
                p.Fill(s1);
                //graphics2D.Render(s1, ColorRGBAf.MakeColorRGBA(0.5f, 0.5f, 0f, 0.1f));

                //graphics2D.Render(new Stroke(0.1).MakeVxs(s1), ColorRGBA.Black);
                p.FillColor = Color.Black;


                p.Fill(new Stroke(0.1).MakeVxs(s1, v1));
                var stroke_vxs = new Stroke(15).MakeVxs(sp.MakeVxs(v2), v3);
                p.FillColor = ColorEx.Make(0.0f, 0.5f, 0.5f, 0.1f);        // XUolorRXBAf.MakeColorRGBA(0.0f, 0.5f, 0.5f, 0.1f);
                p.Fill(stroke_vxs);
                //graphics2D.Render(stroke_vxs, ColorRGBAf.MakeColorRGBA(0.0f, 0.5f, 0.5f, 0.1f));
                CreateAndRenderCombined(p, new VertexStoreSnap(s1), new VertexStoreSnap(stroke_vxs));

                VectorToolBox.ReleaseVxs(ref s1, ref v1);
                VectorToolBox.ReleaseVxs(ref v2, ref v3);
            }
            break;

            case PolygonExampleSet.SprialAndGlyph:
            {
                //------------------------------------
                // Spiral and glyph
                //
                spiral     sp     = new spiral(m_x, m_y, 10, 150, 30, 0.0);
                Stroke     stroke = new Stroke(15);
                PathWriter glyph  = new PathWriter();
                glyph.MoveTo(28.47, 6.45);
                glyph.Curve3(21.58, 1.12, 19.82, 0.29);
                glyph.Curve3(17.19, -0.93, 14.21, -0.93);
                glyph.Curve3(9.57, -0.93, 6.57, 2.25);
                glyph.Curve3(3.56, 5.42, 3.56, 10.60);
                glyph.Curve3(3.56, 13.87, 5.03, 16.26);
                glyph.Curve3(7.03, 19.58, 11.99, 22.51);
                glyph.Curve3(16.94, 25.44, 28.47, 29.64);
                glyph.LineTo(28.47, 31.40);
                glyph.Curve3(28.47, 38.09, 26.34, 40.58);
                glyph.Curve3(24.22, 43.07, 20.17, 43.07);
                glyph.Curve3(17.09, 43.07, 15.28, 41.41);
                glyph.Curve3(13.43, 39.75, 13.43, 37.60);
                glyph.LineTo(13.53, 34.77);
                glyph.Curve3(13.53, 32.52, 12.38, 31.30);
                glyph.Curve3(11.23, 30.08, 9.38, 30.08);
                glyph.Curve3(7.57, 30.08, 6.42, 31.35);
                glyph.Curve3(5.27, 32.62, 5.27, 34.81);
                glyph.Curve3(5.27, 39.01, 9.57, 42.53);
                glyph.Curve3(13.87, 46.04, 21.63, 46.04);
                glyph.Curve3(27.59, 46.04, 31.40, 44.04);
                glyph.Curve3(34.28, 42.53, 35.64, 39.31);
                glyph.Curve3(36.52, 37.21, 36.52, 30.71);
                glyph.LineTo(36.52, 15.53);
                glyph.Curve3(36.52, 9.13, 36.77, 7.69);
                glyph.Curve3(37.01, 6.25, 37.57, 5.76);
                glyph.Curve3(38.13, 5.27, 38.87, 5.27);
                glyph.Curve3(39.65, 5.27, 40.23, 5.62);
                glyph.Curve3(41.26, 6.25, 44.19, 9.18);
                glyph.LineTo(44.19, 6.45);
                glyph.Curve3(38.72, -0.88, 33.74, -0.88);
                glyph.Curve3(31.35, -0.88, 29.93, 0.78);
                glyph.Curve3(28.52, 2.44, 28.47, 6.45);
                glyph.CloseFigure();
                glyph.MoveTo(28.47, 9.62);
                glyph.LineTo(28.47, 26.66);
                glyph.Curve3(21.09, 23.73, 18.95, 22.51);
                glyph.Curve3(15.09, 20.36, 13.43, 18.02);
                glyph.Curve3(11.77, 15.67, 11.77, 12.89);
                glyph.Curve3(11.77, 9.38, 13.87, 7.06);
                glyph.Curve3(15.97, 4.74, 18.70, 4.74);
                glyph.Curve3(22.41, 4.74, 28.47, 9.62);
                glyph.CloseFigure();
                //Affine mtx = Affine.NewIdentity();
                //mtx *= Affine.NewScaling(4.0);
                //mtx *= Affine.NewTranslation(220, 200);
                Affine mtx = Affine.NewMatix(
                    AffinePlan.Scale(4),
                    AffinePlan.Translate(220, 200));
                var t_glyph = new VertexStore();

                mtx.TransformToVertexSnap(glyph.Vxs, t_glyph);


                VectorToolBox.GetFreeVxs(out var v1, out var v2, out var v3);

                var sp1 = stroke.MakeVxs(sp.MakeVxs(v1), v2);

                var curveVxs = new VertexStore();
                curveFlattener.MakeVxs(t_glyph, curveVxs);
                CreateAndRenderCombined(p, new VertexStoreSnap(sp1), new VertexStoreSnap(curveVxs));
                p.FillColor = ColorEx.Make(0f, 0f, 0f, 0.1f);
                p.Fill(stroke.MakeVxs(sp1, v3));
                //graphics2D.Render(stroke.MakeVxs(sp1), ColorRGBAf.MakeColorRGBA(0f, 0f, 0f, 0.1f));

                p.FillColor = ColorEx.Make(0f, 0.6f, 0f, 0.1f);
                p.Fill(curveVxs);
                //graphics2D.Render(curveVxs, ColorRGBAf.MakeColorRGBA(0f, 0.6f, 0f, 0.1f));


                VectorToolBox.ReleaseVxs(ref v1, ref v2, ref v3);
            }
            break;
            }
        }
Exemple #22
0
        public override VertexStore MakeVxs(VertexStore vxs)
        {
            this.RewindZero();
            //this polygon control has  2 subcontrol
            //stroke and ellipse

            VectorToolBox.GetFreeVxs(out var v1, out var v2);
            this.m_stroke.MakeVxs(this.m_vs.MakeVxs(v1), v2);
            int    j = v2.Count;
            double x, y;

            for (int i = 0; i < j; ++i)
            {
                var cmd = v2.GetVertex(i, out x, out y);
                if (cmd == VertexCmd.NoMore)
                {
                    break;
                }
                else
                {
                    vxs.AddVertex(x, y, cmd);
                }
            }

            VectorToolBox.ReleaseVxs(ref v1, ref v2);
            //------------------------------------------------------------
            //draw each polygon point
            double r = m_point_radius;

            if (m_node >= 0 && m_node == (int)(m_status))
            {
                r *= 1.2;
            }

            int n_count = m_polygon.Length / 2;

            VectorToolBox.GetFreeVxs(out var v3);
            for (int m = 0; m < n_count; ++m)
            {
                m_ellipse.Reset(GetXN(m), GetYN(m), r, r, 32);

                var ellipseVxs = m_ellipse.MakeVxs(v3);
                j = ellipseVxs.Count;
                for (int i = 0; i < j; ++i)
                {
                    var cmd = ellipseVxs.GetVertex(i, out x, out y);
                    if (cmd == VertexCmd.NoMore)
                    {
                        break;
                    }
                    vxs.AddVertex(x, y, cmd);
                }
                m_status++;

                //reuse
                v3.Clear();
            }
            VectorToolBox.ReleaseVxs(ref v3);
            //------------------------------------------------------------

            //close with stop
            vxs.AddVertex(0, 0, VertexCmd.NoMore);
            return(vxs);
        }
        void GenerateMaskWithWinGdiPlus(int w, int h)
        {
            //1. create 32 bits for mask image
            this.a_alphaBmp = new System.Drawing.Bitmap(w, h);
            //2. create graphics based on a_alphaBmp
            using (System.Drawing.Graphics gfxBmp = System.Drawing.Graphics.FromImage(a_alphaBmp))
            {
                gfxBmp.Clear(System.Drawing.Color.Black);
                //ClipProxyImage clippingProxy = new ClipProxyImage(image);
                //clippingProxy.Clear(ColorRGBA.Black);
                VertexSource.Ellipse ellipseForMask = new PixelFarm.Agg.VertexSource.Ellipse();
                System.Random        randGenerator  = new Random(1432);
                int num = (int)maskAlphaSliderValue;
                int lim = num - 1;
                for (int i = 0; i < lim; ++i)
                {
                    ellipseForMask.Reset(randGenerator.Next() % w,
                                         randGenerator.Next() % h,
                                         randGenerator.Next() % 100 + 20,
                                         randGenerator.Next() % 100 + 20,
                                         100);
                    // set the color to draw into the alpha channel.
                    // there is not very much reason to set the alpha as you will get the amount of
                    // transparency based on the color you draw.  (you might want some type of different edeg effect but it will be minor).
                    //rasterizer.AddPath(ellipseForMask.MakeVxs());
                    //sclineRasToBmp.RenderWithColor(clippingProxy, rasterizer, sclnPack,
                    //   ColorRGBA.Make((int)((float)i / (float)num * 255), 0, 0, 255));

                    VectorToolBox.GetFreeVxs(out var v1);
                    VxsHelper.FillVxsSnap(gfxBmp, ellipseForMask.MakeVertexSnap(v1), ColorEx.Make((int)((float)i / (float)num * 255), 0, 0, 255));
                    VectorToolBox.ReleaseVxs(ref v1);
                }
                //the last one
                ellipseForMask.Reset(Width / 2, Height / 2, 110, 110, 100);
                //fill
                VectorToolBox.GetFreeVxs(out var v2);
                VxsHelper.FillVxsSnap(gfxBmp, ellipseForMask.MakeVertexSnap(v2), ColorEx.Make(0, 0, 0, 255));
                v2.Clear();// reuse later
                //rasterizer.AddPath(ellipseForMask.MakeVertexSnap());
                //sclineRasToBmp.RenderWithColor(clippingProxy, rasterizer, sclnPack, new ColorRGBA(0, 0, 0, 255));
                ellipseForMask.Reset(ellipseForMask.originX, ellipseForMask.originY, ellipseForMask.radiusX - 10, ellipseForMask.radiusY - 10, 100);
                //rasterizer.AddPath(ellipseForMask.MakeVertexSnap());
                //sclineRasToBmp.RenderWithColor(clippingProxy, rasterizer, sclnPack, new ColorRGBA(255, 0, 0, 255));

                VxsHelper.FillVxsSnap(gfxBmp, ellipseForMask.MakeVertexSnap(v2), ColorEx.Make(255, 0, 0, 255));

                VectorToolBox.ReleaseVxs(ref v2);

                //for (i = 0; i < num; i++)
                //{
                //    if (i == num - 1)
                //    {
                //        ellipseForMask.Reset(Width / 2, Height / 2, 110, 110, 100);
                //        //fill
                //        VxsHelper.DrawVxsSnap(gfxBmp, ellipseForMask.MakeVertexSnap(), new ColorRGBA(0, 0, 0, 255));
                //        //rasterizer.AddPath(ellipseForMask.MakeVertexSnap());
                //        //sclineRasToBmp.RenderWithColor(clippingProxy, rasterizer, sclnPack, new ColorRGBA(0, 0, 0, 255));
                //        ellipseForMask.Reset(ellipseForMask.originX, ellipseForMask.originY, ellipseForMask.radiusX - 10, ellipseForMask.radiusY - 10, 100);
                //        //rasterizer.AddPath(ellipseForMask.MakeVertexSnap());
                //        //sclineRasToBmp.RenderWithColor(clippingProxy, rasterizer, sclnPack, new ColorRGBA(255, 0, 0, 255));
                //        VxsHelper.DrawVxsSnap(gfxBmp, ellipseForMask.MakeVertexSnap(), new ColorRGBA(255, 0, 0, 255));
                //    }
                //    else
                //    {
                //        ellipseForMask.Reset(randGenerator.Next() % w,
                //                 randGenerator.Next() % h,
                //                 randGenerator.Next() % 100 + 20,
                //                 randGenerator.Next() % 100 + 20,
                //                 100);
                //        // set the color to draw into the alpha channel.
                //        // there is not very much reason to set the alpha as you will get the amount of
                //        // transparency based on the color you draw.  (you might want some type of different edeg effect but it will be minor).
                //        //rasterizer.AddPath(ellipseForMask.MakeVxs());
                //        //sclineRasToBmp.RenderWithColor(clippingProxy, rasterizer, sclnPack,
                //        //   ColorRGBA.Make((int)((float)i / (float)num * 255), 0, 0, 255));
                //        VxsHelper.DrawVxsSnap(gfxBmp, ellipseForMask.MakeVertexSnap(), ColorRGBA.Make((int)((float)i / (float)num * 255), 0, 0, 255));
                //    }
                //}
            }
        }
        public void Render(IImageReaderWriter source, double destX, double destY)
        {
            int inScaleX     = 1;
            int inScaleY     = 1;
            int angleRadians = 0;
            // exit early if the dest and source bounds don't touch.
            // TODO: <BUG> make this do rotation and scalling
            RectInt sourceBounds = source.GetBounds();

            sourceBounds.Offset((int)destX, (int)destY);

            RectInt destBounds = this.destImageReaderWriter.GetBounds();

            if (!RectInt.DoIntersect(sourceBounds, destBounds))
            {
                //if (inScaleX != 1 || inScaleY != 1 || angleRadians != 0)
                //{
                //    throw new NotImplementedException();
                //}
                return;
            }

            double scaleX            = inScaleX;
            double scaleY            = inScaleY;
            Affine graphicsTransform = this.CurrentTransformMatrix;

            if (!graphicsTransform.IsIdentity())
            {
                if (scaleX != 1 || scaleY != 1 || angleRadians != 0)
                {
                    throw new NotImplementedException();
                }
                graphicsTransform.Transform(ref destX, ref destY);
            }


#if false // this is an optomization that eliminates the drawing of images that have their alpha set to all 0 (happens with generated images like explosions).
            MaxAlphaFrameProperty maxAlphaFrameProperty = MaxAlphaFrameProperty::GetMaxAlphaFrameProperty(source);

            if ((maxAlphaFrameProperty.GetMaxAlpha() * color.A_Byte) / 256 <= ALPHA_CHANNEL_BITS_DIVISOR)
            {
                m_OutFinalBlitBounds.SetRect(0, 0, 0, 0);
            }
#endif
            bool isScale   = (scaleX != 1 || scaleY != 1);
            bool isRotated = false;
            if (angleRadians != 0 && Math.Abs(angleRadians) >= (0.1 * MathHelper.Tau / 360))
            {
                isRotated = true;
            }
            else
            {
                angleRadians = 0;//reset very small angle to 0
            }


            //bool IsMipped = false;
            //double ox, oy;
            //source.GetOriginOffset(out ox, out oy);

            bool canUseMipMaps = isScale;
            if (scaleX > 0.5 || scaleY > 0.5)
            {
                canUseMipMaps = false;
            }

            bool needSourceResampling = isScale || isRotated || destX != (int)destX || destY != (int)destY;



            VectorToolBox.GetFreeVxs(out VertexStore imgBoundsPath);
            // this is the fast drawing path
            if (needSourceResampling)
            {
#if false // if the scalling is small enough the results can be improved by using mip maps
                if (CanUseMipMaps)
                {
                    CMipMapFrameProperty *pMipMapFrameProperty = CMipMapFrameProperty::GetMipMapFrameProperty(source);
                    double OldScaleX = scaleX;
                    double OldScaleY = scaleY;
                    const CFrameInterface *pMippedFrame = pMipMapFrameProperty.GetMipMapFrame(ref scaleX, ref scaleY);
                    if (pMippedFrame != source)
                    {
                        IsMipped             = true;
                        source               = pMippedFrame;
                        sourceOriginOffsetX *= (OldScaleX / scaleX);
                        sourceOriginOffsetY *= (OldScaleY / scaleY);
                    }

                    HotspotOffsetX *= (inScaleX / scaleX);
                    HotspotOffsetY *= (inScaleY / scaleY);
                }
#endif


                Affine destRectTransform = BuildImageBoundsPath(source.Width, source.Height,
                                                                destX, destY, ox, oy, scaleX, scaleY, angleRadians, imgBoundsPath);
                // We invert it because it is the transform to make the image go to the same position as the polygon. LBB [2/24/2004]
                Affine sourceRectTransform = destRectTransform.CreateInvert();
                var    imgSpanGen          = new ImgSpanGenRGBA_BilinearClip(
                    source,
                    Drawing.Color.Black,
                    new SpanInterpolatorLinear(sourceRectTransform));

                VectorToolBox.GetFreeVxs(out VertexStore v1);
                destRectTransform.TransformToVxs(imgBoundsPath, v1);
                Render(v1, imgSpanGen);
                VectorToolBox.ReleaseVxs(ref v1);
#if false // this is some debug you can enable to visualize the dest bounding box
                LineFloat(BoundingRect.left, BoundingRect.top, BoundingRect.right, BoundingRect.top, WHITE);
                LineFloat(BoundingRect.right, BoundingRect.top, BoundingRect.right, BoundingRect.bottom, WHITE);
                LineFloat(BoundingRect.right, BoundingRect.bottom, BoundingRect.left, BoundingRect.bottom, WHITE);
                LineFloat(BoundingRect.left, BoundingRect.bottom, BoundingRect.left, BoundingRect.top, WHITE);
#endif
            }
            else // TODO: this can be even faster if we do not use an intermediat buffer
            {
                Affine destRectTransform = BuildImageBoundsPath(source.Width, source.Height,
                                                                destX, destY, imgBoundsPath);
                // We invert it because it is the transform to make the image go to the same position as the polygon. LBB [2/24/2004]
                Affine     sourceRectTransform = destRectTransform.CreateInvert();
                var        interpolator        = new SpanInterpolatorLinear(sourceRectTransform);
                ImgSpanGen imgSpanGen          = null;
                switch (source.BitDepth)
                {
                case 32:
                    imgSpanGen = new ImgSpanGenRGBA_NN_StepXBy1(source, interpolator);
                    break;

                //case 24:
                //    imgSpanGen = new ImgSpanGenRGB_NNStepXby1(source, interpolator);
                //    break;
                case 8:
                    imgSpanGen = new ImgSpanGenGray_NNStepXby1(source, interpolator);
                    break;

                default:
                    throw new NotImplementedException();
                }


                VectorToolBox.GetFreeVxs(out VertexStore v1);

                destRectTransform.TransformToVxs(imgBoundsPath, v1);
                Render(v1, imgSpanGen);

                VectorToolBox.ReleaseVxs(ref v1);
                unchecked { destImageChanged++; };
            }
            VectorToolBox.ReleaseVxs(ref imgBoundsPath);
        }
Exemple #25
0
        public override void Draw(PixelFarm.Drawing.Painter p)
        {
            //specific for agg
            if (!(p is AggPainter))
            {
                return;
            }


            throw new NotSupportedException();

            AggPainter       p2      = (AggPainter)p;
            AggRenderSurface aggRdsf = p2.RenderSurface;

            if (aggRdsf.DestImage != null)
            {
                IImageReaderWriter backBuffer          = aggRdsf.DestImage;
                IPixelBlender      currentPixelBlender = aggRdsf.PixelBlender;
                int distBetween = backBuffer.BytesBetweenPixelsInclusive;
                //use different pixel blender
                var                redImageBuffer     = new SubImageRW(backBuffer, new PixelBlenderGray(distBetween), distBetween, CO.R, 8);
                var                greenImageBuffer   = new SubImageRW(backBuffer, new PixelBlenderGray(distBetween), distBetween, CO.G, 8);
                var                blueImageBuffer    = new SubImageRW(backBuffer, new PixelBlenderGray(distBetween), distBetween, CO.B, 8);
                ClipProxyImage     clippingProxy      = new ClipProxyImage(backBuffer);
                ClipProxyImage     clippingProxyRed   = new ClipProxyImage(redImageBuffer);
                ClipProxyImage     clippingProxyGreen = new ClipProxyImage(greenImageBuffer);
                ClipProxyImage     clippingProxyBlue  = new ClipProxyImage(blueImageBuffer);
                ScanlineRasterizer sclineRas          = aggRdsf.ScanlineRasterizer;
                ScanlinePacked8    scline             = aggRdsf.ScanlinePacked8;
                Drawing.Color      clearColor         = this.UseBlackBlackground ? Drawing.Color.FromArgb(0, 0, 0) : Drawing.Color.FromArgb(255, 255, 255);
                clippingProxy.Clear(clearColor);
                Drawing.Color fillColor = this.UseBlackBlackground ?
                                          new Drawing.Color((byte)(this.AlphaValue), 255, 255, 255) :
                                          new Drawing.Color((byte)(this.AlphaValue), 0, 0, 0);
                ScanlineRasToDestBitmapRenderer sclineRasToBmp = aggRdsf.ScanlineRasToDestBitmap;
                VertexSource.Ellipse            er             = new PixelFarm.Agg.VertexSource.Ellipse(Width / 2 - 0.87 * 50, Height / 2 - 0.5 * 50, 100, 100, 100);
                //
                VectorToolBox.GetFreeVxs(out var v1);
                sclineRas.AddPath(er.MakeVxs(v1));
                v1.Clear();
                sclineRasToBmp.RenderWithColor(clippingProxyRed, sclineRas, scline, fillColor);
                VertexSource.Ellipse eg = new PixelFarm.Agg.VertexSource.Ellipse(Width / 2 + 0.87 * 50, Height / 2 - 0.5 * 50, 100, 100, 100);
                sclineRas.AddPath(eg.MakeVertexSnap(v1));
                v1.Clear();

                sclineRasToBmp.RenderWithColor(clippingProxyGreen, sclineRas, scline, fillColor);
                VertexSource.Ellipse eb = new PixelFarm.Agg.VertexSource.Ellipse(Width / 2, Height / 2 + 50, 100, 100, 100);

                sclineRas.AddPath(eb.MakeVertexSnap(v1));
                v1.Clear();
                sclineRasToBmp.RenderWithColor(clippingProxyBlue, sclineRas, scline, fillColor);

                VectorToolBox.ReleaseVxs(ref v1);
            }
            //            else if (graphics2D.DestImageFloat != null)
            //            {
            //#if false
            //                IImageFloat backBuffer = graphics2D.DestImageFloat;

            //                int distBetween = backBuffer.GetFloatsBetweenPixelsInclusive();
            //                ImageBufferFloat redImageBuffer = new ImageBufferFloat();
            //                redImageBuffer.Attach(backBuffer, new blender_gray(distBetween), distBetween, 2, 8);
            //                ImageBufferFloat greenImageBuffer = new ImageBufferFloat();
            //                greenImageBuffer.Attach(backBuffer, new blender_gray(distBetween), distBetween, 1, 8);
            //                ImageBufferFloat blueImageBuffer = new ImageBufferFloat();
            //                blueImageBuffer.Attach(backBuffer, new blender_gray(distBetween), distBetween, 0, 8);

            //                ImageClippingProxy clippingProxy = new ImageClippingProxy(backBuffer);
            //                ImageClippingProxy clippingProxyRed = new ImageClippingProxy(redImageBuffer);
            //                ImageClippingProxy clippingProxyGreen = new ImageClippingProxy(greenImageBuffer);
            //                ImageClippingProxy clippingProxyBlue = new ImageClippingProxy(blueImageBuffer);

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

            //                RGBA_Bytes clearColor = useBlackBackgroundCheckbox.Checked ? new RGBA_Bytes(0, 0, 0) : new RGBA_Bytes(255, 255, 255);
            //                clippingProxy.clear(clearColor);
            //                alphaSlider.View.BackGroundColor = clearColor;

            //                RGBA_Bytes FillColor = useBlackBackgroundCheckbox.Checked ? new RGBA_Bytes(255, 255, 255, (int)(alphaSlider.Value)) : new RGBA_Bytes(0, 0, 0, (int)(alphaSlider.Value));

            //                VertexSource.Ellipse er = new AGG.VertexSource.Ellipse(Width / 2 - 0.87 * 50, Height / 2 - 0.5 * 50, 100, 100, 100);
            //                ras.add_path(er);
            //                agg_renderer_scanline.Default.render_scanlines_aa_solid(clippingProxyRed, ras, sl, FillColor);

            //                VertexSource.Ellipse eg = new AGG.VertexSource.Ellipse(Width / 2 + 0.87 * 50, Height / 2 - 0.5 * 50, 100, 100, 100);
            //                ras.add_path(eg);
            //                agg_renderer_scanline.Default.render_scanlines_aa_solid(clippingProxyGreen, ras, sl, FillColor);

            //                VertexSource.Ellipse eb = new AGG.VertexSource.Ellipse(Width / 2, Height / 2 + 50, 100, 100, 100);
            //                ras.add_path(eb);
            //                agg_renderer_scanline.Default.render_scanlines_aa_solid(clippingProxyBlue, ras, sl, FillColor);
            //#endif
            //            }
        }
 void ReleaseVxs(ref VertexStore v)
 {
     VectorToolBox.ReleaseVxs(ref v);
 }