part of stitch.outputs;

class PngOutput extends Output {
  String get extension => ".png";

  @override
  Asset renderSprites(List<Sprite> sprites, Asset primaryInput) {
    var size = sprites.map((sprite) => sprite.bounds)
        .reduce((Rectangle value, Rectangle current) => value.boundingBox(current)) as Rectangle;

    var image = new Image(size.width, size.height);
    for (var sprite in sprites) {
      copyInto(image, sprite.image, dstX: sprite.position.x, dstY: sprite.position.y);
    }

    return new Asset.fromBytes(primaryInput.id.changeExtension(extension), encodePng(image));
  }
}
part of stitch.outputs;

class PngOutput extends Output {
  String get extension => ".png";

  @override
  Asset renderSprites(List<Sprite> sprites, Asset primaryInput) {
    var size = sprites.map((sprite) => sprite.bounds)
        .reduce((Rectangle value, Rectangle current) => value.boundingBox(current)) as Rectangle;

    var image = new Image(size.width, size.height);
    for (var sprite in sprites) {
      copyInto(image, sprite.image, dstX: sprite.position.x, dstY: sprite.position.y, blend: false);
    }

    return new Asset.fromBytes(primaryInput.id.changeExtension(extension), encodePng(image));
  }
}
Disable alpha blending to preserve opacity of original sprites
Disable alpha blending to preserve opacity of original sprites

If the original sprite has transparency, alpha blending will change the level of
transparency when it's combined into the sprite sheet. The original transparency
needs to be preserved.

Closes #14
