Esempio n. 1
0
        void RunSampleE(PixelFarm.Drawing.Painter p)
        {
            //version 4:
            p.Clear(PixelFarm.Drawing.Color.White);
            p.UseSubPixelLcdEffect = 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)));
            }
        }
Esempio n. 2
0
        void RunSampleF(PixelFarm.Drawing.Painter p)
        {
            //version 4:
            p.Clear(PixelFarm.Drawing.Color.White);
            p.UseSubPixelLcdEffect = 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;

            VertexStorePool pool = new VertexStorePool();

            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.Contours.GlyphPathBuilder(typeface);
                builder.BuildFromGlyphIndex((ushort)typeface.LookupIndex('C'), 16);
                PixelFarm.Drawing.Fonts.GlyphTranslatorToVxs tovxs = new Drawing.Fonts.GlyphTranslatorToVxs();
                builder.ReadShapes(tovxs);
                VertexStore vxs = new VertexStore();
                tovxs.WriteOutput(vxs);
                p.Fill(vxs);
            }
            p.FillRect(0, 0, 20, 20);
        }
Esempio n. 3
0
        void RunSampleD(PixelFarm.Drawing.Painter p)
        {
            //version 4:
            p.Clear(PixelFarm.Drawing.Color.White);
            p.UseSubPixelLcdEffect = 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)));
            //}
        }
Esempio n. 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.UseSubPixelLcdEffect = this.EnableSubPix;
     p.DrawLine(0, 1, 15, 20);
 }
Esempio n. 5
0
        public override void Draw(PixelFarm.Drawing.Painter p)
        {
            p.Clear(Drawing.Color.White);
            p.FillColor = Drawing.Color.Black;
            int j = myBrushPathList.Count;

            for (int n = 0; n < j; ++n)
            {
                var brushPath = myBrushPathList[n];
                if (brushPath.Vxs != null)
                {
                    switch (brushPath.BrushMode)
                    {
                    case SmoothBrushMode.CutBrush:
                    {
                    }
                    break;

                    default:
                    {
                        //TODO: review PixelCache here
                        p.FillColor = brushPath.FillColor;
                        p.Fill(brushPath.Vxs);

#if DEBUG
                        //if (brushPath.StrokeColor.alpha > 0)
                        //{
                        //    p.StrokeColor = Drawing.Color.Red;
                        //    p.Draw(brushPath.Vxs);
                        //}
#endif
                    }
                    break;
                    }
                }
                else
                {
                    //current drawing brush
                    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);
                    }
                }
            }
        }
Esempio n. 6
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);
            }
        }