}
final Map<String,Image.Region> packed = new HashMap<String,Image.Region>();
for (Atlas atlas : atlases) {
Node root = atlas.root;
final SurfaceImage atlasImage = graphics().createSurface(root.width, root.height);
root.visitItems(new Slot<Node>() { @Override public void onEmit (Node node) {
// Draw the item to the atlas
node.item.draw(atlasImage.surface(), node.x, node.y);
// Record its region
packed.put(node.item.id, atlasImage.subImage(
node.x, node.y, node.width, node.height));
}});
}
return packed;
}