Exemple #1
0
        private Rect AddSpritesToViewport(Document document)
        {
            var globalAabb         = Rect.Empty;
            var visibleSpriteNodes = GetVisibleSpriteNodesInDrawOrder(document);

            foreach (var spriteNode in visibleSpriteNodes)
            {
                SceneViewport.AddSpriteNode(spriteNode.Id, _spriteBitmapStore.Get(spriteNode.SpriteRef.RelativePath));
                SceneViewport.SetTransform(spriteNode.Id, spriteNode.GetAnimateTransformation().GlobalTransform.ToWpfMatrix());
                var aabb = SceneViewport.GetBoundingBox(spriteNode.Id);
                globalAabb = CombineAabb(aabb, globalAabb);
            }

            return(globalAabb);
        }
        /// <summary>
        /// Creates and saves a single png spritesheet from the sprites used in a <see cref="Document"/>
        /// </summary>
        public void ExportUsedSprites(IEnumerable <SpriteReference> spriteRefs, string filenamePng, string filenameJson)
        {
            var sprites = spriteRefs.Select(spriteRef => new SpriteInfo(spriteRef.RelativePath, _spriteBitmapStore.Get(spriteRef.RelativePath).Bitmap));

            SpritesheetExporter.Export(sprites, filenamePng, filenameJson);
        }