Project290.Screens.Shared.HypercubeDisplay.HypercubeDisplay C# (CSharp) Method

HypercubeDisplay() public method

Initializes a new instance of the HypercubeDisplay class.
public HypercubeDisplay ( Rectangle displayRectangle, int hypercubeCount, Random random, float layerDepth ) : System
displayRectangle Microsoft.Xna.Framework.Rectangle The display rectangle.
hypercubeCount int The number of hypercubes.
random System.Random The PRNG.
layerDepth float The layer depth.
return System
        public HypercubeDisplay(Rectangle displayRectangle, int hypercubeCount, Random random, float layerDepth)
        {
            this.DisplayRectangle = displayRectangle;
            this.layerDepth = layerDepth;
            this.hypercubes = new List<Hypercube>();
            Rectangle bounceRectangle = new Rectangle(this.DisplayRectangle.X, this.DisplayRectangle.Y, this.DisplayRectangle.Width, this.DisplayRectangle.Height);
            bounceRectangle.Inflate(this.DisplayRectangle.Height, this.DisplayRectangle.Width);

            for (int i = 0; i < hypercubeCount; i++)
            {
                float greyscale = MathHelper.Lerp(0f, 1f, (i + 1f) / (hypercubeCount + 2f));
                this.hypercubes.Add(new Hypercube(
                    new Vector2(displayRectangle.Center.X, displayRectangle.Center.Y),
                    new Color(0, 0, greyscale, 1f),
                    this.DisplayRectangle,
                    bounceRectangle,
                    random,
                    this.layerDepth + 0.001f * (i + 1)));
            }
        }