Пример #1
0
        /// <summary>
        /// Zoom to center of image
        /// </summary>
        /// <param name="image">Image to apply zoom effect</param>
        /// <param name="duration">lenght of zoom animation</param>
        /// <param name="zoomInX">zoom percent in x</param>
        /// <param name="zoomInY"> zoom percent in y </param>
        public void ZoomTo(ImageWithTexCoords image, float duration, float zoomInX, float zoomInY)
        {
            if (image == null)
            {
                throw new System.ArgumentNullException("Invalid image");
            }
            if (zoomInX < Mathf.Epsilon)
            {
                zoomInX = Mathf.Epsilon;
            }
            if (zoomInY < Mathf.Epsilon)
            {
                zoomInY = Mathf.Epsilon;
            }

            Rect startTextCoords = image.TextureCoordinate;

            Rect destTextCoords = new Rect();

            destTextCoords.width  = 1.0f / zoomInX;
            destTextCoords.height = 1.0f / zoomInY;

            destTextCoords.x = (1.0f - destTextCoords.width) * 0.5f;
            destTextCoords.y = (1.0f - destTextCoords.height) * 0.5f;

            Zoom(image, duration, startTextCoords, destTextCoords);
        }
Пример #2
0
        /// <summary>
        /// zoom from currect TextCoords to rect defined in pixels
        /// </summary>
        /// <param name="image">Image to apply zoom effect</param>
        /// <param name="duration">lenght of zoom animation</param>
        /// <param name="x"> pixel x (0 - image.Texture.width)</param>
        /// <param name="y"> pixel y (0 - image.Texture.height) </param>
        /// <param name="width">with of destination in pixel</param>
        /// <param name="height">height of destination in pixel</param>
        /// <param name="inverseY">Inverse y</param>
        public void ZoomTo(ImageWithTexCoords image, float duration, int x, int y, int width, int height, bool inverseY = false)
        {
            if (image == null)
            {
                throw new System.ArgumentNullException("Invalid image");
            }
            if (image.Texture == null)
            {
                throw new System.ArgumentNullException("Invalid image.Texture");
            }
            Rect startTextCoords = image.TextureCoordinate;

            Rect destTextCoords = new Rect();

            destTextCoords.width  = ((float)width / (float)image.Texture.width);
            destTextCoords.height = ((float)height / (float)image.Texture.height);
            destTextCoords.x      = ((float)x / (float)image.Texture.width);
            destTextCoords.y      = ((float)y / (float)image.Texture.height);

            if (inverseY)
            {
                destTextCoords.y = 1.0f - destTextCoords.y;
            }

            Zoom(image, duration, startTextCoords, destTextCoords);
        }
Пример #3
0
        /// <summary>
        /// Zoom from currect TextCoords to destTextCoords
        /// </summary>
        /// <param name="image">Image to apply zoom effect</param>
        /// <param name="duration">lenght of zoom animation</param>
        /// <param name="destTextCoords">destination TextCoords</param>
        public void ZoomTo(ImageWithTexCoords image, float duration, Rect destTextCoords)
        {
            if (image == null)
            {
                throw new System.ArgumentNullException("Invalid image");
            }
            Rect startTextCoords = image.TextureCoordinate;

            Zoom(image, duration, startTextCoords, destTextCoords);
        }
Пример #4
0
        /// <summary>
        /// Zoom from startTextCoords to destTextCoords
        /// </summary>
        /// <param name="image">Image to apply zoom effect</param>
        /// <param name="duration">lenght of zoom animation</param>
        /// <param name="startTextCoords">start TextCoords</param>
        /// <param name="destTextCoords">destination TextCoords</param>
        public void Zoom(ImageWithTexCoords image, float duration, Rect startTextCoords, Rect destTextCoords)
        {
            if (image == null)
            {
                throw new System.ArgumentNullException("Invalid image");
            }
            ZoomData zd = new ZoomData();

            zd.Image      = image;
            zd.SourceRect = startTextCoords;
            zd.DestRect   = destTextCoords;
            zd.Timer.Begin(Mathf.Max(0, duration));
            _Zooms.Add(zd);
        }
Пример #5
0
        /// <summary>
        /// Shake image for specific time
        /// </summary>
        /// <param name="image">Image to apply shake </param>
        /// <param name="duration">lenght of shake animation</param>
        /// <param name="shakeAmount">amount of shake in x,y (0.0f - 1.0f)</param>
        /// <param name="saveTexCoords">Whether to return to initial TexCoords after shake </param>
        /// <param name="fadeout">Fade out shake at specified time left of shake</param>
        public void Shake(ImageWithTexCoords image, float duration, Vector2 shakeAmount, bool saveTexCoords = false, float fadeout = 0)
        {
            if (image == null)
            {
                throw new System.ArgumentNullException("Invalid image");
            }
            ShakeData sd = new ShakeData();

            sd.Image  = image;
            sd.Amount = shakeAmount;
            sd.Timer.Begin(Mathf.Max(0, duration));
            sd.InitialTexCoords = image.TextureCoordinate;
            sd.SaveTexCoords    = saveTexCoords;
            sd.Fadeout          = fadeout;
            _Shakes.Add(sd);
        }
Пример #6
0
        /// <summary>
        /// Create a RoundSidedProgressBar
        /// </summary>
        /// <param name="texture">Texture of ProgressBar</param>
        /// <param name="orientation"> left/right or top/down </param>
        /// <param name="roundSize">Size of round side in pixel</param>
        public RoundSidedProgressBar(Texture texture, Orientation orientation, float roundSize)
        {
            if (texture == null)
            {
                throw new ArgumentNullException("Invalid texture for RoundSidedImage");
            }
            if (roundSize < 0)
            {
                throw new ArgumentException("BorderInPixels can not be lower than i pixel");
            }

            this.Orientation = orientation;
            this._ImgLeft    = new ImageWithTexCoords();
            this._ImgCenter  = new ImageWithTexCoords();
            this._ImgRight   = new ImageWithTexCoords();

            this.Controls.Add(this._ImgLeft);
            this.Controls.Add(this._ImgCenter);
            this.Controls.Add(this._ImgRight);

            this._RoundSize = roundSize;
            this.Texture    = texture;
        }