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);
        }
Esempio n. 2
0
            public void DoAlphaTween()
            {
                if (!alive)
                {
                    return;
                }

                float val = PennerDoubleAnimation.GetValue(ease, age, valueStart, valueEnd, maxTime);

                _spr.Alpha = (byte)val;
            }
Esempio n. 3
0
            public void DoScaleTween()
            {
                if (!alive)
                {
                    return;
                }

                float val = PennerDoubleAnimation.GetValue(ease, age, valueStart, valueEnd, maxTime);

                _spr.Scale(val, val);
            }
Esempio n. 4
0
        private void DoParticleAlpha()
        {
            float time  = TotalLifeTime - RemainingLifeTime;
            float value = 1.0f - (float)PennerDoubleAnimation.GetValue(AlphaChangeType, time, 0, 1, TotalLifeTime);

            if (value * (float)InitialAlpha <= 2)
            {
                IsAlive = false;
            }
            SetAlpha((byte)(value * (float)InitialAlpha));
        }
        public static void CreateLinearAssymetricGlowInOut(out Texture targetTexture, uint sizeX, uint sizeY, Color col, float opacity = 0.2f, PennerDoubleAnimation.EquationType type1 = PennerDoubleAnimation.EquationType.Linear, PennerDoubleAnimation.EquationType type2 = 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)(centerPosition - j);
                    }
                    else if (direction == ShakeDirection.LeftRight)
                    {
                        distanceToCenter = (float)(centerPosition - i);
                    }
                    float newAlpha;
                    if (distanceToCenter > 0.0f)
                    {
                        newAlpha = 255.0f * opacity * (1.0f - (float)PennerDoubleAnimation.GetValue(type1, distanceToCenter, 0, 1, centerPosition));
                    }
                    else
                    {
                        newAlpha = 255.0f * opacity * (1.0f - (float)PennerDoubleAnimation.GetValue(type2, 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);
        }
Esempio n. 6
0
            public void DoAlphaTween()
            {
                if (!alive)
                {
                    return;
                }

                float val = PennerDoubleAnimation.GetValue(ease, age, valueStart, valueEnd, maxTime);
                //Console.WriteLine("do alpha tween" + val.ToString());
                Color newCol = new Color(_shp.FillColor);

                newCol.A       = (byte)(val);
                _shp.FillColor = newCol;
            }
        private void DoScaleTween()
        {
            float val = PennerDoubleAnimation.GetValue(ease, age, valueStart, valueEnd, maxTime);

            _shp.Scale = new SFML.Window.Vector2f(val, val);
        }