Пример #1
0
        public Size GetMaxCharacterSize(BGICanvas.Direction dir, int size)
        {
            float width = 0;

            foreach (var ch in characters)
            {
                if (ch != null)
                {
                    width = Math.Max(width, ch.GetWidth(size));
                }
            }
            if (dir == BGICanvas.Direction.Horizontal)
            {
                return(new Size(BGICanvas.Round(width), (int)((Height + Math.Abs(OriginToDescender) + 1) * BGICharacter.scaleup[size] / BGICharacter.scaledown[size])));
            }
            else
            {
                return(new Size((int)((Height + Math.Abs(OriginToDescender) + 1) * BGICharacter.scaleup[size] / BGICharacter.scaledown[size]), BGICanvas.Round(width)));
            }
        }
Пример #2
0
        public Size GetRealTextSize(string str, BGICanvas.Direction dir, int size)
        {
            float width = 0;

            foreach (byte c in BGICanvas.Encoding.GetBytes(str))
            {
                BGICharacter ch = this[c];
                if (ch != null)
                {
                    width += ch.GetWidth(size);
                }
            }
            if (dir == BGICanvas.Direction.Horizontal)
            {
                return(new Size(BGICanvas.Round(width), (int)((Height + Math.Abs(OriginToDescender) + 1) * BGICharacter.scaleup[size] / BGICharacter.scaledown[size])));
            }
            else
            {
                return(new Size((int)((Height + Math.Abs(OriginToDescender) + 1) * BGICharacter.scaleup[size] / BGICharacter.scaledown[size]), BGICanvas.Round(width)));
            }
        }
Пример #3
0
        int GetAngle(Point start, Point end)
        {
            var offset = new Point(end - start);

            var angle = BGICanvas.Round(Math.Atan((double)offset.Y * radius.Width / radius.Height / offset.X) * (180.0 / Math.PI));

            if (offset.Y < 0 && offset.X < 0)
            {
                angle = 180 - angle;
            }
            else if (offset.Y > 0 && offset.X < 0)
            {
                angle = 180 - angle;
            }
            else if (offset.Y > 0 && offset.X > 0)
            {
                angle = 360 - angle;
            }
            else
            {
                angle = -angle;
            }
            return(angle);
        }