Ejemplo n.º 1
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);
 }
Ejemplo n.º 2
0
        public static void Circle(this AggRenderSurface g, double x, double y, double radius, Color color)
        {
            ellipse.Set(x, y, radius, radius);
            var v1 = GetFreeVxs();

            g.Render(ellipse.MakeVxs(v1), color);
            RelaseVxs(ref v1);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);

            var v1 = GetFreeVxs();
            var v2 = GetFreeVxs();

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

            RelaseVxs(ref v1);
            RelaseVxs(ref v2);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        public AggPainter(AggRenderSurface aggsx)
        {
            this._aggsx         = aggsx;
            this.sclineRas      = _aggsx.ScanlineRasterizer;
            this.stroke         = new Stroke(1);//default
            this.scline         = aggsx.ScanlinePacked8;
            this.sclineRasToBmp = aggsx.ScanlineRasToDestBitmap;
            _orientation        = DrawBoardOrientation.LeftBottom;

            //from membuffer
            _bxt = new BitmapBuffer(aggsx.Width,
                                    aggsx.Height,
                                    PixelFarm.Agg.ActualImage.GetBuffer(aggsx.DestActualImage));
        }
Ejemplo n.º 7
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
            //            }
        }
Ejemplo n.º 8
0
 public static void FillRectangle(this AggRenderSurface gx, RectInt rect, Color fillColor)
 {
     gx.FillRectangle(rect.Left, rect.Bottom, rect.Right, rect.Top, fillColor);
 }
Ejemplo n.º 9
0
 public static void Rectangle(this AggRenderSurface gx, RectInt rect, Color color)
 {
     gx.Rectangle(rect.Left, rect.Bottom, rect.Right, rect.Top, color);
 }
Ejemplo n.º 10
0
 public static void Rectangle(this AggRenderSurface gx, RectD rect, Color color, double strokeWidth = 1)
 {
     gx.Rectangle(rect.Left, rect.Bottom, rect.Right, rect.Top, color, strokeWidth);
 }
Ejemplo n.º 11
0
 public static void Circle(this AggRenderSurface g, Vector2 origin, double radius, Color color)
 {
     Circle(g, origin.x, origin.y, radius, color);
 }
Ejemplo n.º 12
0
 public static void FillRectangle(this AggRenderSurface gx,
                                  Vector2 leftBottom,
                                  Vector2 rightTop, Color fillColor)
 {
     gx.FillRectangle(leftBottom.x, leftBottom.y, rightTop.x, rightTop.y, fillColor);
 }