예제 #1
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)));
            }
        }
예제 #2
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)));
            //}
        }
예제 #3
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);
                    }
                }
            }
        }
예제 #4
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);
            }
        }
예제 #6
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);
                }
            }
        }
예제 #7
0
        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);
        }
예제 #8
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));
        }
예제 #9
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);
            }
        }