示例#1
0
 private SpriteAlphaTween(float mt, SmartSprite spr, float end, Action done = null, PennerDoubleAnimation.EquationType e = PennerDoubleAnimation.EquationType.Linear)
 {
     maxTime    = mt;
     _spr       = spr;
     valueStart = spr.Alpha;
     valueEnd   = end;
     OnDone     = done;
     ease       = e;
 }
示例#2
0
 private ShapeAlphaTween(float mt, Shape shp, float end, Action done = null, PennerDoubleAnimation.EquationType e = PennerDoubleAnimation.EquationType.Linear)
 {
     maxTime    = mt;
     _shp       = shp;
     valueStart = shp.FillColor.A;
     valueEnd   = end;
     OnDone     = done;
     ease       = e;
 }
示例#3
0
            public static SpriteAlphaTween createAlphaTween(SmartSprite spr, float end = 0, float time = 1, Action done = null, PennerDoubleAnimation.EquationType e = PennerDoubleAnimation.EquationType.Linear)
            {
                SpriteAlphaTween t = new SpriteAlphaTween(time, spr, end, done, e);

                TweenManager.Add(t);
                return(t);
            }
        public static void CreateLinearGlowInOut(out Texture targetTexture, uint sizeX, uint sizeY, Color col, float opacity = 0.2f, PennerDoubleAnimation.EquationType type = PennerDoubleAnimation.EquationType.Linear, ShakeDirection direction = ShakeDirection.UpDown)
        {
            Image targetImage = new Image(sizeX, sizeY);

            float centerPosition = 0.0f;

            if (direction == ShakeDirection.UpDown)
            {
                centerPosition = sizeY / 2.0f;
            }
            else if (direction == ShakeDirection.LeftRight)
            {
                centerPosition = sizeX / 2.0f;
            }

            for (uint i = 0; i != sizeX; i++)
            {
                for (uint j = 0; j != sizeY; j++)
                {
                    Color pixelCol = col;

                    float distanceToCenter = 0.0f;
                    if (direction == ShakeDirection.UpDown)
                    {
                        distanceToCenter = (float)Math.Abs(centerPosition - j);
                    }
                    else if (direction == ShakeDirection.LeftRight)
                    {
                        distanceToCenter = (float)Math.Abs(centerPosition - i);
                    }
                    float newAlpha = 255.0f * opacity * (1.0f - (float)PennerDoubleAnimation.GetValue(type, distanceToCenter, 0, 1, centerPosition));
                    if (newAlpha < 0.0f)
                    {
                        newAlpha = 0.0f;
                    }
                    //Console.WriteLine(newAlpha);
                    pixelCol.A = (byte)newAlpha;
                    targetImage.SetPixel(i, j, pixelCol);
                }
            }

            targetTexture = new Texture(targetImage);
        }
        public static void CreateRadialGlow(out Texture targetTexture, uint size, Color col, float opacity = 0.2f, PennerDoubleAnimation.EquationType type = PennerDoubleAnimation.EquationType.Linear)
        {
            Image targetImage = new Image(size, size);

            Vector2u centerPosition      = new Vector2u(size / 2, size / 2);
            float    distanceToCenterMax = (float)Math.Sqrt(centerPosition.X * centerPosition.X + centerPosition.Y * centerPosition.Y) / 1.5f;

            for (uint i = 0; i != size; i++)
            {
                for (uint j = 0; j != size; j++)
                {
                    Color pixelCol = col;

                    Vector2u distanceToCenter = new Vector2u(centerPosition.X - i, centerPosition.Y - j);
                    float    distance         = (float)Math.Sqrt(distanceToCenter.X * distanceToCenter.X + distanceToCenter.Y * distanceToCenter.Y);
                    float    newAlpha         = 255.0f * opacity * (1.0f - (float)PennerDoubleAnimation.GetValue(type, distance, 0, 1, distanceToCenterMax));
                    if (newAlpha < 0.0f)
                    {
                        newAlpha = 0.0f;
                    }
                    //Console.WriteLine(newAlpha);
                    pixelCol.A = (byte)newAlpha;
                    targetImage.SetPixel(i, j, pixelCol);
                }
            }

            targetTexture = new Texture(targetImage);
        }
        public static ShapeScaleTween createShapeTween(Shape shp, float end = 1, float time = 1, Action done = null, PennerDoubleAnimation.EquationType e = PennerDoubleAnimation.EquationType.Linear)
        {
            ShapeScaleTween t = new ShapeScaleTween(time, shp, end, done, e);

            TweenManager.Add(t);
            return(t);
        }