コード例 #1
0
 public static void SetFrame(DMIState state, Image <Rgba32> image, DirectionDepth depth, StateDirection direction, int frame)
 {
     if (depth == DirectionDepth.One)
     {
         state.SetFrame(image, frame);
     }
     else
     {
         state.SetFrame(image, direction, frame);
     }
 }
コード例 #2
0
        public void CanCreateDMIFromImages()
        {
            using var newDMI = new DMIFile(32, 32);
            var sourceData = new List <string>()
            {
                "sord", "sordvert", "steve32"
            };

            foreach (var source in sourceData)
            {
                var img      = Image.Load <Rgba32>($@"Data/Input/SourceImages/{source}.png");
                var newState = new DMIState(source, DirectionDepth.One, 1, 32, 32);
                newState.SetFrame(img, 0);
                newDMI.AddState(newState);
            }

            newDMI.Save(@"Data/Output/minecraft.dmi");
        }
コード例 #3
0
        public void CanChangeDMIDepths()
        {
            using var newDMI = new DMIFile(32, 32);

            // Create state
            var img      = Image.Load <Rgba32>($@"Data/Input/SourceImages/steve32.png");
            var newState = new DMIState("steve32", DirectionDepth.One, 1, 32, 32);

            newState.SetFrame(img, 0);
            newDMI.AddState(newState);

            // Modifying state
            newDMI.States.First().SetDirectionDepth(DirectionDepth.Four);
            newDMI.States.First().SetFrameCount(10);

            // Check new states
            Assert.Equal(DirectionDepth.Four, newDMI.States.First().DirectionDepth);
            Assert.Equal(10, newDMI.States.First().Frames);

            // Cannot save
            Assert.False(newDMI.CanSave());
        }