コード例 #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);
 }
コード例 #2
0
ファイル: Tools.cs プロジェクト: brezza92/PixelFarm
 public static void Circle(this AggRenderSurface g, double x, double y, double radius, Color color)
 {
     using (Tools.BorrowEllipse(out var ellipse))
         using (Tools.BorrowVxs(out var v1))
         {
             ellipse.Set(x, y, radius, radius);
             g.Render(ellipse.MakeVxs(v1), color);
         }
 }
コード例 #3
0
ファイル: Tools.cs プロジェクト: brezza92/PixelFarm
 public static void Rectangle(this AggRenderSurface gx, double left, double bottom, double right, double top, Color color, double strokeWidth = 1)
 {
     using (Tools.BorrowStroke(out var stroke))
         using (Tools.BorrowRect(out var rect))
             using (Tools.BorrowVxs(out var v1, out var v2))
             {
                 stroke.Width = strokeWidth;
                 rect.SetRect(left + .5, bottom + .5, right - .5, top - .5);
                 gx.Render(stroke.MakeVxs(rect.MakeVxs(v1), v2), color);
             }
 }
コード例 #4
0
 public AggPainter(AggRenderSurface aggsx)
 {
     //painter paint to target surface
     _orientation = RenderSurfaceOrientation.LeftBottom;
     //----------------------------------------------------
     _aggsx_0             = aggsx;         //set this as default ***
     TargetBufferName     = TargetBufferName.Default;
     _stroke              = new Stroke(1); //default
     _useDefaultBrush     = true;
     _defaultPixelBlender = this.DestBitmapBlender.OutputPixelBlender;
 }
コード例 #5
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);
        }
コード例 #6
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);
        }
コード例 #7
0
        public static void Circle(this AggRenderSurface g, double x, double y, double radius, Color color)
        {
            if (s_threadInit == null)
            {
                CheckInit();
            }
            //------------------------------------

            s_ellipse.Set(x, y, radius, radius);
            using (VxsTemp.Borrow(out var v1))
            {
                g.Render(s_ellipse.MakeVxs(v1), color);
            }
        }
コード例 #8
0
        public static AggPainter Create(ActualBitmap bmp, PixelProcessing.PixelBlender32 blender = null)
        {
            //helper func

            AggRenderSurface renderSx = new AggRenderSurface(bmp);

            if (blender == null)
            {
                blender = new PixelProcessing.PixelBlenderBGRA();
            }
            renderSx.PixelBlender = blender;

            return(new AggPainter(renderSx));
        }
コード例 #9
0
        public static void Rectangle(this AggRenderSurface gx, double left, double bottom, double right, double top, Color color, double strokeWidth = 1)
        {
            if (s_threadInit == null)
            {
                CheckInit();
            }
            //------------------------------------
            s_stroke.Width = strokeWidth;
            s_simpleRect.SetRect(left + .5, bottom + .5, right - .5, top - .5);

            using (VxsTemp.Borrow(out var v1, out var v2))
            {
                gx.Render(s_stroke.MakeVxs(s_simpleRect.MakeVxs(v1), v2), color);
            }
        }
コード例 #10
0
ファイル: Tools.cs プロジェクト: brezza92/PixelFarm
        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();
            }

            using (Tools.BorrowRect(out var rect))
                using (Tools.BorrowVxs(out var v1))
                {
                    rect.SetRect(left, bottom, right, top);
                    gx.Render(rect.MakeVxs(v1), fillColor);
                }
        }
コード例 #11
0
 public AggPainter(AggRenderSurface aggsx)
 {
     //painter paint to target surface
     this._aggsx         = aggsx;
     this.sclineRas      = _aggsx.ScanlineRasterizer;
     this.stroke         = new Stroke(1);//default
     this.scline         = aggsx.ScanlinePacked8;
     this._bmpRasterizer = aggsx.BitmapRasterizer;
     _orientation        = DrawBoardOrientation.LeftBottom;
     //from membuffer
     _bxt = new BitmapBuffer(aggsx.Width,
                             aggsx.Height,
                             PixelFarm.CpuBlit.ActualBitmap.GetBuffer(aggsx.DestActualImage));
     _vectorTool      = new VectorTool();
     _useDefaultBrush = true;
 }
コード例 #12
0
ファイル: AggPainter.cs プロジェクト: zwcloud/Typography
        public AggPainter(AggRenderSurface aggsx)
        {
            //painter paint to target surface
            _orientation = RenderSurfaceOrientation.LeftBottom;
            //----------------------------------------------------
            _aggsx = _aggsx_0 = aggsx; //set this as default ***

            _aggsx_0.DstBitmapAttached += (s, e) =>
            {
                UpdateTargetBuffer(_targetBufferName);
            };
            _aggsx_0.DstBitmapDetached += (s, e) =>
            {
                DetachMaskPixelBlender();
            };

            TargetBufferName     = TargetBufferName.Default;
            _stroke              = new Stroke(1);//default
            _useDefaultBrush     = true;
            _defaultPixelBlender = this.DestBitmapBlender.OutputPixelBlender;
        }
コード例 #13
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();
            }


            if (s_threadInit == null)
            {
                CheckInit();
            }
            //------------------------------------

            s_simpleRect.SetRect(left, bottom, right, top);
            using (VxsTemp.Borrow(out var v1))
            {
                gx.Render(s_simpleRect.MakeVxs(v1), fillColor);
            }
        }
コード例 #14
0
        public override void Draw(PixelFarm.Drawing.Painter p)
        {
            //specific for agg
            if (!(p is AggPainter))
            {
                return;
            }


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

            if (asx.DestBitmapBlender != null)
            {
                IBitmapBlender backBuffer = asx.DestBitmapBlender;

                //use different pixel blender
                var redImageBuffer   = new SubBitmapBlender(backBuffer, new PixelBlenderGrey());
                var greenImageBuffer = new SubBitmapBlender(backBuffer, new PixelBlenderGrey());
                var blueImageBuffer  = new SubBitmapBlender(backBuffer, new PixelBlenderGrey());

                ClipProxyImage clippingProxy      = new ClipProxyImage(backBuffer);
                ClipProxyImage clippingProxyRed   = new ClipProxyImage(redImageBuffer);
                ClipProxyImage clippingProxyGreen = new ClipProxyImage(greenImageBuffer);
                ClipProxyImage clippingProxyBlue  = new ClipProxyImage(blueImageBuffer);
                //
                ScanlineRasterizer sclineRas  = asx.ScanlineRasterizer;
                ScanlinePacked8    scline     = asx.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);


                DestBitmapRasterizer bmpRas = asx.BitmapRasterizer;

                using (VectorToolBox.Borrow(out Ellipse ellipse))
                    using (VxsTemp.Borrow(out var v1))
                    {
                        ellipse.Set(Width / 2 - 0.87 * 50, Height / 2 - 0.5 * 50, 100, 100, 100);
                        sclineRas.AddPath(ellipse.MakeVxs(v1));
                        v1.Clear();//**
                        bmpRas.RenderWithColor(clippingProxyRed, sclineRas, scline, fillColor);

                        ////

                        ellipse.Set(Width / 2 + 0.87 * 50, Height / 2 - 0.5 * 50, 100, 100, 100);
                        sclineRas.AddPath(ellipse.MakeVxs(v1));
                        v1.Clear();//***
                        bmpRas.RenderWithColor(clippingProxyGreen, sclineRas, scline, fillColor);

                        //

                        ellipse.Set(Width / 2, Height / 2 + 50, 100, 100, 100);
                        sclineRas.AddPath(ellipse.MakeVxs(v1));
                        v1.Clear(); //***
                        bmpRas.RenderWithColor(clippingProxyBlue, sclineRas, scline, fillColor);
                    }
            }
            //            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
            //            }
        }
コード例 #15
0
 public static void FillRectangle(this AggRenderSurface gx, RectInt rect, Color fillColor)
 {
     gx.FillRectangle(rect.Left, rect.Bottom, rect.Right, rect.Top, fillColor);
 }
コード例 #16
0
 public static void Rectangle(this AggRenderSurface gx, RectInt rect, Color color)
 {
     gx.Rectangle(rect.Left, rect.Bottom, rect.Right, rect.Top, color);
 }
コード例 #17
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);
 }
コード例 #18
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);
 }
コード例 #19
0
 public static void Circle(this AggRenderSurface g, Vector2 origin, double radius, Color color)
 {
     Circle(g, origin.x, origin.y, radius, color);
 }