flxSharp.flxSharp.FlxSprite.replaceColor C# (CSharp) Méthode

replaceColor() public méthode

Undocumented in Flixel.
public replaceColor ( Color color, Color newColor, bool fetchPositions = false ) : List
color Color
newColor Color
fetchPositions bool
Résultat List
        public List<FlxPoint> replaceColor(Color color, Color newColor, bool fetchPositions = false)
        {
            List<FlxPoint> positions = (fetchPositions) ? new List<FlxPoint>() : null;

            var colorBuffer = new Color[_pixels.Width * _pixels.Height];
            _pixels.GetData<Color>(colorBuffer);

            for (int y = 0; y < _pixels.Height; ++y)
            {
                for (int x = 0; x < _pixels.Width; ++x)
                {
                    int index = (y * _pixels.Width) + x;
                    Color c = colorBuffer[index];

                    // flx# - maybe can be replaced with c.Equals(color)
                    if (c.A == color.A &&
                        c.R == color.R &&
                        c.G == color.G &&
                        c.B == color.B)
                    {
                        colorBuffer[index] = newColor;

                        if (fetchPositions)
                        {
                            positions.Add(new FlxPoint(x, y));
                        }

                        Dirty = true;
                    }
                }
            }

            _pixels.SetData<Color>(colorBuffer);

            return positions;
        }