Exemplo n.º 1
0
    public void Trim()
    {
        if (Source.Trim == true && Source.PadStyle == SpPadStyle.Transparent)
        {
            var sourceRect  = new Rect(0.0f, 0.0f, Pixels.Width, Pixels.Height);
            var trimmedRect = default(Rect);
            var pivotX      = Pivot.x * sourceRect.width;
            var pivotY      = Pivot.y * sourceRect.height;

            Pixels = Pixels.GetTrimmed(ref trimmedRect, ref Border);

            pivotX = SpHelper.Divide(pivotX - trimmedRect.xMin, trimmedRect.width);
            pivotY = SpHelper.Divide(pivotY - trimmedRect.yMin, trimmedRect.height);

            Pivot = new Vector2(pivotX, pivotY);
        }

        W = Pixels.Width + Source.PadSize * 2;
        H = Pixels.Height + Source.PadSize * 2;
    }