-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
118 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
package ase.chunks; | ||
|
||
import haxe.Int32; | ||
import haxe.io.Bytes; | ||
|
||
class ColorProfileChunk extends Chunk { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package ase.chunks; | ||
|
||
import haxe.Int32; | ||
import haxe.io.Bytes; | ||
|
||
class SliceKey { | ||
public var frameNumber:Int; | ||
public var xOrigin:Int32; | ||
public var yOrigin:Int32; | ||
public var width:Int32; | ||
public var height:Int32; | ||
public var xCenter:Int32; | ||
public var yCenter:Int32; | ||
public var centerWidth:Int32; | ||
public var centerHeight:Int32; | ||
public var xPivot:Int32; | ||
public var yPivot:Int32; | ||
|
||
public function new() {} | ||
} | ||
|
||
class SliceChunk extends Chunk { | ||
public var numSliceKeys:Int32; | ||
public var flags:Int32; | ||
|
||
public var reserved:Int32; | ||
public var name:String; | ||
|
||
public var sliceKeys:Array<SliceKey> = []; | ||
|
||
public function new(header:ChunkHeader, chunkData:Bytes) { | ||
super(header, chunkData); | ||
|
||
numSliceKeys = bytesInput.readInt32(); | ||
flags = bytesInput.readInt32(); | ||
reserved = bytesInput.readInt32(); | ||
name = bytesInput.readString(bytesInput.readUInt16()); | ||
|
||
for (n in 0...numSliceKeys) { | ||
var sliceKey:SliceKey = new SliceKey(); | ||
sliceKey.frameNumber = bytesInput.readInt32(); | ||
sliceKey.xOrigin = bytesInput.readInt32(); | ||
sliceKey.yOrigin = bytesInput.readInt32(); | ||
sliceKey.width = bytesInput.readInt32(); | ||
sliceKey.height = bytesInput.readInt32(); | ||
|
||
if (flags & (1 << 0) != 0) { | ||
sliceKey.xCenter = bytesInput.readInt32(); | ||
sliceKey.yCenter = bytesInput.readInt32(); | ||
sliceKey.centerWidth = bytesInput.readInt32(); | ||
sliceKey.centerHeight = bytesInput.readInt32(); | ||
} | ||
|
||
if (flags & (1 << 1) != 0) { | ||
sliceKey.xPivot = bytesInput.readInt32(); | ||
sliceKey.yPivot = bytesInput.readInt32(); | ||
} | ||
|
||
sliceKeys.push(sliceKey); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,37 @@ | ||
import ase.AseHeader; | ||
import haxe.io.Bytes; | ||
import haxe.Resource; | ||
import ase.Aseprite; | ||
import ase.chunks.ChunkType; | ||
import haxe.Resource; | ||
import haxe.io.Bytes; | ||
import massive.munit.Assert; | ||
|
||
class AsepriteTest { | ||
@Test | ||
public function case128x128_rgba() { | ||
// TODO: More/better tests | ||
var aseprite = Aseprite.fromBytes(Resource.getBytes('128x128_rgba')); | ||
Assert.areEqual(AseHeader.ASEPRITE_MAGIC, aseprite.header.magic); | ||
Assert.areEqual(128, aseprite.header.width); | ||
Assert.areEqual(128, aseprite.header.height); | ||
Assert.areEqual(1, aseprite.header.frames); | ||
Assert.areEqual(32, aseprite.header.colorDepth); | ||
} | ||
|
||
@Test | ||
public function caseSlices() { | ||
// TODO: More/better tests | ||
var aseprite = Aseprite.fromBytes(Resource.getBytes('slices.aseprite')); | ||
Assert.areEqual(aseprite.frames[ | ||
0 | ||
].chunkTypes[ | ||
ChunkType.SLICE | ||
].length, 4); | ||
Assert.areEqual(aseprite.frames[ | ||
0 | ||
].chunkTypes[ | ||
ChunkType.SLICE | ||
][ | ||
0 | ||
].userData.text, 'User Data + Blue color'); | ||
} | ||
} |
Binary file not shown.