コード例 #1
0
 public PixelFarm.Drawing.RectangleF GetBounds()
 {
     if (_cacheBoundEval)
     {
         return(_cacheBounds);
     }
     if (_figures != null)
     {
         PixelFarm.Drawing.RectangleF bounds = new Drawing.RectangleF();
         if (_figures.FigureCount > 0)
         {
             bounds = _figures[0].GetBounds(); //start
             for (int i = 1; i < _figures.FigureCount; ++i)
             {
                 bounds = PixelFarm.Drawing.RectangleF.Union(bounds, _figures[i].GetBounds());
             }
         }
         _cacheBoundEval = true;
         return(_cacheBounds = bounds);
     }
     else
     {
         //single figure
         _cacheBoundEval = true;
         return(_cacheBounds = _figure.GetBounds());
     }
 }
コード例 #2
0
 //------------------------------------------------
 public static System.Drawing.RectangleF ToRectF(this PixelFarm.Drawing.RectangleF rect)
 {
     return(new System.Drawing.RectangleF(rect.X, rect.Y, rect.Width, rect.Height));
 }
コード例 #3
0
 public static SKRect ConvToRect(PixelFarm.Drawing.RectangleF r)
 {
     return(new SKRect(r.X, r.Y, r.Right, r.Bottom));
 }
コード例 #4
0
        internal unsafe static GlyphImage BuildMsdfFontImage()
        {
            IntPtr shape = MyFtLib.CreateShape();
            IntPtr cnt   = MyFtLib.ShapeAddBlankContour(shape);

            //MyFtLib.ContourAddLinearSegment(cnt, 10, 10, 25, 25);
            //MyFtLib.ContourAddLinearSegment(cnt, 25, 25, 15, 10);
            //MyFtLib.ContourAddLinearSegment(cnt, 15, 10, 10, 10);
            //

            MyFtLib.ContourAddLinearSegment(cnt, 10, 10, 25, 25);
            MyFtLib.ContourAddQuadraticSegment(cnt, 25, 25, 15, 30, 10, 15);
            MyFtLib.ContourAddLinearSegment(cnt, 10, 15, 10, 10);

            double s_left, s_bottom, s_right, s_top;

            MyFtLib.ShapeFindBounds(shape, out s_left, out s_bottom, out s_right, out s_top);
            var glyphBounds = new PixelFarm.Drawing.RectangleF((float)s_left, (float)s_top, (float)(s_right - s_left), (float)(s_top - s_bottom));

            //then create msdf texture
            if (!MyFtLib.ShapeValidate(shape))
            {
                throw new NotSupportedException();
            }
            MyFtLib.ShapeNormalize(shape);
            int borderXY = 0;
            int w        = (int)Math.Ceiling(glyphBounds.Width) + (borderXY + borderXY);
            int h        = (int)(Math.Ceiling(glyphBounds.Height)) + (borderXY + borderXY);

            if (w == 0)
            {
                w = 5;
                h = 5;
            }
            int[]      outputBuffer = new int[w * h];
            GlyphImage glyphImage   = new GlyphImage(w, h);

            glyphImage.BorderXY            = borderXY;
            glyphImage.OriginalGlyphBounds = Typography.Contours.RectangleF.FromLTRB(
                glyphBounds.Left,
                glyphBounds.Top,
                glyphBounds.Right,
                glyphBounds.Bottom);
            unsafe
            {
                fixed(int *output_header = &outputBuffer[0])
                {
                    float dx = 0;
                    float dy = 0;

                    if (s_left < 0)
                    {
                        //make it positive
                        dx = (float)-s_left;
                    }
                    else if (s_left > 0)
                    {
                    }
                    if (s_bottom < 0)
                    {
                        //make it positive
                        dy = (float)-s_bottom;
                    }
                    else if (s_bottom > 0)
                    {
                    }
                    //this glyph image has border (for msdf to render correctly)
                    MyFtLib.MyFtGenerateMsdf(shape, w, h, 4, 1, dx + borderXY, dy + borderXY, -1, 3, output_header);
                    MyFtLib.DeleteUnmanagedObj(shape);
                }

                glyphImage.SetImageBuffer(outputBuffer, true);
            }
            return(glyphImage);
        }
コード例 #5
0
 public static void Rect(ref PixelFarm.Drawing.RectangleF rect)
 {
     GL.Rect(rect.Left, rect.Top, rect.Right, rect.Bottom);
 }
コード例 #6
0
 //------------------------------------------------
 public static SkiaSharp.SKRect ToRectF(this PixelFarm.Drawing.RectangleF rect)
 {
     return(SkiaSharp.SKRect.Create(rect.X, rect.Y, rect.Width, rect.Height));
 }