///|
pub struct ExportBundle {
sheet : SpriteSheet
atlas : AtlasPlan
machine : AnimationMachine
nine_patches : Array[NinePatch]
diagnostics : Array[Diagnostic]
} derive(Debug, Eq, ToJson, FromJson)
///|
pub fn build_export_bundle(
sheet : SpriteSheet,
atlas? : AtlasOptions = AtlasOptions::default(),
) -> ExportBundle {
let enriched = attach_collision_slices(sheet)
{
sheet: enriched,
atlas: pack_rows(enriched, options=atlas),
machine: build_machine(enriched),
nine_patches: collect_nine_patches(enriched),
diagnostics: validate_sheet(enriched),
}
}
///|
pub fn export_bundle_json(
sheet : SpriteSheet,
atlas? : AtlasOptions = AtlasOptions::default(),
indent? : Int = 2,
) -> String {
build_export_bundle(sheet, atlas~).to_json().stringify(indent~)
}
///|
pub fn convert_aseprite_json(text : String, indent? : Int = 2) -> String raise {
let sheet = parse_aseprite_json(text)
export_bundle_json(sheet, indent~)
}