Esempio n. 1
0
 public RectF(IRectangleF area)
 {
     X      = area.X;
     Y      = area.Y;
     Width  = area.Width;
     Height = area.Height;
 }
Esempio n. 2
0
 public TrapeziumData(IList <PointF> points, Angle angle, IRectangleF bounds)
 {
     Points      = points;
     Angle       = angle;
     Bounds      = bounds;
     Initialized = true;
 }
Esempio n. 3
0
        public Angle AssignCenter(IRectangleF rc, bool permanent = false)
        {
            if (CenterAssigned)
            {
                return(this);
            }
            var a = new Angle(Degree, rc.X + rc.Width / 2f, rc.Y + rc.Height / 2f, Skew, permanent);

            return(a);
        }
Esempio n. 4
0
 public IRectangleF MeasureText(IDrawStyle style = null)
 {
     if (!Changed)
         return Bounds;
     ChangeDrawStyle(style);
     var info = font.MeasureGlyphs(originalGlyphs, DrawX, DrawY, DrawStyle);
     area = info.Bounds;
     originalGlyphs = info.Glyphs;
     RestoreDrawStyle();
     return area;
 }
Esempio n. 5
0
 public Shape(IShape shape)
 {
     Points = shape;
     Name   = shape.Name;
     Angle  = shape.Angle;
     Bounds = shape.Bounds;
     ID     = shape.ID;
     if (ID == null)
     {
         shape.AssignIDIfNone();
     }
 }
Esempio n. 6
0
 public Shape(IEnumerable <PointF> points, string shapeType, Angle angle, IRectangleF originalArea)
 {
     Points = points;
     Name   = shapeType;
     Angle  = angle;
     Bounds = originalArea ?? points.ToArea();
     ID     = (points is IElement) ? (points as IElement).ID : "Custom";
     if (ID == null)
     {
         ID = Implementation.Factory.NewID(Points);
     }
 }
Esempio n. 7
0
 GlyphsData(string text, IRectangleF area, IList <IGlyph> glyphs, float minHBY, Angle angle = default(Angle), bool containsNewLine = false)
 {
     Bounds          = area;
     Bounds          = area;
     Glyphs          = glyphs;
     MinHBY          = minHBY;
     Angle           = angle;
     ContainsNewLine = containsNewLine;
     if (text == null)
     {
         Text = new string(glyphs.Select(x => x.Character).ToArray());
     }
     else
     {
         Text = text;
     }
 }
Esempio n. 8
0
 public Angle(float angle, IRectangleF area, bool skew = false) :
     this(angle, area.Center(), skew)
 {
 }
Esempio n. 9
0
 public static IBoxF newBoxF(this IFactory factory, IRectangleF area) =>
 factory.newBoxF(area?.X ?? 0, area?.Y ?? 0, area?.Width ?? 0, area?.Height ?? 0);
Esempio n. 10
0
 public static IRhombus newRhombus(this IFactory factory, IRectangleF area, Angle angle = default(Angle), float?deviation = null) =>
 factory.newRhombus(area.X, area.Y, area.Width, area.Height, angle, deviation);
Esempio n. 11
0
 public static IRoundedBox newRoundedBox(this IFactory factory, IRectangleF rc, float cornerRadius, Angle angle = default(Angle)) =>
 factory.newRoundedBox(rc.X, rc.Y, rc.Width, rc.Height, cornerRadius, angle);
Esempio n. 12
0
 public Occupier(IRectangleF bounds, Angle angle)
 {
     Bounds = bounds;
     Angle  = angle;
 }
Esempio n. 13
0
 public static GlyphsData Create(string text, IRectangleF area, IList <IGlyph> glyphs, float minHBY, Angle angle = default(Angle), bool containsNewLine = false) =>
 new GlyphsData(text, area, glyphs, minHBY, angle, containsNewLine);
Esempio n. 14
0
 void Initialize(ICurve curve, IRectangleF area, bool assignID, PointF c = default(PointF) , ICurve attachedCurve = null)
 {
     Initialize(curve.StartAngle, curve.EndAngle,
         new EllipseData(area, curve.Data), curve.Type, assignID, c, attachedCurve);
 }
Esempio n. 15
0
 public EllipseData(IRectangleF rc, Angle angle) :
     this(rc.X, rc.Y, rc.Width, rc.Height, angle)
 {
 }
Esempio n. 16
0
 public EllipseData(IRectangleF rc, EllipseData original) :
     this(rc.X, rc.Y, rc.Width, rc.Height, original.Angle)
 {
 }
Esempio n. 17
0
        public static GlyphsData MeasureGlyphs(this IFont font, IList <IGlyph> Glyphs, float destX, float destY, IDrawStyle drawStyle = null)
        {
            if (font == null)
            {
                return(GlyphsData.Empty);
            }

            var DrawStyle = drawStyle ?? new DrawStyle();

            DrawStyle.LineHeight = font.Info.LineHeight.Ceiling();

            float lineHeight = DrawStyle.LineHeight;

            float newx, newy, right, bottom, minX, minY, kerning;

            for (int i = 0; i < Glyphs.Count; i++)
            {
                Glyphs[i].SetDrawXY(0, 0);
            }
            var minHBY = Glyphs.Min(g => g.Bounds.Y);

            if (minHBY < 0)
            {
                destY += -minHBY;
            }

            if (Glyphs[0].Bounds.X < 0)
            {
                destX += -Glyphs[0].Bounds.X;
            }

            newx = right = minX = destX;
            newy = bottom = minY = destY;

            bool start = true;

            kerning = 0;

            for (int i = 0; i < Glyphs.Count; i++)
            {
                IGlyph g = Glyphs[i];
                lineHeight = Math.Max(lineHeight, g.Bounds.Height);

                if (IsSpace(Glyphs, i))
                {
                    switch (DrawStyle.Breaker)
                    {
                    case TextBreaker.None:
                    case TextBreaker.Word:
                        if (DrawStyle.Delimiter == BreakDelimiter.Word)
                        {
                            goto case TextBreaker.SingleWord;
                        }
                        break;

                    case TextBreaker.Line:
                    default:
                        if (!start)
                        {
                            newx += g.Bounds.Width;
                        }
                        goto mks;

                    case TextBreaker.SingleWord:
                        newx  = destX;
                        newy += lineHeight;
                        start = true;
                        break;
                    }
                }
                else if (IsCR(Glyphs, i) || IsLF(Glyphs, i))
                {
                    if (IsPreviousCR(Glyphs, i))
                    {
                        goto last;
                    }
                    else
                    {
                        newx  = destX;
                        newy += lineHeight;
                        goto mks;
                    }
                }

                kerning = GetKerning(Glyphs, font, i);

mks:
                g.SetDrawXY((newx + kerning).Round(), newy.Round());

                minX = Math.Min(g.DrawX, minX);
                minY = Math.Min(g.DrawY, minY);

                newx   = g.DrawX + g.Bounds.Width;
                right  = Math.Max(newx, right);
                bottom = Math.Max(bottom, g.DrawY + g.Bounds.Height);
last:
                start = false;
            }

            IRectangleF Area = Factory.RectangleFFromLTRB(minX, minY, ++right, ++bottom);

            //IAreaF PenArea = Factory.AreaFFromLTRB(destX, destY, right, bottom);

            if (DrawStyle.Angle.Valid)
            {
                var glyphs = new IGlyph[Glyphs.Count];
                Glyphs.CopyTo(glyphs, 0);

                for (int i = 0; i < glyphs.Length; i++)
                {
                    glyphs[i].Rotate(DrawStyle.Angle.AssignCenter(Area.Center()));
                }
                Area = Factory.newRhombus(glyphs[0].Bounds, DrawStyle.Angle, Area.Width);
                return(GlyphsData.Create(null, Area, glyphs as IList <IGlyph>, minHBY, DrawStyle.Angle));
            }
            return(GlyphsData.Create(null, Area, Glyphs, minHBY));
        }