public override void DrawRect(double left, double top, double width, double height)
        {
            //BitmapExt
            if (this.RenderQuality == RenderQualtity.Fast)
            {
                if (this._orientation == DrawBoardOrientation.LeftBottom)
                {
                    this._bxt.DrawRectangle(
                        (int)Math.Round(left),
                        (int)Math.Round(top),
                        (int)Math.Round(left + width),
                        (int)Math.Round(top + height),

                        ColorInt.FromArgb(this.strokeColor.ToARGB()));
                }
                else
                {
                    //TODO: review here
                    throw new NotSupportedException();
                    //int canvasH = this.Height;
                    ////_simpleRectVxsGen.SetRect(left + 0.5, canvasH - (bottom + 0.5 + height), right - 0.5, canvasH - (top - 0.5 + height));
                    //this._bmpBuffer.DrawRectangle(
                    //(int)Math.Round(left),
                    //(int)Math.Round(top),
                    //(int)Math.Round(left + width),
                    //(int)Math.Round(top + height),
                    //ColorInt.FromArgb(this.strokeColor.ToARGB()));
                }
                return; //exit
            }

            //----------------------------------------------------------
            //Agg
            if (this._orientation == DrawBoardOrientation.LeftBottom)
            {
                double right  = left + width;
                double bottom = top + height;
                _simpleRectVxsGen.SetRect(left + 0.5, bottom + 0.5, right - 0.5, top - 0.5);
            }
            else
            {
                double right   = left + width;
                double bottom  = top - height;
                int    canvasH = this.Height;
                //_simpleRectVxsGen.SetRect(left + 0.5, canvasH - (bottom + 0.5), right - 0.5, canvasH - (top - 0.5));
                _simpleRectVxsGen.SetRect(left + 0.5, canvasH - (bottom + 0.5 + height), right - 0.5, canvasH - (top - 0.5 + height));
            }

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

            //
            _aggsx.Render(stroke.MakeVxs(_simpleRectVxsGen.MakeVxs(v1), v2), this.strokeColor);
            //
            ReleaseVxs(ref v1);
            ReleaseVxs(ref v2);
        }
Example #2
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);
        }
Example #3
0
        public override void Rectangle(double left, double bottom, double right, double top)
        {
            simpleRect.SetRect(left + .5, bottom + .5, right - .5, top - .5);
            var v1 = GetFreeVxs();
            var v2 = GetFreeVxs();

            //
            gx.Render(stroke.MakeVxs(simpleRect.MakeVxs(v1), v2), this.fillColor);
            //
            ReleaseVxs(ref v1);
            ReleaseVxs(ref v2);
        }
        //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 Graphics2D 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);
        }
Example #5
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);
            }
        }
Example #6
0
 /// <summary>
 /// draw rectangle
 /// </summary>
 /// <param name="left"></param>
 /// <param name="bottom"></param>
 /// <param name="right"></param>
 /// <param name="top"></param>
 /// <param name="color"></param>
 /// <param name="strokeWidth"></param>
 public void Rectangle(double left, double bottom, double right, double top, ColorRGBA color)
 {
     simpleRect.SetRect(left + .5, bottom + .5, right - .5, top - .5);
     gx.Render(stroke.MakeVxs(simpleRect.MakeVxs()), color);
 }
Example #7
0
        public override void Draw(Painter p)
        {
            if (UseBitmapExt)
            {
                p.RenderQuality = RenderQuality.Fast;
            }
            else
            {
                p.RenderQuality = RenderQuality.HighQuality;
            }



            p.Clear(Drawing.Color.Yellow);
            p.UseSubPixelLcdEffect = false;


            //
            //---red reference line--
            p.StrokeColor = Color.Black;
            p.DrawLine(0, 400, 800, 400); //draw reference line
            p.DrawImage(_lionImg, 300, 0);

            int _imgW = _lionImg.Width;
            int _imgH = _lionImg.Height;



            int x_pos = 0;

            for (int i = 0; i < 360; i += 30)
            {
                p.DrawImage(_lionImg,
                            //move to center of the image (hotspot x,y)
                            AffinePlan.Translate(-_imgW / 2f, -_imgH / 2f),
                            AffinePlan.Scale(0.50, 0.50),
                            AffinePlan.Rotate(AggMath.deg2rad(i)),
                            AffinePlan.Translate((_imgW / 2f) + x_pos, _imgH / 2f) //translate back
                            );

                x_pos += _imgW / 3;
            }


            using (VxsTemp.Borrow(out var vxs1, out var vxs2))
            {
                SimpleRect sRect = new SimpleRect();
                int        x = 0, y = 0, w = 100, h = 100;
                sRect.SetRect(x, y, x + w, y + h);
                sRect.MakeVxs(vxs1);
                p.Fill(vxs1, Color.Blue);
                //-------------------
                Affine af = Affine.NewMatix(
                    AffinePlan.Translate(-w / 2f, -h / 2f),
                    AffinePlan.Rotate(AggMath.deg2rad(30)),
                    AffinePlan.Translate(w / 2f, h / 2f)
                    );

                af.TransformToVxs(vxs1, vxs2);
                p.Fill(vxs2, Color.Red);
                //-------------------
            }
        }
Example #8
0
        public override void Draw(Painter p)
        {
            if (UseBitmapExt)
            {
                p.RenderQuality = RenderQuality.Fast;
            }
            else
            {
                p.RenderQuality = RenderQuality.HighQuality;
            }

            p.Clear(Drawing.Color.White);
            p.UseSubPixelLcdEffect = false;

            //---red reference line--
            p.StrokeColor = Color.Black;
            p.DrawLine(0, 400, 800, 400); //draw reference line
            p.DrawImage(_lionImg, 300, 0);
            //p.DrawImage(lionImg, 0, 0, 10, 10, 100, 100);

            //
            //p.DrawImage(halfLion, 50, 0);

            int _imgW = _lionImg.Width;
            int _imgH = _lionImg.Height;
            int x_pos = 0;
            int y_pos = 0;

            var affPlans = new AffinePlan[4];

            //1. create new half-size lion image

            //for (int i = 0; i < 360; i += 30)
            //{
            //    affPlans[0] = AffinePlan.Translate(-_imgW / 2f, -_imgH / 2f);
            //    affPlans[1] = AffinePlan.Scale(1, 1);
            //    affPlans[2] = AffinePlan.Rotate(AggMath.deg2rad(i));
            //    affPlans[3] = AffinePlan.Translate((_imgW / 2f) + x_pos, (_imgH / 2f) + y_pos);
            //    p.DrawImage(halfLion, affPlans);

            //    x_pos += _imgW / 3;
            //}


            x_pos = 0;
            y_pos = 100;
            for (int i = 0; i < 360; i += 30)
            {
                affPlans[0] = AffinePlan.Translate(-_imgW / 2f, -_imgH / 2f);
                affPlans[1] = AffinePlan.Scale(0.50, 0.50);
                affPlans[2] = AffinePlan.Rotate(AggMath.deg2rad(i));
                affPlans[3] = AffinePlan.Translate((_imgW / 2f) + x_pos, (_imgH / 2f) + y_pos);
                p.DrawImage(_lionImg, affPlans);
                x_pos += _imgW / 3;
            }



            //----
            //

            using (VxsTemp.Borrow(out var vxs1, out var vxs2))
            {
                SimpleRect sRect = new SimpleRect();
                int        x = 0, y = 0, w = 100, h = 100;
                sRect.SetRect(x, y, x + w, y + h);
                sRect.MakeVxs(vxs1);
                p.Fill(vxs1, Color.Blue);
                //-------------------
                Affine af = Affine.NewMatix(
                    AffinePlan.Translate(-w / 2f, -h / 2f),
                    AffinePlan.Rotate(AggMath.deg2rad(30)),
                    AffinePlan.Translate(w / 2f, h / 2f)
                    );

                af.TransformToVxs(vxs1, vxs2);
                p.Fill(vxs2, Color.Red);
            }
        }