Terraria.Dust.GetColor C# (CSharp) Method

GetColor() public method

public GetColor ( Color newColor ) : Color
newColor Color
return Color
        public Color GetColor(Color newColor)
        {
            int r = (int)this.color.R - ((int)byte.MaxValue - (int)newColor.R);
            int g = (int)this.color.G - ((int)byte.MaxValue - (int)newColor.G);
            int b = (int)this.color.B - ((int)byte.MaxValue - (int)newColor.B);
            int a = (int)this.color.A - ((int)byte.MaxValue - (int)newColor.A);
            if (r < 0)
                r = 0;
            if (r > (int)byte.MaxValue)
                r = (int)byte.MaxValue;
            if (g < 0)
                g = 0;
            if (g > (int)byte.MaxValue)
                g = (int)byte.MaxValue;
            if (b < 0)
                b = 0;
            if (b > (int)byte.MaxValue)
                b = (int)byte.MaxValue;
            if (a < 0)
                a = 0;
            if (a > (int)byte.MaxValue)
                a = (int)byte.MaxValue;
            return new Color(r, g, b, a);
        }
    }

Usage Example

Esempio n. 1
0
 //in Terraria.Main.DrawDust before universal dust drawing call
 //  if(dust.modDust != null) { dust.modDust.Draw(dust, color5, scale); continue; }
 internal void Draw(Dust dust, Color alpha, float scale)
 {
     Main.spriteBatch.Draw(Texture, dust.position - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(dust.frame), alpha, dust.rotation, new Vector2(4f, 4f), scale, SpriteEffects.None, 0f);
     if (dust.color != default(Microsoft.Xna.Framework.Color))
     {
     Main.spriteBatch.Draw(Texture, dust.position - Main.screenPosition, new Microsoft.Xna.Framework.Rectangle?(dust.frame), dust.GetColor(alpha), dust.rotation, new Vector2(4f, 4f), scale, SpriteEffects.None, 0f);
     }
     if (alpha == Microsoft.Xna.Framework.Color.Black)
     {
     dust.active = false;
     }
 }