Skip to content

Commit

Permalink
"from" methods
Browse files Browse the repository at this point in the history
  • Loading branch information
miriti committed Sep 9, 2019
1 parent 05400f6 commit 67d2a02
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ bin/
build/
.vscode/
report/
ase.zip
21 changes: 14 additions & 7 deletions src/ase/Aseprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,24 @@ class Aseprite {
public var header:AseHeader;
public var frames:Array<Frame> = [];

public static function main() {}

public function new(data:Bytes) {
var bytesInput:BytesInput = new BytesInput(data);
public static function fromBytes(bytes:Bytes):Aseprite {
return fromBytesInput(new BytesInput(bytes));
}

header = new AseHeader(bytesInput.read(128));
public static function fromBytesInput(bytesInput:BytesInput):Aseprite {
var aseprite:Aseprite = new Aseprite();

for (frameNum in 0...header.frames) {
aseprite.header = new AseHeader(bytesInput.read(128));
for (frameNum in 0...aseprite.header.frames) {
var frameHeader:FrameHeader = new FrameHeader(bytesInput.read(FrameHeader.BYTE_SIZE));
var frame:Frame = new Frame(frameHeader, bytesInput.read(frameHeader.size - FrameHeader.BYTE_SIZE));
frames.push(frame);
aseprite.frames.push(frame);
}

return aseprite;
}

public static function main() {}

public function new() {}
}

0 comments on commit 67d2a02

Please sign in to comment.