Esempio n. 1
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. 2
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. 3
0
        public override void Draw(PixelFarm.Drawing.Painter p)
        {
            p.RenderQuality = RenderQuality.Fast;
            Brush prevBrush     = p.CurrentBrush;
            Brush selectedBrush = _linearGrBrush;

            p.Clear(Color.White);

            switch (SelectedBrushKind)
            {
            case BrushKind.LinearGradient:
                break;

            case BrushKind.CircularGradient:
                selectedBrush = _circularGrBrush;
                break;

            case BrushKind.PolygonGradient:
                selectedBrush = _polygonGradientBrush;
                break;
            }

            //
            p.CurrentBrush = selectedBrush;

            p.FillRect(0, 100, 500, 500);

            //p.FillRect(0, 200, 200, 50);

            //p.Fill(_triangleVxs);
            ////-------------

            p.CurrentBrush = prevBrush;
        }
Esempio n. 4
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
            }
        }
Esempio n. 5
0
        public static void DrawVxsPoints(VertexStore vxs, PixelFarm.Drawing.Painter p)
        {
            int j = vxs.Count;

            for (int i = 0; i < j; ++i)
            {
                double x, y;
                var    cmd = vxs.GetVertex(i, out x, out y);
                switch (cmd)
                {
                case VertexCmd.MoveTo:
                {
                    p.FillColor = PixelFarm.Drawing.Color.Blue;
                    p.FillRect(x, y, 5, 5);
                    p.DrawString(i.ToString(), x, y + 5);
                }
                break;

                case VertexCmd.C3:
                {
                    p.FillColor = PixelFarm.Drawing.Color.Red;
                    p.FillRect(x, y, 5, 5);
                    p.DrawString(i.ToString(), x, y + 5);
                }
                break;

                case VertexCmd.C4:
                {
                    p.FillColor = PixelFarm.Drawing.KnownColors.Gray;
                    p.FillRect(x, y, 5, 5);
                    p.DrawString(i.ToString(), x, y + 5);
                }
                break;

                case VertexCmd.LineTo:
                {
                    p.FillColor = PixelFarm.Drawing.Color.Yellow;
                    p.FillRect(x, y, 5, 5);
                    p.DrawString(i.ToString(), x, y + 5);
                }
                break;
                }
            }
        }
Esempio n. 6
0
        void DrawPoint(PixelFarm.Drawing.Painter p, Vector2 v)
        {
            Color prev = p.FillColor;

            p.FillColor = Color.Red;

            p.FillRect(v.X, v.Y, 4, 4);

            p.FillColor = prev;
        }
Esempio n. 7
0
        void RenderGrids(int width, int height, int sqSize, PixelFarm.Drawing.Painter p)
        {
            //render grid
            p.FillColor = PixelFarm.Drawing.Color.Gray;

            float pointW = (sqSize >= 100) ? 2 : 1;

            for (int y = 0; y < height;)
            {
                for (int x = 0; x < width;)
                {
                    p.FillRect(x, y, pointW, pointW);
                    x += sqSize;
                }
                y += sqSize;
            }
        }
Esempio n. 8
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;
            }
        }
Esempio n. 9
0
 public void DrawMarker(float x, float y, PixelFarm.Drawing.Color color, float sizeInPx = 8)
 {
     painter.FillRect(x, y, sizeInPx, sizeInPx, color);
 }