示例#1
0
        void RunSampleD(PixelFarm.Drawing.Painter p)
        {
            //version 4:
            p.Clear(PixelFarm.Drawing.Color.White);
            p.UseLcdEffectSubPixelRendering = this.EnableSubPix;
            //--------------------------
            p.StrokeColor = PixelFarm.Drawing.Color.Black;
            p.StrokeWidth = 1.0f;
            //p.Line(2, 0, 10, 15);

            int lineLen = 10;
            int x       = 30;
            int y       = 30;

            for (int i = 0; i < 360; i += 15)
            {
                p.DrawLine(x, y, x + lineLen * Math.Cos(DegToRad(i)), y + lineLen * Math.Sin(DegToRad(i)));
                y += 5;
            }
            //y += 10;
            //for (int i = 0; i < 360; i += 360)
            //{
            //    p.Line(x, y, x + lineLen * Math.Cos(DegToRad(i)), y + lineLen * Math.Sin(DegToRad(i)));
            //}
        }
示例#2
0
        void RunSampleE(PixelFarm.Drawing.Painter p)
        {
            //version 4:
            p.Clear(PixelFarm.Drawing.Color.White);
            p.UseLcdEffectSubPixelRendering = this.EnableSubPix;
            //--------------------------
            p.StrokeColor = PixelFarm.Drawing.Color.Black;
            p.StrokeWidth = 2.0f;
            p.DrawLine(2, 0, 10, 15);

            int lineLen = 10;
            int x       = 30;
            int y       = 30;

            p.FillColor = PixelFarm.Drawing.Color.Black;
            p.FillRect(0, 0, 1, 1);

            for (int i = 0; i < 360; i += 30)
            {
                p.DrawLine(x, y, x + lineLen * Math.Cos(DegToRad(i)), y + lineLen * Math.Sin(DegToRad(i)));
            }
            y += 10;
            for (int i = 0; i < 360; i += 360)
            {
                p.DrawLine(x, y, x + lineLen * Math.Cos(DegToRad(i)), y + lineLen * Math.Sin(DegToRad(i)));
            }
        }
示例#3
0
        public override void Render(PixelFarm.Drawing.Painter p)
        {
            if (_currentTx == null)
            {
                _currentTx = Affine.NewMatix(
                    AffinePlan.Translate(-_spriteShape.Center.x, -_spriteShape.Center.y),
                    AffinePlan.Scale(_spriteScale, _spriteScale),
                    AffinePlan.Rotate(_angle + Math.PI),
                    AffinePlan.Skew(_skewX / 1000.0, _skewY / 1000.0),
                    AffinePlan.Translate(Width / 2, Height / 2)
                    );
            }

            if (JustMove)
            {
                float ox = p.OriginX;
                float oy = p.OriginY;

                p.SetOrigin(ox + _posX, oy + _posY);
                _spriteShape.Paint(p);
                p.SetOrigin(ox, oy);
            }
            else
            {
                _spriteShape.Paint(p, _currentTx);
            }
        }
示例#4
0
        public override void Draw(PixelFarm.Drawing.Painter p)
        {
            p.Clear(Drawing.Color.White);
            p.FillColor = Drawing.Color.Black;
            p.DrawRect(10, 10, 30, 30);

            foreach (var brushPath in this.myBrushPathList)
            {
                if (brushPath.Vxs != null)
                {
                    p.Fill(brushPath.Vxs);
                }
                else
                {
                    var contPoints = brushPath.contPoints;
                    int pcount     = contPoints.Count;
                    for (int i = 1; i < pcount; ++i)
                    {
                        var p0 = contPoints[i - 1];
                        var p1 = contPoints[i];
                        p.DrawLine(p0.x, p0.y, p1.x, p1.y);
                    }
                }
            }
        }
示例#5
0
 void RunSampleC(PixelFarm.Drawing.Painter p)
 {
     //version 3:
     p.Clear(PixelFarm.Drawing.Color.White);
     //---------------------------------------------
     p.StrokeColor = PixelFarm.Drawing.Color.Black;
     p.StrokeWidth = 1.0f;
     p.UseLcdEffectSubPixelRendering = this.EnableSubPix;
     p.DrawLine(0, 1, 15, 20);
 }
        static void DrawLineSet(PixelFarm.Drawing.Painter p, List <Point> contPoints)
        {
            int pcount = contPoints.Count;

            for (int i = 1; i < pcount; ++i)
            {
                var p0 = contPoints[i - 1];
                var p1 = contPoints[i];
                p.DrawLine(p0.x, p0.y, p1.x, p1.y);
            }
        }
示例#7
0
        public override void Draw(PixelFarm.Drawing.Painter p)
        {
            p.Clear(Drawing.Color.White);

            if (UseBitmapExt)
            {
                p.RenderQuality = Drawing.RenderQualtity.Fast;
            }
            else
            {
                p.RenderQuality = Drawing.RenderQualtity.HighQuality;
            }

            lionFill.Draw(p);
        }
示例#8
0
        void DrawBoneJoint(PixelFarm.Drawing.Painter painter, GlyphBoneJoint joint)
        {
            //--------------
            EdgeLine p_contactEdge = joint.dbugGetEdge_P();
            //mid point
            Vector2 jointPos = joint.OriginalJointPos * _pxscale;//scaled joint pos

            painter.FillRect(jointPos.X, jointPos.Y, 4, 4, PixelFarm.Drawing.Color.Yellow);
            if (joint.TipEdgeP != null)
            {
                EdgeLine tipEdge = joint.TipEdgeP;
                double   p_x, p_y, q_x, q_y;
                tipEdge.dbugGetScaledXY(out p_x, out p_y, out q_x, out q_y, _pxscale);
                //
                painter.Line(
                    jointPos.X, jointPos.Y,
                    p_x, p_y,
                    PixelFarm.Drawing.Color.White);
                painter.FillRect(p_x, p_y, 3, 3, PixelFarm.Drawing.Color.Green); //marker

                //
                painter.Line(
                    jointPos.X, jointPos.Y,
                    q_x, q_y,
                    PixelFarm.Drawing.Color.White);
                painter.FillRect(q_x, q_y, 3, 3, PixelFarm.Drawing.Color.Green); //marker
            }
            if (joint.TipEdgeQ != null)
            {
                EdgeLine tipEdge = joint.TipEdgeQ;
                double   p_x, p_y, q_x, q_y;
                tipEdge.dbugGetScaledXY(out p_x, out p_y, out q_x, out q_y, _pxscale);
                //
                painter.Line(
                    jointPos.X, jointPos.Y,
                    p_x, p_y,
                    PixelFarm.Drawing.Color.White);
                painter.FillRect(p_x, p_y, 3, 3, PixelFarm.Drawing.Color.Green); //marker

                //
                painter.Line(
                    jointPos.X, jointPos.Y,
                    q_x, q_y,
                    PixelFarm.Drawing.Color.White);
                painter.FillRect(q_x, q_y, 3, 3, PixelFarm.Drawing.Color.Green); //marker
            }
        }
示例#9
0
        public override void Draw(PixelFarm.Drawing.Painter p)
        {
            p.Clear(Drawing.Color.White);
            var plistCount = pointSets.Count;

            for (int n = 0; n < plistCount; ++n)
            {
                var contPoints = pointSets[n];
                int pcount     = contPoints.Count;
                for (int i = 1; i < pcount; ++i)
                {
                    var p0 = contPoints[i - 1];
                    var p1 = contPoints[i];
                    p.DrawLine(p0.x, p0.y, p1.x, p1.y);
                }
            }
        }
示例#10
0
        public override void Draw(PixelFarm.Drawing.Painter p)
        {
            p.CoordTransformer = _currentTx;
            p.Clear(Drawing.Color.White);
            if (UseBitmapExt)
            {
                p.RenderQuality = Drawing.RenderQuality.Fast;
            }
            else
            {
                p.RenderQuality = Drawing.RenderQuality.HighQuality;
            }

            _testSprite.Render(p);

            p.CoordTransformer = _iden;
        }
示例#11
0
        public override void Draw(PixelFarm.Drawing.Painter p)
        {
            p.Clear(Drawing.Color.White);

            if (UseBitmapExt)
            {
                p.RenderQuality = Drawing.RenderQuality.Fast;
            }
            else
            {
                p.RenderQuality = Drawing.RenderQuality.HighQuality;
            }

            foreach (MyTestSprite s in _spriteList)
            {
                s.Render(p);
            }
        }
示例#12
0
        public override void Draw(PixelFarm.Drawing.Painter p)
        {
            p.Clear(Drawing.Color.White);

            if (UseBitmapExt)
            {
                p.RenderQuality = Drawing.RenderQualtity.Fast;
            }
            else
            {
                p.RenderQuality = Drawing.RenderQualtity.HighQuality;
            }

            foreach (var lion in lionList)
            {
                lion.Draw(p);
            }
        }
        public override void Draw(PixelFarm.Drawing.Painter p)
        {
            p.Clear(Drawing.Color.White);
            //p.SmoothingMode = Drawing.SmoothingMode.AntiAlias;
            //// draw a circle
            p.FillColor = Drawing.Color.Blue;
            p.FillCircle(50, 50, 30);
            p.StrokeColor = Drawing.Color.FromArgb(20, 200, 200);
            p.DrawLine(10, 100, 520, 50);
            //// draw a filled box
            p.FillRect(60, 260, 200, 280, Drawing.Color.Yellow);

            // and an outline around it
            p.DrawRectangle(60, 260, 200, 280, Drawing.Color.Magenta);
            p.DrawString("A Simple Example", 20, 400);
            p.DrawString("A Simple Example2", 300, 350);
            p.DrawString("A Simple Example3", 300, 300);
            p.DrawString("A Simple Example4", 300, 250);
        }
示例#14
0
        void RunSampleA(PixelFarm.Drawing.Painter p)
        {
            //1. create simple vertical line to test agg's lcd rendernig technique
            //create gray-scale actual image
            using (MemBitmap glyphBmp = new MemBitmap(100, 100))
            {
                int x = 10, y = 10;
                using (Tools.BorrowAggPainter(glyphBmp, out var painter))
                {
                    painter.StrokeColor = PixelFarm.Drawing.Color.Black;
                    painter.StrokeWidth = 2.0f * 3;
                    painter.DrawLine(x * 3, 0, y * 3, 20); //scale horizontal 3 times, s
                }


                //painter.Line(x * 3, 0, y * 3, 20); //scale horizontal 3 times,
                //painter.Line(2, 0, 2, 15);
                //painter.Line(2, 0, 20, 20);
                //painter.Line(2, 0, 30, 15);
                //painter.Line(2, 0, 30, 5);
                //clear surface bg
                p.Clear(PixelFarm.Drawing.Color.White);
                //draw img into that bg
                //---------------
                //convert glyphImg from RGBA to grey Scale buffer
                //---------------
                //lcd process ...
                byte[] glyphGreyScale         = CreateGreyScaleBuffer(glyphBmp);
                //---------------

                //swap gray scale
                int    newGreyImgStride;
                byte[] expanedGreyScaleBuffer = CreateNewExpandedLcdGrayScale(glyphGreyScale, glyphBmp.Width, glyphBmp.Height, out newGreyImgStride);

                //blend lcd
                var aggPainer                 = (PixelFarm.CpuBlit.AggPainter)p;
                Blend(aggPainer.RenderSurface.DestBitmap, expanedGreyScaleBuffer, newGreyImgStride, glyphBmp.Height);
                //---------------
                p.DrawImage(glyphBmp, 0, 50);
            }
        }
示例#15
0
 public override void Draw(PixelFarm.Drawing.Painter p)
 {
     if (p is AggPainter)
     {
         var p2 = (AggPainter)p;
         p.FillColor = Drawing.Color.Red;
         p.FillRect(0, 70, 150, 120);
         //-------------------------------------------
         var innerGradient = new Gradients.GvcRadial();
         SpanInterpolatorLinear       linerInterpolator   = new SpanInterpolatorLinear(Affine.IdentityMatrix);
         LinearGradientColorsProvider linearColorProvider = new LinearGradientColorsProvider(Drawing.Color.Red, Drawing.Color.Yellow);
         SpanGenGradient spanGenGradient = new SpanGenGradient(linerInterpolator,
                                                               innerGradient,
                                                               linearColorProvider,
                                                               0, 150);
         SimpleRect srect = new SimpleRect(0, 0, 150, 50);
         var        v1    = GetFreeVxs();
         p2.Fill(srect.MakeVxs(v1), spanGenGradient);
         ReleaseVxs(ref v1);
     }
 }
示例#16
0
        void DrawPointKind(PixelFarm.Drawing.Painter painter, GlyphPoint point)
        {
            if (!DrawGlyphPoint)
            {
                return;
            }

            switch (point.PointKind)
            {
            case PointKind.C3Start:
            case PointKind.C3End:
            case PointKind.C4Start:
            case PointKind.C4End:
            case PointKind.LineStart:
            case PointKind.LineStop:

                painter.FillRect(point.OX * _pxscale, point.OY * _pxscale, 5, 5, PixelFarm.Drawing.Color.Red);

                break;
            }
        }
示例#17
0
        void SoftAggControl_Load(object sender, EventArgs e)
        {
            if (_useGdiPlusOutput)
            {
                // This example assumes the existence of a form called Form1.
                // Gets a reference to the current BufferedGraphicsContext
                //BufferedGraphicsContext currentContext = BufferedGraphicsManager.Current;
                //_myBuffGfx = currentContext.Allocate(this.CreateGraphics(),
                //   this.DisplayRectangle);

                // Creates a BufferedGraphics instance associated with Form1, and with
                // dimensions the same size as the drawing surface of Form1.
                thisGfx       = this.CreateGraphics(); //for render to output
                bufferBmpRect = this.DisplayRectangle;
                //bufferBmp = new Bitmap(bufferBmpRect.Width, bufferBmpRect.Height);


                sx = new PixelFarm.Drawing.WinGdi.GdiPlusRenderSurface(0, 0, bufferBmpRect.Width, bufferBmpRect.Height);
                var gdiPlusCanvasPainter = new PixelFarm.Drawing.WinGdi.GdiPlusPainter(sx);

                gdiPlusCanvasPainter.SmoothingMode = _gdiAntiAlias ? PixelFarm.Drawing.SmoothingMode.AntiAlias : PixelFarm.Drawing.SmoothingMode.HighSpeed;
                painter             = gdiPlusCanvasPainter;
                painter.CurrentFont = new PixelFarm.Drawing.RequestFont("tahoma", 14);
            }
            else
            {
                AggRenderSurface aggsx      = CreateAggRenderSurface(myWidth, myHeight, 32);
                AggPainter       aggPainter = new AggPainter(aggsx);
                //set text printer for agg canvas painter
                aggPainter.CurrentFont = new PixelFarm.Drawing.RequestFont("tahoma", 14);

                //TODO: review text printer here again***
                VxsTextPrinter textPrinter = new VxsTextPrinter(aggPainter, YourImplementation.BootStrapWinGdi.GetFontLoader());
                aggPainter.TextPrinter = textPrinter;
                painter = aggPainter;
            }
            painter.Clear(PixelFarm.Drawing.Color.White);
        }
示例#18
0
 void RunSampleB(PixelFarm.Drawing.Painter p)
 {
     //version 2:
     //1. create simple vertical line to test agg's lcd rendernig technique
     //create gray-scale actual image
     using (MemBitmap glyphBmp = new MemBitmap(100, 100))
     {
         AggPainter painter = AggPainter.Create(glyphBmp);
         //
         painter.StrokeColor = PixelFarm.Drawing.Color.Black;
         painter.StrokeWidth = 2.0f;
         painter.DrawLine(2, 0, 3, 15); //not need to scale3
                                        //
                                        //clear surface bg
         p.Clear(PixelFarm.Drawing.Color.White);
         //--------------------------
         var aggPainer = (PixelFarm.CpuBlit.AggPainter)p;
         BlendWithLcdTechnique(aggPainer.RenderSurface.DestBitmap, glyphBmp, PixelFarm.Drawing.Color.Black);
         //---------------
         p.DrawImage(glyphBmp, 0, 50);
         //---------------
     }
 }
示例#19
0
        public override void Draw(PixelFarm.Drawing.Painter p)
        {
            //specific for agg

            if (!(p is PixelFarm.CpuBlit.AggPainter))
            {
                return;
            }
            switch (Sample)
            {
            default: throw new NotSupportedException();

            case Sample.A:
                RunSampleA(p);
                break;

            case Sample.B:
                RunSampleB(p);
                break;

            case Sample.C:
                RunSampleC(p);
                break;

            case Sample.D:
                RunSampleD(p);
                break;

            case Sample.E:
                RunSampleE(p);
                break;

            case Sample.F:
                RunSampleF(p);
                break;
            }
        }
示例#20
0
        void RunSampleF(PixelFarm.Drawing.Painter p)
        {
            //version 4:
            p.Clear(PixelFarm.Drawing.Color.White);
            p.UseLcdEffectSubPixelRendering = this.EnableSubPix;
            //--------------------------
            p.StrokeColor = PixelFarm.Drawing.Color.Black;
            p.StrokeWidth = 2.0f;
            //p.DrawLine(2, 0, 10, 15);

            int lineLen = 10;
            int x       = 30;
            int y       = 30;

            p.FillColor = PixelFarm.Drawing.Color.Black;


            using (System.IO.FileStream fs = new System.IO.FileStream("c:\\Windows\\Fonts\\tahoma.ttf", System.IO.FileMode.Open, System.IO.FileAccess.Read))
            {
                Typography.OpenFont.OpenFontReader reader   = new Typography.OpenFont.OpenFontReader();
                Typography.OpenFont.Typeface       typeface = reader.Read(fs);


                var builder = new Typography.OpenFont.Contours.GlyphOutlineBuilder(typeface);
                builder.BuildFromGlyphIndex((ushort)typeface.GetGlyphIndex('C'), 24);

                var tovxs = new Typography.OpenFont.Contours.GlyphTranslatorToVxs();
                builder.ReadShapes(tovxs);

                using (Tools.BorrowVxs(out var vxs))
                {
                    tovxs.WriteOutput(vxs);
                    p.Fill(vxs);
                }
            }
            // p.FillRect(0, 0, 20, 20);
        }
        public override void Draw(PixelFarm.Drawing.Painter p)
        {
            p.Clear(Drawing.Color.White);
            var plistCount = pointSets.Count;

            p.StrokeColor = Drawing.Color.Black;
            for (int n = 0; n < plistCount; ++n)
            {
                var contPoints = pointSets[n];
                DrawLineSet(p, contPoints);
            }

            plistCount    = simplifiedPointSets.Count;
            p.StrokeColor = Drawing.Color.Red;
            for (int n = 0; n < plistCount; ++n)
            {
                var contPoints = simplifiedPointSets[n];
                DrawLineSet(p, contPoints);
            }

            //p.StrokeColor = ColorRGBA.Blue;
            //p.FillColor = ColorRGBA.Black;
            //int ccount = cubicCurves.Count;
            //for (int i = 0; i < ccount; ++i)
            //{
            //    var cc = cubicCurves[i];
            //    FillPoint(cc.p0, p);
            //    FillPoint(cc.p1, p);
            //    FillPoint(cc.p2, p);
            //    FillPoint(cc.p3, p);
            //    p.DrawBezierCurve(
            //       (float)cc.p0.x, (float)cc.p0.y,
            //       (float)cc.p3.x, (float)cc.p3.y,
            //       (float)cc.p1.x, (float)cc.p1.y,
            //       (float)cc.p2.x, (float)cc.p2.y);
            //}
        }
示例#22
0
        public override void Draw(PixelFarm.Drawing.Painter p)
        {
            int strokeWidth = 1;
            int width       = p.Width;
            int height      = p.Height;

            Affine affTx = Affine.NewMatix(
                AffinePlan.Translate(-lionShape.Center.x, -lionShape.Center.y),
                AffinePlan.Scale(spriteScale, spriteScale),
                AffinePlan.Rotate(angle + Math.PI),
                AffinePlan.Skew(skewX / 1000.0, skewY / 1000.0),
                AffinePlan.Translate(width / 2, height / 2));

            var p1 = p as AggPainter;

            if (p1 == null)
            {
                //TODO: review here

                lionShape.Paint(p, affTx);
                //int j = lionShape.NumPaths;
                //int[] pathList = lionShape.PathIndexList;
                //Drawing.Color[] colors = lionShape.Colors;
                ////graphics2D.UseSubPixelRendering = true;
                //var vxs = GetFreeVxs();
                //affTx.TransformToVxs(lionShape.Vxs, vxs);
                //p.StrokeWidth = 1;
                //for (int i = 0; i < j; ++i)
                //{
                //    p.StrokeColor = colors[i];
                //    p.Draw(new PixelFarm.Drawing.VertexStoreSnap(vxs, pathList[i]));

                //}
                ////not agg
                //Release(ref vxs);
                //return; //**
            }


            if (UseBitmapExt)
            {
                p.RenderQuality = Drawing.RenderQualtity.Fast;
                p.Clear(Drawing.Color.White);
                p.StrokeWidth = 1;

                //-------------------------
                lionShape.DrawOutline(p);
            }
            else
            {
                p.RenderQuality = Drawing.RenderQualtity.HighQuality;
            }



            //-----------------------
            AggRenderSurface aggsx = p1.RenderSurface;
            //var widgetsSubImage = ImageHelper.CreateChildImage(graphics2D.DestImage, graphics2D.GetClippingRect());
            //int width = widgetsSubImage.Width;
            //int height = widgetsSubImage.Height;

            SubImageRW     widgetsSubImage    = ImageHelper.CreateSubImgRW(aggsx.DestImage, aggsx.GetClippingRect());
            SubImageRW     clippedSubImage    = new SubImageRW(widgetsSubImage, new PixelBlenderBGRA());
            ClipProxyImage imageClippingProxy = new ClipProxyImage(clippedSubImage);

            imageClippingProxy.Clear(PixelFarm.Drawing.Color.White);


            if (RenderAsScanline)
            {
                ScanlineRasterizer rasterizer = aggsx.ScanlineRasterizer;
                rasterizer.SetClipBox(0, 0, width, height);
                //Stroke stroke = new Stroke(strokeWidth);
                //stroke.LineJoin = LineJoin.Round;
                lionShape.ApplyTransform(affTx);


                DrawAsScanline(imageClippingProxy, aggsx, rasterizer, aggsx.ScanlineRasToDestBitmap);



                lionShape.ResetTransform();
            }
            else
            {
                //LineProfileAnitAlias lineProfile = new LineProfileAnitAlias(strokeWidth * affTx.GetScale(), new GammaNone());
                LineProfileAnitAlias lineProfile     = new LineProfileAnitAlias(strokeWidth * affTx.GetScale(), null);
                OutlineRenderer      outlineRenderer = new OutlineRenderer(imageClippingProxy, new PixelBlenderBGRA(), lineProfile);
                OutlineAARasterizer  rasterizer      = new OutlineAARasterizer(outlineRenderer);
                rasterizer.LineJoin = (RenderAccurateJoins ?
                                       OutlineAARasterizer.OutlineJoin.AccurateJoin
                    : OutlineAARasterizer.OutlineJoin.Round);
                rasterizer.RoundCap = true;

                SvgRenderVx renderVx = lionShape.GetRenderVx();

                lionShape.ApplyTransform(affTx);

                DrawWithLineProfile(rasterizer);

                lionShape.ResetTransform();
            }
            base.Draw(p);
        }
示例#23
0
        void DrawPerpendicularEdgeControlPoints(PixelFarm.Drawing.Painter painter, OutsideEdgeLine internalEdgeLine)
        {
            //Vector2 regen0 = edge._newRegen0 * _pxscale;
            //Vector2 regen1 = edge._newRegen1 * _pxscale;
            //painter.FillRectLBWH(regen0.X, regen0.Y, 5, 5, PixelFarm.Drawing.Color.Green);
            //painter.FillRectLBWH(regen1.X, regen1.Y, 5, 5, PixelFarm.Drawing.Color.Blue);

            bool foundSomePerpendicularEdge = false;

            if (internalEdgeLine.ControlEdge_P != null && internalEdgeLine.ControlEdge_Q != null)
            {
                Vector2 m0 = internalEdgeLine.ControlEdge_P.GetMidPoint();
                Vector2 m1 = internalEdgeLine.ControlEdge_Q.GetMidPoint();

                //find angle from m0-> m1

                Vector2 v2 = (m0 + m1) / 2;
                //find perpendicular line  from  midpoint_m0m1 to edge
                Vector2 cutpoint;
                if (MyMath.FindPerpendicularCutPoint(internalEdgeLine, v2, out cutpoint))
                {
                    painter.Line(
                        v2.X * _pxscale, v2.Y * _pxscale,
                        cutpoint.X * _pxscale, cutpoint.Y * _pxscale,
                        PixelFarm.Drawing.Color.Red);
                    foundSomePerpendicularEdge = true;
                }

                //Vector2 e0_fitpos = internalEdgeLine.ControlEdge_P.GetFitPos() * _pxscale;
                //Vector2 e1_fitpos = internalEdgeLine.ControlEdge_Q.GetFitPos() * _pxscale;

                //painter.Line(
                //      e0_fitpos.X, e0_fitpos.Y,
                //      regen0.X, regen0.Y,
                //      PixelFarm.Drawing.Color.Yellow);
                //painter.Line(
                //    e1_fitpos.X, e1_fitpos.Y,
                //    regen1.X, regen1.Y,
                //    PixelFarm.Drawing.Color.Yellow);
            }

            if (internalEdgeLine.ControlEdge_P != null)
            {
                Vector2 v2 = internalEdgeLine.ControlEdge_P.GetMidPoint();
                //Vector2 cutpoint = internalEdgeLine._ctrlEdge_P_cutAt;
                //painter.Line(
                //    v2.X * _pxscale, v2.Y * _pxscale,
                //    cutpoint.X * _pxscale, cutpoint.Y * _pxscale,
                //    PixelFarm.Drawing.Color.Green);
                //foundSomePerpendicularEdge = true;
            }
            if (internalEdgeLine.ControlEdge_Q != null)
            {
                Vector2 v2 = internalEdgeLine.ControlEdge_Q.GetMidPoint();
                //Vector2 cutpoint = internalEdgeLine._ctrlEdge_Q_cutAt;
                //painter.Line(
                //    v2.X * _pxscale, v2.Y * _pxscale,
                //    cutpoint.X * _pxscale, cutpoint.Y * _pxscale,
                //    PixelFarm.Drawing.Color.Green);
                //foundSomePerpendicularEdge = true;
            }

            if (!foundSomePerpendicularEdge)
            {
                //TODO: reimplement this again
                //Vector2 midpoint = edge.GetMidPoint();
                //painter.FillRectLBWH(midpoint.X, midpoint.Y, 5, 5, PixelFarm.Drawing.Color.White);
            }
        }
示例#24
0
 public override void Draw(PixelFarm.Drawing.Painter p)
 {
     _lionOutlineSprite.Render(p);
 }
示例#25
0
        public override void Render(PixelFarm.Drawing.Painter p)
        {
            int strokeWidth = 1;
            int width       = p.Width;
            int height      = p.Height;

            Affine affTx = Affine.NewMatix(
                AffinePlan.Translate(-_spriteShape.Center.x, -_spriteShape.Center.y),
                AffinePlan.Scale(_spriteScale, _spriteScale),
                AffinePlan.Rotate(_angle + Math.PI),
                AffinePlan.Skew(_skewX / 1000.0, _skewY / 1000.0),
                AffinePlan.Translate(width / 2, height / 2));

            var p1 = p as AggPainter;

            if (p1 == null)
            {
                //TODO: review here
                _spriteShape.Paint(p, affTx);
                //int j = lionShape.NumPaths;
                //int[] pathList = lionShape.PathIndexList;
                //Drawing.Color[] colors = lionShape.Colors;
                ////graphics2D.UseSubPixelRendering = true;
                //var vxs = GetFreeVxs();
                //affTx.TransformToVxs(lionShape.Vxs, vxs);
                //p.StrokeWidth = 1;
                //for (int i = 0; i < j; ++i)
                //{
                //    p.StrokeColor = colors[i];
                //    p.Draw(new PixelFarm.Drawing.VertexStoreSnap(vxs, pathList[i]));

                //}
                ////not agg
                //Release(ref vxs);
                //return; //**
            }


            if (UseBitmapExt)
            {
                p.RenderQuality = Drawing.RenderQuality.Fast;
                p.Clear(Drawing.Color.White);
                p.StrokeWidth = 1;

                //-------------------------
                _spriteShape.DrawOutline(p);
            }
            else
            {
                p.RenderQuality = Drawing.RenderQuality.HighQuality;
            }


            //-----------------------
            AggRenderSurface aggsx = p1.RenderSurface;
            //-----------------------
            //TODO: make this reusable ...
            //
            SubBitmapBlender widgetsSubImage    = BitmapBlenderExtension.CreateSubBitmapBlender(aggsx.DestBitmapBlender, aggsx.GetClippingRect());
            SubBitmapBlender clippedSubImage    = new SubBitmapBlender(widgetsSubImage, new PixelBlenderBGRA());
            ClipProxyImage   imageClippingProxy = new ClipProxyImage(clippedSubImage);

            imageClippingProxy.Clear(PixelFarm.Drawing.Color.White);

            AggPainter aggPainter = (AggPainter)p;

            if (RenderAsScanline)
            {
                //a low-level example, expose scanline rasterizer

                ScanlineRasterizer rasterizer = aggsx.ScanlineRasterizer;
                rasterizer.SetClipBox(0, 0, width, height);

                //lionShape.ApplyTransform(affTx);
                //---------------------

                using (VgPaintArgsPool.Borrow(aggPainter, out VgPaintArgs paintArgs))
                {
                    paintArgs._currentTx        = affTx;
                    paintArgs.PaintVisitHandler = (vxs, painterA) =>
                    {
                        //use external painter handler
                        //draw only outline with its fill-color.
                        rasterizer.Reset();
                        rasterizer.AddPath(vxs);
                        aggsx.BitmapRasterizer.RenderWithColor(
                            imageClippingProxy, rasterizer,
                            aggsx.ScanlinePacked8,
                            aggPainter.FillColor); //draw line with external drawing handler
                    };

                    _spriteShape.Paint(paintArgs);
                }

                //----------------------------
                //lionShape.ResetTransform();
            }
            else
            {
                if (UseBuiltInAggOutlineAATech)
                {
                    aggPainter.StrokeWidth       = 1;
                    aggPainter.LineRenderingTech = AggPainter.LineRenderingTechnique.OutlineAARenderer;

                    //------
                    using (VgPaintArgsPool.Borrow(aggPainter, out VgPaintArgs paintArgs))
                    {
                        paintArgs._currentTx        = affTx;
                        paintArgs.PaintVisitHandler = (vxs, painterA) =>
                        {
                            //use external painter handler
                            //draw only outline with its fill-color.
                            Drawing.Painter m_painter       = paintArgs.P;
                            Drawing.Color   prevStrokeColor = m_painter.StrokeColor;
                            m_painter.StrokeColor = m_painter.FillColor;
                            m_painter.Draw(vxs);
                            m_painter.StrokeColor = prevStrokeColor;
                        };
                        _spriteShape.Paint(paintArgs);
                    }
                }
                else
                {
                    //low-level implementation
                    aggPainter.StrokeWidth = 1;

                    //-------------------------
                    //Draw with LineProfile:
                    //LineProfileAnitAlias lineProfile = new LineProfileAnitAlias(strokeWidth * affTx.GetScale(), new GammaNone()); //with gamma

                    LineProfileAnitAlias lineProfile     = new LineProfileAnitAlias(strokeWidth * affTx.GetScale(), null);
                    OutlineRenderer      outlineRenderer = new OutlineRenderer(imageClippingProxy, new PixelBlenderBGRA(), lineProfile);
                    outlineRenderer.SetClipBox(0, 0, this.Width, this.Height);

                    OutlineAARasterizer rasterizer = new OutlineAARasterizer(outlineRenderer);
                    rasterizer.LineJoin = (RenderAccurateJoins ?
                                           OutlineAARasterizer.OutlineJoin.AccurateJoin
                        : OutlineAARasterizer.OutlineJoin.Round);
                    rasterizer.RoundCap = true;

                    //lionShape.ApplyTransform(affTx);
                    //----------------------------
                    using (VgPaintArgsPool.Borrow(aggPainter, out VgPaintArgs paintArgs))
                    {
                        paintArgs._currentTx        = affTx;
                        paintArgs.PaintVisitHandler = (vxs, painterA) =>
                        {
                            //use external painter handler
                            //draw only outline with its fill-color.
                            rasterizer.RenderVertexSnap(
                                vxs,
                                painterA.P.FillColor);
                        };

                        _spriteShape.Paint(paintArgs);
                    }

                    //----------------------------
                    //lionShape.ResetTransform();
                }
            }
        }
示例#26
0
 public virtual void OnDraw(PixelFarm.Drawing.Painter p)
 {
 }
示例#27
0
        public override void Draw(PixelFarm.Drawing.Painter p)
        {
            //1.
            // clear the image to white
            p.Clear(Drawing.Color.White);
            p.FillColor = Drawing.Color.FromArgb(80, Drawing.Color.Blue);
            //M414 -20q-163 0 -245 86t-82 236z
            //<path d="M414 20q-163 40 -245 126t-82 276z"/>
            //PathWriter path = new PathWriter();
            //path.MoveTo(414, 20);
            //path.Curve3Rel(-163, 40, -245, 126);
            //path.SmoothCurve3Rel(-82, 246);
            //path.CloseFigure();

            //M414 -20q-163 0 -245 86t-82 236z
            //PathWriter path = new PathWriter();
            //path.MoveTo(414, -20);
            //path.Curve3Rel(-163, 0, -245, 86);
            //path.SmoothCurve3Rel(-82, 236);
            //path.CloseFigure();

            //p.Fill(p.FlattenCurves(path.Vxs));

            //p.DrawBezierCurve(120, 500 - 160, 220, 500 - 40, 35, 500 - 200, 220, 500 - 260);
            //---------------------------------------------------

            //temp comment, get glyph outline
            //var fontGlyph = a_font1.GetGlyph('{');
            ////outline version
            //var flat_v = fontGlyph.flattenVxs;
            //p.Fill(flat_v);
            //bitmap version
            //p.DrawImage(fontGlyph.glyphImage32, 20, 30);
            //-----------------------------------------------------
            p.CurrentFont = _font1;
            p.FillColor   = Drawing.Color.Black;
            //string test_str = "fมีมี่ญูดุญคำค่าค่ำป่บ่";
            //string test_str = "abcde";
            string test_str = "I...A Quick Brown Fox Jumps Over The Lazy Dog...I";

            //string test_str = "A single pixel on a color LCD";
            //string test_str = "กิน กิ่น";


            //string test_str = "บ่ป่มีมี่อุอูญญูกินกิ่นก็โก้";
            p.UseSubPixelLcdEffect = true;
            p.DrawString(test_str, 5, 200);
            //p.DrawString("12345", 50, 200);
            p.UseSubPixelLcdEffect = false;
            p.DrawString(test_str, 5, 300);
            //---------------------------------------------------
            p.UseSubPixelLcdEffect = true;
            p.StrokeColor          = Drawing.Color.Black;
            p.DrawLine(0, 200, 800, 200);
            p.FillColor   = Drawing.Color.Black;
            p.CurrentFont = _font2;
            p.DrawString(test_str, 80, 100);
            //---------------------------------------------------
            p.UseSubPixelLcdEffect = false;
            p.DrawString(test_str, 80, 150);
            //---------------------------------------------------
            //p.Fill(fontGlyph.vxs);
#if DEBUG
            //p.Fill(fontGlyph.vxs);


            // dbugVxsDrawPoints.DrawVxsPoints(flat_v, g);
            //dbugVxsDrawPoints.DrawVxsPoints(fontGlyph.vxs, g);
#endif

            //p.Fill(p.FlattenCurves(fontGlyph.vxs));


            //StyledTypeFace typeFaceForLargeA = new StyledTypeFace(LiberationSansFont.Instance, 300, flatenCurves: false);
            //var m_pathVxs = typeFaceForLargeA.GetGlyphForCharacter('a');
            //Affine shape_mtx = Affine.NewMatix(AffinePlan.Translate(150, 50));
            //m_pathVxs = shape_mtx.TransformToVxs(m_pathVxs);

            ////p.FillColor = new ColorRGBA(ColorRGBA.Red, 100);
            ////p.Fill(m_pathVxs);
            //p.FillColor = new ColorRGBA(ColorRGBA.Green, 120);
            //p.Fill(p.FlattenCurves(m_pathVxs));
        }
示例#28
0
        void DrawEdge(PixelFarm.Drawing.Painter painter, EdgeLine edge)
        {
            if (edge.IsOutside)
            {
                //free side
                {
                    GlyphPoint p = edge.P;
                    GlyphPoint q = edge.Q;

                    DrawPointKind(painter, p);
                    DrawPointKind(painter, q);
                    _infoView.ShowEdge(edge);
                    switch (edge.SlopeKind)
                    {
                    default:
                        painter.StrokeColor = PixelFarm.Drawing.Color.Green;
                        break;

                    case LineSlopeKind.Vertical:
                        if (edge.IsLeftSide)
                        {
                            painter.StrokeColor = PixelFarm.Drawing.Color.Blue;
                        }
                        else
                        {
                            painter.StrokeColor = PixelFarm.Drawing.Color.LightGray;
                        }
                        break;

                    case LineSlopeKind.Horizontal:

                        if (edge.IsUpper)
                        {
                            painter.StrokeColor = PixelFarm.Drawing.Color.Red;
                        }
                        else
                        {
                            //lower edge
                            painter.StrokeColor = PixelFarm.Drawing.Color.Magenta;
                        }
                        break;
                    }
                }
                float scale = this._pxscale;
                //show info: => edge point
                if (this.DrawPerpendicularLine && _infoView.HasDebugMark)
                {
                    double prevWidth = painter.StrokeWidth;
                    painter.StrokeWidth = 3;
                    painter.Line(edge.PX * scale, edge.PY * scale, edge.QX * scale, edge.QY * scale, PixelFarm.Drawing.Color.Yellow);
                    painter.StrokeWidth = prevWidth;

                    //draw
                    GlyphPoint p = edge.P;
                    GlyphPoint q = edge.Q;

                    //
                    //AssocBoneCollection p_bones = glyphEdge._P.dbugGetAssocBones();
                    //if (p_bones != null)
                    //{
                    //    Vector2 v2 = new Vector2(q.x, q.y);
                    //    foreach (GlyphBone b in p_bones)
                    //    {
                    //        Vector2 v3 = b.GetMidPoint();
                    //        painter.Line(v2.X * scale, v2.Y * scale, v3.X * scale, v3.Y * scale, PixelFarm.Drawing.Color.Yellow);
                    //    }
                    //}

                    //AssocBoneCollection q_bones = glyphEdge._Q.dbugGetAssocBones();
                    //if (q_bones != null)
                    //{
                    //    Vector2 v2 = new Vector2(p.x, p.y);
                    //    foreach (GlyphBone b in q_bones)
                    //    {

                    //        //Vector2 v2 = new Vector2(q.x, q.y);
                    //        Vector2 v3 = b.GetMidPoint();
                    //        painter.Line(v2.X * scale, v2.Y * scale, v3.X * scale, v3.Y * scale, PixelFarm.Drawing.Color.Green);
                    //    }
                    //}

                    {
                        //TODO: reimplement this again
                        //Vector2 orginal_MidPoint = glyphEdge.GetMidPoint() * _pxscale;
                        //Vector2 newMidPoint = glyphEdge.GetNewMidPoint() * _pxscale;
                        //painter.FillRectLBWH(newMidPoint.X, newMidPoint.Y, 3, 3, PixelFarm.Drawing.Color.Red);
                        //painter.Line(newMidPoint.X, newMidPoint.Y, orginal_MidPoint.X, orginal_MidPoint.Y, PixelFarm.Drawing.Color.LightGray);


                        //painter.FillRectLBWH(glyphEdge.newEdgeCut_P_X * _pxscale, glyphEdge.newEdgeCut_P_Y * _pxscale, 6, 6, PixelFarm.Drawing.Color.Blue);
                        //painter.FillRectLBWH(glyphEdge.newEdgeCut_Q_X * _pxscale, glyphEdge.newEdgeCut_Q_Y * _pxscale, 6, 6, PixelFarm.Drawing.Color.Blue);
                    }
                }
                else
                {
                    painter.DrawLine(edge.PX * scale, edge.PY * scale, edge.QX * scale, edge.QY * scale);
                }

                {
                    GlyphPoint p = edge.P;
                    GlyphPoint q = edge.Q;
                    //---------
                    {
                        //TODO: reimplement this again
                        //Vector2 orginal_MidPoint = glyphEdge.GetMidPoint() * _pxscale;
                        //Vector2 newMidPoint = glyphEdge.GetNewMidPoint() * _pxscale;

                        //if (DrawEdgeMidPoint)
                        //{
                        //    painter.FillRectLBWH(newMidPoint.X, newMidPoint.Y, 3, 3, PixelFarm.Drawing.Color.Red);
                        //}
                        ////
                        //painter.Line(newMidPoint.X, newMidPoint.Y, orginal_MidPoint.X, orginal_MidPoint.Y, PixelFarm.Drawing.Color.LightGray);

                        //painter.FillRectLBWH(glyphEdge.newEdgeCut_P_X * _pxscale, glyphEdge.newEdgeCut_P_Y * _pxscale, 4, 4, PixelFarm.Drawing.Color.Blue);
                        //painter.FillRectLBWH(glyphEdge.newEdgeCut_Q_X * _pxscale, glyphEdge.newEdgeCut_Q_Y * _pxscale, 4, 4, PixelFarm.Drawing.Color.Blue);
                    }
                    //---------
                    if (this.DrawPerpendicularLine)
                    {
                        var asOutsideEdge = edge as OutsideEdgeLine;
                        if (asOutsideEdge != null)
                        {
                            DrawPerpendicularEdgeControlPoints(painter, asOutsideEdge);
                        }
                    }
                }
            }
            else
            {
                //draw inside edge
                painter.Line(
                    edge.PX * _pxscale, edge.PY * _pxscale,
                    edge.QX * _pxscale, edge.QY * _pxscale,
                    PixelFarm.Drawing.Color.Gray);
            }
        }
 static void FillPoint(Vector2 v, PixelFarm.Drawing.Painter p)
 {
     p.FillRect(
         v.x, v.y,
         v.x + 3, v.y + 3);
 }
示例#30
0
 public override void Draw(PixelFarm.Drawing.Painter p)
 {
     lionFill.Draw(p);
 }