/// <summary> /// Generates an Animation with a given set of parameters. /// </summary> /// <param name="name">The name of the animation to generate</param> /// <param name="width">The width of the animation to generate</param> /// <param name="height">The height of the animation to generate</param> /// <param name="frameCount">The number of frames to add to the animation</param> /// <param name="seed">The seed for the animation's frames, used to seed the random number generator that will generate each of the frame's contents</param> /// <returns>An animation with the passed parameters</returns> public static Animation GenerateAnimation(string name, int width, int height, int frameCount, int seed = -1) { var anim = new Animation(name, width, height); for (int i = 0; i < frameCount; i++) { var frame = FrameGenerator.GenerateRandomFrame(width, height, seed == -1 ? seed : seed + i, 1); anim.AddFrame(frame); } return(anim); }
/// <summary> /// Generates a bundle with all features used, with a seed used to generate the randomicity. The bundles and their respective /// inner objects generated with the same seed will be guaranteed to be considered equal by the respective equality unit tests /// </summary> /// <param name="seed">An integer to utilize as a seed for the random number generator used to fill in the bundle</param> /// <returns>A Bundle filled with randomized objects</returns> public static Bundle GenerateTestBundle(int seed) { Random r = new Random(seed); Bundle bundle = new Bundle("Bundle" + r.Next()); for (int i = 0; i < 5; i++) { bundle.AddAnimationSheet(AnimationSheetGenerator.GenerateAnimationSheet("Sheet" + i, 5, r.Next(10, 128), r.Next(10, 128), r.Next(2, 5), r.Next())); // Create some dummy layers foreach (var animation in bundle.Animations) { foreach (var frame in animation.Frames) { var fr = frame as Frame; if (fr != null) { for (int j = 0; j < r.Next(1, 2); j++) { fr.AddLayer(FrameGenerator.GenerateRandomBitmap(fr.Width, fr.Height, seed + j)); } } } } // Add some repeated frames to a few animations if (i % 2 == 0) { bundle.AnimationSheets[i].Animations[0].CreateFrame(); bundle.AnimationSheets[i].Animations[0].CreateFrame(); bundle.AnimationSheets[i].Animations[0].CreateFrame(); bundle.AnimationSheets[i].Animations[1].CreateFrame().RandomizeBitmap(1); bundle.AnimationSheets[i].Animations[1].CreateFrame().RandomizeBitmap(1); bundle.AnimationSheets[i].Animations[1].CreateFrame().RandomizeBitmap(1); } } return(bundle); }