|
1 |
| -// Copyright (c) Christopher Whitley. All rights reserved. |
2 |
| -// Licensed under the MIT license. |
| 1 | +// Copyright (c) Christopher Whitley. All rights reserved. |
| 2 | +// Licensed under the MIT license. |
3 | 3 | // See LICENSE file in the project root for full license information.
|
4 | 4 |
|
5 |
| -using AsepriteDotNet; |
6 |
| -using AsepriteDotNet.Aseprite; |
7 |
| -using AsepriteDotNet.IO; |
8 |
| -using AsepriteDotNet.Processors; |
9 |
| - |
10 |
| -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
11 |
| -/// |
12 |
| -/// Load the file using the AsepriteFileLoader. In this example, we are passing the path to the file. There is also |
13 |
| -/// an overload where you can pass a stream instead if you needed. |
14 |
| -/// |
15 |
| -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
16 |
| -AsepriteFile aseFile = AsepriteFileLoader.FromFile("adventurer.aseprite"); |
17 |
| - |
18 |
| -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
19 |
| -/// |
20 |
| -/// Create the process options to use with the processors. Here we use the default options, however you an customize |
21 |
| -/// them. See the README documentation for available properties and what each does for the processor options. |
22 |
| -/// |
23 |
| -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
24 |
| -ProcessorOptions options = ProcessorOptions.Default; |
25 |
| - |
26 |
| -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
27 |
| -/// |
28 |
| -/// The SpriteProcesor is used to process a Sprite from a single frame |
29 |
| -/// |
30 |
| -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
31 |
| -Sprite sprite = SpriteProcessor.Process(aseFile, 0, options); |
32 |
| - |
33 |
| -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
34 |
| -/// |
35 |
| -/// The TextureAtlas processor will process a TextureAtlas from the aseprite file. A TextureAtlas contains single |
36 |
| -/// image representation of all frames in the Aseprite file that have been box packed into the pixel data. Additional |
37 |
| -/// TextureRegion properties are provided that define the source rectangle for each frame within the base texture |
38 |
| -/// representation. |
39 |
| -/// |
40 |
| -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
41 |
| -TextureAtlas atals = TextureAtlasProcessor.Process(aseFile, options); |
42 |
| - |
43 |
| -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
44 |
| -/// |
45 |
| -/// The SpriteSheet processor will process a SpriteSheet from the aseprite file. A SpriteSheet uses a TextureAtlas as |
46 |
| -/// its source for the image and provides additional properties that define animations as defined by the tags in |
47 |
| -/// Aseprite. |
48 |
| -/// |
49 |
| -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
50 |
| -SpriteSheet spriteSheet = SpriteSheetProcessor.Process(aseFile, options); |
| 5 | +using AsepriteDotNet; |
| 6 | +using AsepriteDotNet.Aseprite; |
| 7 | +using AsepriteDotNet.IO; |
| 8 | +using AsepriteDotNet.Processors; |
| 9 | + |
| 10 | +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 11 | +/// |
| 12 | +/// Load the file using the AsepriteFileLoader. In this example, we are passing the path to the file. There is also |
| 13 | +/// an overload where you can pass a stream instead if you needed. |
| 14 | +/// |
| 15 | +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 16 | +AsepriteFile aseFile = AsepriteFileLoader.FromFile("adventurer.aseprite"); |
| 17 | + |
| 18 | + |
| 19 | +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 20 | +/// |
| 21 | +/// The SpriteProcessor is used to process a Sprite from a single frame |
| 22 | +/// |
| 23 | +/// The onlyVisibleLayers, includeBackgroundLayer, and includeTilemapLayers parameters are optional. Below shows their |
| 24 | +/// default values if not specified. |
| 25 | +/// |
| 26 | +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 27 | +Sprite sprite = SpriteProcessor.Process(aseFile, |
| 28 | + 0, |
| 29 | + onlyVisibleLayers: true, |
| 30 | + includeBackgroundLayer: false, |
| 31 | + includeTilemapLayers: false); |
| 32 | + |
| 33 | +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 34 | +/// |
| 35 | +/// The TextureAtlas processor will process a TextureAtlas from the aseprite file. A TextureAtlas contains single |
| 36 | +/// image representation of all frames in the Aseprite file that have been box packed into the pixel data. Additional |
| 37 | +/// TextureRegion properties are provided that define the source rectangle for each frame within the base texture |
| 38 | +/// representation. |
| 39 | +/// |
| 40 | +/// The onlyVisibleLayers, includeBackgroundLayer, includeTileMapLayers, mergeDuplicateFrames, borderPadding, spacing, |
| 41 | +/// and innerPadding parameters are optional. Below shows their default values when not specified. |
| 42 | +/// |
| 43 | +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 44 | +TextureAtlas atlas = TextureAtlasProcessor.Process(aseFile, |
| 45 | + onlyVisibleLayers: true, |
| 46 | + includeBackgroundLayer: false, |
| 47 | + includeTilemapLayers: false, |
| 48 | + mergeDuplicateFrames: true, |
| 49 | + borderPadding: 0, |
| 50 | + spacing: 0, |
| 51 | + innerPadding: 0); |
| 52 | + |
| 53 | +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 54 | +/// |
| 55 | +/// The SpriteSheet processor will process a SpriteSheet from the aseprite file. A SpriteSheet uses a TextureAtlas as |
| 56 | +/// its source for the image and provides additional properties that define animations as defined by the tags in |
| 57 | +/// Aseprite. |
| 58 | +/// |
| 59 | +/// The onlyVisibleLayers, includeBackgroundLayer, includeTileMapLayers, mergeDuplicateFrames, borderPadding, spacing, |
| 60 | +/// and innerPadding parameters are optional. Below shows their default values when not specified. |
| 61 | +/// |
| 62 | +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 63 | +SpriteSheet spriteSheet = SpriteSheetProcessor.Process(aseFile, |
| 64 | + onlyVisibleLayers: true, |
| 65 | + includeBackgroundLayer: false, |
| 66 | + includeTilemapLayers: false, |
| 67 | + mergeDuplicateFrames: true, |
| 68 | + borderPadding: 0, |
| 69 | + spacing: 0, |
| 70 | + innerPadding: 0); |
0 commit comments