rectloom

    Deterministic rectangle packing and layout verification toolkit for MoonBit

    rectangle-packing
    layout
    asset-pipeline
    algorithm
    moonbit
    Download zip
    Author
    Version
    0.1.0
    License
    MIT
    Last updated
    2 months ago
    Downloads
    41

    No dependencies

    #rectloom

    rectloom 是一个 MoonBit 原生的确定性矩形打包与布局校验库,用于把一组带尺寸的矩形放入固定二维容器,并导出可复现的布局清单。它适合游戏资源图集、终端/文档布局、WebAssembly 小工具、资源管线和教学项目中需要“先算布局、再渲染或导出”的场景。

    #解决的问题

    MoonBit 生态里已有图形、资源和布局相关项目,但缺少一个小而完整的纯几何矩形打包基础库。rectloom 不处理图片像素、不绑定平台 API,而是专注于可复用的布局算法、输入校验、错误报告和清单导出,便于被其他 MoonBit 包直接嵌入。

    #安装

    Mooncakes 拟定包名:

    YM-ai-nb/rectloom

    发布到 Mooncakes 后,可在 MoonBit 项目中添加依赖:

    moon add YM-ai-nb/rectloom

    Mooncakes owner 与 moon.mod 中的 name 保持一致。

    #最小示例

    let options = @rectloom.PackOptions::default(64, 32)
    let rects = [
    @rectloom.Rect::make("hero", 18, 12),
    @rectloom.Rect::make("icon", 8, 8),
    @rectloom.Rect::make("badge", 9, 5),
    ]

    match @rectloom.pack(rects, options) {
    Ok(layout) => println(@rectloom.to_report(layout))
    Err(err) => println(@rectloom.error_message(err))
    }

    也可以使用内置文本 spec:

    let layout = @rectloom.pack_spec(
    "bin 64 32\npadding 1 1\nalgorithm guillotine\nsort area\nrotate true\nrect hero 18 12\n",
    )

    #本地运行

    moon fmt --check moon check --deny-warn moon build moon test --deny-warn moon run cmd/main

    示例入口 cmd/main 会运行内置 sample,并打印布局报告、ASCII 预览、审计摘要和自动推荐结果。

    #核心功能

    • 数据模型:Rect、Bin、Padding、PackOptions、Placed、Layout、Page、MultiLayout。
    • 打包算法:ShelfFirstFit、GuillotineBestArea 与 SkylineBottomLeft。
    • 排序策略:输入顺序、面积、高度、宽度、周长优先。
    • 可选旋转:允许宽高交换以提高容器利用率。
    • 多页打包:超过单个容器容量时分页输出。
    • 校验器:尺寸、padding、重复 id、越界、重叠检查。
    • 文本 spec:解析 bin、padding、algorithm、sort、rotate、rect。
    • 分析诊断:布局统计、密度网格、热力图、约束检查、差异对比和自动方案推荐。
    • 内置 fixture:图集、UI 面板、文档块、混合图标和细条压力测试数据。
    • 导出器:稳定 JSON manifest、人类可读 report、CSV、Markdown 表格和 ASCII 预览。
    • 示例:moon run cmd/main。

    #支持范围

    • 纯 MoonBit 实现,无运行时外部依赖。
    • 固定尺寸单 bin 打包。
    • 固定尺寸多页打包。
    • 整数坐标与整数尺寸。
    • 确定性输出,适合 CI 快照和资源管线。
    • 自制测试数据,覆盖正常、错误、边界、导出和校验路径。

    #暂不支持范围

    • 不同尺寸容器之间的自动选择。
    • 任意多边形、圆形或带透明像素的真实图像检测。
    • 图片读取、PNG/JPEG 编码或图集像素合成。
    • 浮点坐标和亚像素布局。
    • 全局最优装箱保证;当前算法以稳定、可解释、易复现为目标。

    #文本 Spec 格式

    bin 64 32 padding 1 1 algorithm guillotine sort area rotate true rect hero 18 12 rect icon 8 8

    #多页与预览

    let pages = @rectloom.pack_pages(rects, options, 3)
    let preview = @rectloom.to_ascii_preview(layout, cell_width=4, cell_height=4)

    pack_pages 会使用同一套容器配置逐页放置剩余矩形;to_ascii_preview 用每个矩形 id 的首字符生成粗略字符网格,方便在终端和 CI 日志里快速检查布局。

    以 # 开头或包含 # 后缀的内容会作为注释忽略。

    #文档

    #验收命令

    moon fmt --check moon check --deny-warn moon build moon test --deny-warn moon run cmd/main moon publish --dry-run

    moon publish --dry-run 需要在完成 MoonBit 登录后执行。

    #开源许可证与参考说明

    本项目使用 MIT 许可证。核心算法、spec 解析器、导出器和测试 fixture 均为 MoonBit 原生实现,不移植第三方源码,不包含来源不明素材或私有代码。

    Algorithm

    pub(all) enum Algorithm {
    ShelfFirstFit
    GuillotineBestArea
    SkylineBottomLeft
    } derive(Eq,
    Debug
    )

    Packing algorithm.

    Bin

    pub(all) struct Bin {
    width : Int
    height : Int
    } derive(Eq,
    Debug
    )

    Two-dimensional bin where rectangles are placed.

    Bin::make

    fn Bin::make(width : Int, height : Int) -> Bin

    Convenience bin constructor.

    ConstraintViolation

    pub(all) struct ConstraintViolation {
    name : String
    expected : Int
    actual : Int
    severity : IssueSeverity
    } derive(Eq,
    Debug
    )

    One failed production constraint.

    DensityCell

    pub(all) struct DensityCell {
    col : Int
    row : Int
    x : Int
    y : Int
    width : Int
    height : Int
    used_area : Int
    capacity : Int
    occupancy_permille : Int
    } derive(Eq,
    Debug
    )

    A coarse grid cell used by density and heatmap reports.

    FixtureKind

    pub(all) enum FixtureKind {
    SpriteSheet
    UiPanels
    DocumentBlocks
    MixedIcons
    StressSlivers
    } derive(Eq,
    Debug
    )

    Built-in fixture families for examples, smoke tests, and benchmarks.

    GridReport

    pub(all) struct GridReport {
    cell_width : Int
    cell_height : Int
    cols : Int
    rows : Int
    cells : Array[DensityCell]
    occupied_cells : Int
    empty_cells : Int
    densest_cell : DensityCell
    sparsest_cell : DensityCell
    } derive(Eq,
    Debug
    )

    Coarse grid summary of a layout.

    IssueKind

    pub(all) enum IssueKind {
    LowOccupancy
    HasUnpacked
    WideBoundingBox
    TallBoundingBox
    SparseGrid
    HeavyRotation
    FragmentedRows
    ConstraintFailed
    SourceRisk
    } derive(Eq,
    Debug
    )

    Machine-readable category for layout diagnostics.

    IssueSeverity

    pub(all) enum IssueSeverity {
    Info
    Warning
    Critical
    } derive(Eq,
    Debug
    )

    Severity used by diagnostic reports.

    Layout

    pub(all) struct Layout {
    bin : Bin
    placements : Array[Placed]
    unpacked : Array[Rect]
    algorithm : Algorithm
    occupancy_permille : Int
    waste_area : Int
    } derive(Eq,
    Debug
    )

    Resulting layout and the items that did not fit.

    LayoutConstraints

    pub(all) struct LayoutConstraints {
    min_occupancy_permille : Int
    max_waste_permille : Int
    min_gap : Int
    max_row_count : Int
    max_column_count : Int
    max_rotated_permille : Int
    require_all_packed : Bool
    } derive(Eq,
    Debug
    )

    Optional policy checks for callers that need production constraints.

    LayoutConstraints::default

    LayoutConstraints::strict

    LayoutDiff

    pub(all) struct LayoutDiff {
    left_algorithm : Algorithm
    right_algorithm : Algorithm
    left_occupancy_permille : Int
    right_occupancy_permille : Int
    occupancy_delta : Int
    added_count : Int
    removed_count : Int
    moved_count : Int
    resized_count : Int
    rotation_changed_count : Int
    unchanged_count : Int
    changes : Array[PlacementChange]
    } derive(Eq,
    Debug
    )

    Summary of differences between two layouts.

    LayoutIssue

    pub(all) struct LayoutIssue {
    severity : IssueSeverity
    kind : IssueKind
    id : String
    message : String
    value : Int
    } derive(Eq,
    Debug
    )

    One diagnostic finding.

    LayoutStats

    pub(all) struct LayoutStats {
    placed_count : Int
    unpacked_count : Int
    rotated_count : Int
    used_area : Int
    container_area : Int
    padded_capacity : Int
    occupancy_permille : Int
    padded_occupancy_permille : Int
    waste_area : Int
    bounding_x : Int
    bounding_y : Int
    bounding_width : Int
    bounding_height : Int
    bounding_area : Int
    bounding_occupancy_permille : Int
    row_count : Int
    column_count : Int
    horizontal_span : Int
    vertical_span : Int
    fragmentation_score : Int
    compactness_score : Int
    } derive(Eq,
    Debug
    )

    Derived metrics for a completed layout.

    MultiLayout

    pub(all) struct MultiLayout {
    pages : Array[Page]
    unpacked : Array[Rect]
    total_occupancy_permille : Int
    } derive(Eq,
    Debug
    )

    Multipage result for inputs that do not fit in a single bin.

    PackCandidate

    pub(all) struct PackCandidate {
    options : PackOptions
    layout : Layout
    score : Int
    rank : Int
    } derive(Eq,
    Debug
    )

    One candidate produced by automatic option exploration.

    PackComparison

    pub(all) struct PackComparison {
    base_options : PackOptions
    candidates : Array[PackCandidate]
    best : PackCandidate
    } derive(Eq,
    Debug
    )

    Result of comparing several option combinations for the same inputs.

    PackError

    pub(all) enum PackError {
    InvalidBin(width~ : Int, height~ : Int)
    InvalidPadding(outer~ : Int, inner~ : Int)
    InvalidRect(id~ : String, width~ : Int, height~ : Int)
    InvalidPageLimit(limit~ : Int)
    InvalidCellSize(width~ : Int, height~ : Int)
    DuplicateId(id~ : String)
    OutOfBounds(id~ : String)
    Overlap(left~ : String, right~ : String)
    ParseError(line~ : Int, message~ : String)
    } derive(Eq,
    Debug
    )

    Errors are explicit so callers can surface actionable diagnostics.

    PackOptions

    pub(all) struct PackOptions {
    bin : Bin
    padding : Padding
    sort : SortOrder
    algorithm : Algorithm
    allow_rotate : Bool
    } derive(Eq,
    Debug
    )

    Complete pack configuration.

    PackOptions::default

    fn PackOptions::default(width : Int, height : Int) -> PackOptions

    Recommended default options for deterministic asset-style packing.

    Padding

    pub(all) struct Padding {
    outer : Int
    inner : Int
    } derive(Eq,
    Debug
    )

    Outer padding reserves a border around the bin. Inner padding is inserted between placements by the built-in algorithms.

    Padding::make

    fn Padding::make(outer : Int, inner : Int) -> Padding

    Convenience padding constructor.

    Page

    pub(all) struct Page {
    index : Int
    layout : Layout
    } derive(Eq,
    Debug
    )

    One packed page in a multipage result.

    Placed

    pub(all) struct Placed {
    id : String
    x : Int
    y : Int
    width : Int
    height : Int
    rotated : Bool
    original_width : Int
    original_height : Int
    } derive(Eq,
    Debug
    )

    One successful placement.

    PlacementChange

    pub(all) struct PlacementChange {
    id : String
    kind : PlacementChangeKind
    old_x : Int
    old_y : Int
    old_width : Int
    old_height : Int
    new_x : Int
    new_y : Int
    new_width : Int
    new_height : Int
    area_delta : Int
    } derive(Eq,
    Debug
    )

    One placement-level difference between two layouts.

    PlacementChangeKind

    pub(all) enum PlacementChangeKind {
    Added
    Removed
    Moved
    Resized
    RotationChanged
    Unchanged
    } derive(Eq,
    Debug
    )

    Change type for comparing two layouts.

    Rect

    pub(all) struct Rect {
    id : String
    width : Int
    height : Int
    } derive(Eq,
    Debug
    )

    Rectangle item requested by a caller.

    Rect::make

    fn Rect::make(id : StringView, width : Int, height : Int) -> Rect

    Convenience rectangle constructor.

    RectSetStats

    pub(all) struct RectSetStats {
    count : Int
    total_area : Int
    min_width : Int
    max_width : Int
    min_height : Int
    max_height : Int
    min_area : Int
    max_area : Int
    average_width_permille : Int
    average_height_permille : Int
    average_area_permille : Int
    square_count : Int
    wide_count : Int
    tall_count : Int
    oversized_count : Int
    } derive(Eq,
    Debug
    )

    Aggregate information about a source rectangle collection.

    SortOrder

    pub(all) enum SortOrder {
    InputOrder
    AreaDesc
    HeightDesc
    WidthDesc
    PerimeterDesc
    } derive(Eq,
    Debug
    )

    Sort strategy used before packing starts.

    Spec

    pub(all) struct Spec {
    options : PackOptions
    rects : Array[Rect]
    } derive(Eq,
    Debug
    )

    Parsed text specification.

    analyze_layout

    fn analyze_layout(layout : Layout) -> Result[LayoutStats, PackError]

    Analyze a layout using the full container area as capacity.

    analyze_layout_with_options

    fn analyze_layout_with_options(layout : Layout, options : PackOptions) -> Result[LayoutStats, PackError]

    Analyze a layout with the padded capacity from the original options.

    audit_spec

    fn audit_spec(source : String) -> Result[String, PackError]

    Parse, pack, and audit a text spec in one call.

    check_constraints

    fn check_constraints(layout : Layout, constraints : LayoutConstraints) -> Result[Array[ConstraintViolation], PackError]

    Check a layout against caller-supplied production constraints.

    clamp_rects_to_bin

    fn clamp_rects_to_bin(rects : ArrayView[Rect], bin : Bin) -> Array[Rect]

    Clamp rectangle dimensions to a bin-sized maximum.

    column_density_hint

    fn column_density_hint(layout : Layout) -> Result[Int, PackError]

    compact_audit_summary

    fn compact_audit_summary(layout : Layout) -> Result[String, PackError]

    Produce a compact one-screen summary for command line demos.

    compare_fixture

    fn compare_fixture(kind : FixtureKind, count : Int) -> Result[PackComparison, PackError]

    Run automatic comparison on a fixture family.

    compare_packers

    fn compare_packers(rects : ArrayView[Rect], base : PackOptions) -> Result[PackComparison, PackError]

    Compare deterministic option combinations for the same input.

    dedupe_rect_ids

    fn dedupe_rect_ids(rects : ArrayView[Rect]) -> Array[Rect]

    Make all ids unique with stable numeric suffixes.

    density_grid

    fn density_grid(layout : Layout, cell_width? : Int, cell_height? : Int) -> Result[GridReport, PackError]

    Build a coarse density grid for a validated layout.

    diagnose_layout

    fn diagnose_layout(layout : Layout) -> Result[Array[LayoutIssue], PackError]

    Diagnose a completed layout and return structured findings.

    diagnose_layout_report

    fn diagnose_layout_report(layout : Layout) -> Result[String, PackError]

    Convenience wrapper for layout diagnostics.

    diagnose_rects

    fn diagnose_rects(rects : ArrayView[Rect]) -> Array[LayoutIssue]

    Diagnose source rectangles without a target bin.

    diagnose_rects_for_bin

    fn diagnose_rects_for_bin(rects : ArrayView[Rect], bin : Bin) -> Array[LayoutIssue]

    Diagnose source rectangles against a target bin.

    diff_algorithms

    fn diff_algorithms(rects : ArrayView[Rect], base : PackOptions, left_algorithm : Algorithm, right_algorithm : Algorithm) -> Result[LayoutDiff, PackError]

    Convenience wrapper to compare two algorithms using the same input.

    diff_layouts

    fn diff_layouts(left : Layout, right : Layout) -> Result[LayoutDiff, PackError]

    Compare two validated layouts by placement id.

    error_message

    fn error_message(err : PackError) -> String

    Stable display text for errors.

    expand_rects

    fn expand_rects(rects : ArrayView[Rect], amount : Int) -> Array[Rect]

    Add pixels around every rectangle.

    filter_fit_rects

    fn filter_fit_rects(rects : ArrayView[Rect], bin : Bin, allow_rotate : Bool) -> Array[Rect]

    Keep rectangles that can fit the bin, optionally considering rotation.

    filter_oversized_rects

    fn filter_oversized_rects(rects : ArrayView[Rect], bin : Bin, allow_rotate : Bool) -> Array[Rect]

    Keep rectangles that cannot fit the bin.

    find_density_cell

    fn find_density_cell(report : GridReport, x : Int, y : Int) -> DensityCell?

    Find the density cell that contains a point.

    fixture_audit

    fn fixture_audit(kind : FixtureKind, count : Int) -> Result[String, PackError]

    Run a complete audit against a built-in fixture family.

    fixture_catalog

    fn fixture_catalog() -> String

    Human-readable list of built-in fixtures.

    fixture_description

    fn fixture_description(kind : FixtureKind) -> String

    fixture_name

    fn fixture_name(kind : FixtureKind) -> String

    fixture_options

    fn fixture_options(kind : FixtureKind) -> PackOptions

    Recommended starting options for a fixture family.

    fixture_rects

    fn fixture_rects(kind : FixtureKind, count : Int) -> Array[Rect]

    Generate deterministic sample rectangles for examples and benchmarks.

    fixture_spec

    fn fixture_spec(kind : FixtureKind, count : Int) -> String

    Generate a ready-to-pack spec for a fixture family.

    full_layout_audit

    fn full_layout_audit(layout : Layout) -> Result[String, PackError]

    Build a complete text audit for a validated layout.

    issue_kind_name

    fn issue_kind_name(kind : IssueKind) -> String

    layout_quality_score

    fn layout_quality_score(stats : LayoutStats) -> Int

    layout_signature

    fn layout_signature(layout : Layout) -> Result[String, PackError]

    Stable compact signature useful for snapshot tests.

    normalize_rects

    fn normalize_rects(rects : ArrayView[Rect], max_width : Int, max_height : Int) -> Array[Rect]

    Normalize inputs by deduping ids and splitting pieces larger than limits.

    normalize_rects_for_bin

    fn normalize_rects_for_bin(rects : ArrayView[Rect], bin : Bin) -> Array[Rect]

    Normalize inputs for a target bin.

    original_rects_from_layout

    fn original_rects_from_layout(layout : Layout) -> Array[Rect]

    Return all original dimensions from a layout, including unpacked items.

    pack

    fn pack(rects : ArrayView[Rect], options : PackOptions) -> Result[Layout, PackError]

    Pack rectangles using the algorithm selected by options.

    pack_fixture

    fn pack_fixture(kind : FixtureKind, count : Int) -> Result[Layout, PackError]

    Pack a fixture with its recommended options.

    pack_pages

    fn pack_pages(rects : ArrayView[Rect], options : PackOptions, max_pages : Int) -> Result[MultiLayout, PackError]

    Pack rectangles across multiple pages with the same bin/options.

    pack_pages_spec

    fn pack_pages_spec(source : String, max_pages : Int) -> Result[MultiLayout, PackError]

    Parse a spec and pack it across several pages.

    pack_spec

    fn pack_spec(source : String) -> Result[Layout, PackError]

    Pack a textual spec in one call.

    packing_audit

    fn packing_audit(rects : ArrayView[Rect], options : PackOptions) -> Result[String, PackError]

    Pack, compare option variants, and return a combined audit report.

    parse_spec

    fn parse_spec(source : String) -> Result[Spec, PackError]

    Parse a small line-oriented specification.

    Supported directives:
    • bin <width> <height>
    • padding <outer> <inner>
    • algorithm shelf|guillotine
    • sort input|area|height|width|perimeter
    • rotate true|false
    • rect <id> <width> <height>

    placement_change_name

    fn placement_change_name(kind : PlacementChangeKind) -> String

    placements_touching_cell

    fn placements_touching_cell(layout : Layout, cell : DensityCell) -> Result[Int, PackError]

    Count placements touching a coarse grid cell.

    prefix_rect_ids

    fn prefix_rect_ids(rects : ArrayView[Rect], prefix : String) -> Array[Rect]

    Prefix all rectangle ids.

    recommend_candidate

    fn recommend_candidate(rects : ArrayView[Rect], base : PackOptions) -> Result[PackCandidate, PackError]

    Return the top candidate without discarding ranking metadata.

    recommend_pack

    fn recommend_pack(rects : ArrayView[Rect], base : PackOptions) -> Result[Layout, PackError]

    Pack with the highest-scoring option combination.

    rects_from_layout

    fn rects_from_layout(layout : Layout) -> Array[Rect]

    Convert a layout back to the dimensions that were actually packed.

    rects_from_placements

    fn rects_from_placements(placements : ArrayView[Placed]) -> Array[Rect]

    Convert placements back to rectangle dimensions for follow-up packing.

    rects_to_csv

    fn rects_to_csv(rects : ArrayView[Rect]) -> String

    Export rectangle dimensions as CSV.

    rects_to_markdown_table

    fn rects_to_markdown_table(rects : ArrayView[Rect]) -> String

    Export rectangle dimensions as a Markdown table.

    rects_to_spec

    fn rects_to_spec(rects : ArrayView[Rect], options : PackOptions) -> String

    Export any rectangle list as a rectloom text spec.

    row_density_hint

    fn row_density_hint(layout : Layout) -> Result[Int, PackError]

    sample_layout

    fn sample_layout() -> Result[Layout, PackError]

    Built-in sample layout. The return type stays explicit so CI catches regressions in the example path.

    sample_spec

    fn sample_spec() -> String

    Built-in sample used by the CLI smoke test and README.

    scale_rects

    fn scale_rects(rects : ArrayView[Rect], permille : Int) -> Array[Rect]

    Scale all rectangles by an integer permille factor.

    severity_name

    fn severity_name(severity : IssueSeverity) -> String

    shrink_rects

    fn shrink_rects(rects : ArrayView[Rect], amount : Int) -> Array[Rect]

    Remove pixels around every rectangle while keeping each side positive.

    split_tall_rects

    fn split_tall_rects(rects : ArrayView[Rect], max_height : Int) -> Array[Rect]

    Split rectangles taller than max_height into deterministic pieces.

    split_wide_rects

    fn split_wide_rects(rects : ArrayView[Rect], max_width : Int) -> Array[Rect]

    Split rectangles wider than max_width into deterministic pieces.

    strict_constraint_report

    fn strict_constraint_report(layout : Layout) -> Result[String, PackError]

    Convenience wrapper for strict production-oriented checks.

    suffix_rect_ids

    fn suffix_rect_ids(rects : ArrayView[Rect], suffix : String) -> Array[Rect]

    Suffix all rectangle ids.

    summarize_rects

    fn summarize_rects(rects : ArrayView[Rect]) -> RectSetStats

    Summarize a rectangle collection without considering a target bin.

    summarize_rects_for_bin

    fn summarize_rects_for_bin(rects : ArrayView[Rect], bin : Bin) -> RectSetStats

    Summarize a rectangle collection and count items larger than bin.

    to_analysis_report

    fn to_analysis_report(layout : Layout) -> Result[String, PackError]

    to_ascii_preview

    fn to_ascii_preview(layout : Layout, cell_width? : Int, cell_height? : Int) -> Result[String, PackError]

    Render a coarse ASCII preview of a layout. Each output cell represents cell_width by cell_height layout units.

    to_comparison_csv

    fn to_comparison_csv(comparison : PackComparison) -> String

    CSV output for spreadsheet-based result comparison.

    to_comparison_report

    fn to_comparison_report(comparison : PackComparison) -> String

    Human-readable report for automatic option exploration.

    to_constraint_report

    fn to_constraint_report(violations : ArrayView[ConstraintViolation]) -> String

    Human-readable constraint check output.

    to_density_csv

    fn to_density_csv(report : GridReport) -> String

    Render density grid as CSV for external analysis.

    to_density_report

    fn to_density_report(report : GridReport) -> String

    Human-readable grid report.

    to_diagnostics_report

    fn to_diagnostics_report(issues : ArrayView[LayoutIssue]) -> String

    Human-readable diagnostic report.

    to_heatmap_preview

    fn to_heatmap_preview(report : GridReport) -> String

    Render density grid as a compact heatmap.

    to_json_manifest

    fn to_json_manifest(layout : Layout) -> String

    Export a deterministic JSON manifest. The output avoids external JSON dependencies so it works in small WASM examples.

    to_layout_diff_csv

    fn to_layout_diff_csv(diff : LayoutDiff) -> String

    CSV layout diff for snapshots and spreadsheets.

    to_layout_diff_report

    fn to_layout_diff_report(diff : LayoutDiff) -> String

    Human-readable layout diff.

    to_layout_stats_report

    fn to_layout_stats_report(stats : LayoutStats) -> String

    to_pages_json_manifest

    fn to_pages_json_manifest(result : MultiLayout) -> String

    Stable JSON manifest for multipage packing.

    to_pages_report

    fn to_pages_report(result : MultiLayout) -> String

    Human-readable multipage report.

    to_rect_stats_report

    fn to_rect_stats_report(stats : RectSetStats) -> String

    to_report

    fn to_report(layout : Layout) -> String

    Export a compact human-readable report.

    utilization_label

    fn utilization_label(permille : Int) -> String

    validate_layout

    fn validate_layout(layout : Layout) -> Result[Unit, PackError]

    Validate a produced or externally assembled layout.