This project is read-only.
1
Vote

Issue with ClippedSpriteImage

description

The SourceRectangle property in ClippedSpriteImage throws an exception whenever (DoubleRectangle)value has a negative value. I think this should be checked before passing the value, converting any negative value to zero.

comments

WardoXna wrote Jan 6, 2011 at 10:27 PM

My solution:

public DoubleRectangle SourceRectangle
    {
        get
        {
            return sourceRectangle;
        }
        set
        {
            if (sourceRectangle.X != value.X ||
                sourceRectangle.Y != value.Y)
            {
                translate.X = -value.X;
                translate.Y = -value.Y;
            }
            if (sourceRectangle.Width != value.Width ||
                sourceRectangle.Height != value.Height)
            {
                if (value.Width > 0)
                {
                    rectangle.Width = value.Width;
                }
                else
                {
                    rectangle.Width = 0;
                }
                if (value.Height > 0)
                {
                    rectangle.Height = value.Height;
                }
                else
                {
                    rectangle.Height = 0;
                }
            }
            sourceRectangle = value;
        }
    }

wrote Feb 14, 2013 at 7:13 PM