ase

所属分类:collect
开发工具:Haxe
文件大小:0KB
下载次数:0
上传日期:2023-07-13 23:00:38
上 传 者sh-1993
说明:  用Haxe编写的Aseprite文件格式读取器编写器,
(Aseprite file format reader writer written in Haxe,)

文件列表:
LICENSE.md (1081, 2023-05-12)
_config.yml (27, 2023-05-12)
build.hxml (70, 2023-05-12)
documentation/ (0, 2023-05-12)
documentation/404.html (3199, 2023-05-12)
documentation/ase/ (0, 2023-05-12)
documentation/ase/Ase.html (11976, 2023-05-12)
documentation/ase/AseHeader.html (11499, 2023-05-12)
documentation/ase/Cel.html (10480, 2023-05-12)
documentation/ase/Frame.html (11672, 2023-05-12)
documentation/ase/FrameHeader.html (7774, 2023-05-12)
documentation/ase/Layer.html (4754, 2023-05-12)
documentation/ase/Palette.html (7166, 2023-05-12)
documentation/ase/chunks/ (0, 2023-05-12)
documentation/ase/chunks/CelChunk.html (11595, 2023-05-12)
documentation/ase/chunks/CelExtraChunk.html (6887, 2023-05-12)
documentation/ase/chunks/Chunk.html (6678, 2023-05-12)
documentation/ase/chunks/ChunkHeader.html (5955, 2023-05-12)
documentation/ase/chunks/ColorProfileChunk.html (7397, 2023-05-12)
documentation/ase/chunks/ExternalFilesChunk.html (6645, 2023-05-12)
documentation/ase/chunks/LayerBlendMode.html (18562, 2023-05-12)
documentation/ase/chunks/LayerChunk.html (9411, 2023-05-12)
documentation/ase/chunks/LayerFlags.html (9197, 2023-05-12)
documentation/ase/chunks/LayerType.html (6057, 2023-05-12)
documentation/ase/chunks/MaskChunk.html (6706, 2023-05-12)
documentation/ase/chunks/OldPaleteChunk.html (6156, 2023-05-12)
documentation/ase/chunks/Packet.html (4280, 2023-05-12)
documentation/ase/chunks/PaletteChunk.html (7964, 2023-05-12)
documentation/ase/chunks/PaletteEntry.html (7067, 2023-05-12)
documentation/ase/chunks/SliceChunk.html (6988, 2023-05-12)
documentation/ase/chunks/SliceKey.html (6222, 2023-05-12)
documentation/ase/chunks/Tag.html (5000, 2023-05-12)
documentation/ase/chunks/TagsChunk.html (6104, 2023-05-12)
documentation/ase/chunks/TilesetChunk.html (8808, 2023-05-12)
documentation/ase/chunks/UserDataChunk.html (7570, 2023-05-12)
documentation/ase/chunks/index.html (6670, 2023-05-12)
documentation/ase/index.html (4476, 2023-05-12)
documentation/ase/types/ (0, 2023-05-12)
... ...

[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE.md) [![Haxelib Version](https://img.shields.io/github/tag/miriti/ase.svg?style=flat&label=haxelib)](http://lib.haxe.org/p/ase) # ASE .ase/.aseprite file format reader/writer written in Haxe with no external dependencies. Implemented following the official [Aseprite File Format (.ase/.aseprite) Specifications](https://github.com/aseprite/aseprite/blob/master/docs/ase-file-specs.md) Note that this library only provides reading and writing of the Aseprite file format. If you need rendering you will have to implement it yourself or use one of the existing rendering libraries: - [OpenFL Aseprite](https://github.com/miriti/openfl-aseprite) - [heaps-aseprite](https://github.com/AustinEast/heaps-aseprite) by [Austin East](https://github.com/AustinEast) ## Getting Started ### Prerequisites - Haxe compiler - Haxelib ### Installation ``` haxelib install ase ``` ### Usage #### Parsing files ```haxe import sys.io.File; import ase.Ase; var data:Bytes = File.getBytes("path/to/file.aseprite"); var ase:Ase = Ase.fromBytes(data); ``` Now you can access some Aseprite file properties: ```haxe var spriteWidth:Int = ase.width; var spriteHeight:Int = ase.height; var spriteColorDepth:ColorDepth = ase.colorDepth; ``` Palette: ```haxe for(index in ase.palette.firstIndex...ase.palette.lastIndex+1) { var entry:PaletteEntry = ase.palette.getEntry(index); var r:Int = entry.r; var g:Int = entry.g; var b:Int = entry.b; var a:Int = entry.a; var rgbaColor = ase.palette.getRGBA(index); var argbColor = ase.palette.getARGB(index); } ``` Layers: ```haxe for(layer in ase.layers) { var layerName:String = layer.name; var layerEditable:Bool = layer.editable; var layerVisible = layer.visible; } ``` Frames: ```haxe for(frame in ase.frames) { var frameDuration = frame.duration; } ``` Cels: ```haxe var layerIndex:Int = 0; var celWidth:Int = frame.cel(layerIndex).width; var celHeight:Int = frame.cel(layerIndex).height; var celPixelData:Bytes = frame.cel(layerIndex).pixelData; ``` #### Create files ```haxe var spriteWidth:Int = 320; var spriteHeight:Int = 320; var colorDepth:ColorDepth = INDEXED; var initialPalette:Array = [ 0x639bffff, 0x5fcde4ff, 0xcbdbfcff, 0xffffffff, 0x9badb7ff, 0x847e87ff ]; var ase = Ase.create(spriteWidth, spriteHeight, colorDepth); ``` Newly created file always comes with one blank frame. To add some content add at least one layer first: ```haxe ase.addLayer('Background'); ``` Now to add some pixels to the sprite create a Cel on the first frame and the newly created layer: ```haxe var layerIndex:Int = 0; var celWidth:Int = 200; var celHeight:Int = 200; var celXPosition:Int = 60; var celYPosition:Int = 60; var cel = ase.frames[0].createCel( layerIndex, celWidth, celHeight, celXPosition, celYPosition ); ``` There are a couple of methods to manipulate pixels of a cel: ```haxe cel.fillIndex(0); // Fill the cel with color #0 from the palette cel.fillColor(0xff00ff00); // Fill the cel with ARGB color (for 32bpp mode) cel.setPixel(20, 20, 0xff0033aa); // Set ARGB color at x and y cel.setPixel(20, 20, 4); // Set color index at x and y cel.setPixelData(bytes, 300, 300); // Set bytes of the pixel data (the size must me equal to width x height x bpp) ``` At any time you can get the file representation as bytes and, for example, store them to a file: ```haxe var bytes = ase.getBytes(); File.saveBytes('my_aseprite_file.aseprite', bytes); ``` ## License This project is licensed under the MIT License - see the LICENSE.md file for details

近期下载者

相关文件


收藏者