Ejemplo n.º 1
0
    public override void Process()
    {
        Rect rect = Rect;

        rect = new Rect(
            rect.x,
            rect.y + rect.height,
            rect.width,
            rect.height
            );

        Vector2 pivot = Alignment.GetPivot();

        float totalHeight = CalcTotalHeight();

        foreach (BitmapLine line in Lines)
        {
            float lineWidth = CalcWidth(line);
            foreach (BitmapCharacter character in line)
            {
                Rect characterRect = character.Rect;

                // Horizontal
                characterRect.x += rect.x + (rect.width - lineWidth) * pivot.x;

                // Vertical
                characterRect.y += rect.y - (rect.height - totalHeight) * pivot.y;

                character.Rect = characterRect;
            }
        }
    }
Ejemplo n.º 2
0
    public static Rect Fit(this Rect _Rect, float _Aspect, Alignment _Alignment = Alignment.MiddleCenter)
    {
        float hFit = _Rect.width * (_Rect.width / _Aspect);
        float vFit = _Rect.height * (_Rect.height * _Aspect);

        Vector2 size = hFit < vFit
                        ? new Vector2(_Rect.width, _Rect.width / _Aspect)
                        : new Vector2(_Rect.height * _Aspect, _Rect.height);
        Vector2 pivot = _Alignment.GetPivot();

        return(new Rect(
                   _Rect.x + (_Rect.width - size.x) * pivot.x,
                   _Rect.y + (_Rect.height - size.y) * pivot.y,
                   size.x,
                   size.y
                   ));
    }