Beispiel #1
0
        public static SliceKey Read(AsepriteStreamReader reader, int flag)
        {
            //   DWORD     Frame number(this slice is valid from
            //             this frame to the end of the animation)
            var frameNumber = reader.DWORD();
            //   LONG Slice X origin coordinate in the sprite
            var xOrigin = reader.LONG();
            //   LONG Slice Y origin coordinate in the sprite
            var yOrigin = reader.LONG();
            //   DWORD Slice width(can be 0 if this slice hidden in the
            //        animation from the given frame)
            var width = reader.DWORD();
            //   DWORD Slice height
            var height = reader.DWORD();

            long centerX = 0;
            long centerY = 0;
            long pivotX  = 0;
            long pivotY  = 0;

            uint centerWidth  = 0;
            uint centerHeight = 0;

            //     + If flags have bit 1
            if (reader.FLAG(flag, 1))
            {
                //         LONG Center X position(relative to slice bounds)
                centerX = reader.LONG();
                //         LONG Center Y position
                centerY = reader.LONG();
                //         DWORD Center width
                centerWidth = reader.DWORD();
                //         DWORD   Center height
                centerHeight = reader.DWORD();
            }
            //     + If flags have bit 2
            if (reader.FLAG(flag, 2))
            {
                //         LONG Pivot X position(relative to the slice origin)
                pivotX = reader.LONG();
                //         LONG Pivot Y position(relative to the slice origin)
                pivotY = reader.LONG();
            }

            return(new SliceKey(frameNumber, xOrigin, yOrigin, width, height, centerX, centerY, centerWidth, centerHeight, pivotX, pivotY));
        }