binpack 1.1.0 copy "binpack: ^1.1.0" to clipboard
binpack: ^1.1.0 copied to clipboard

Simple library for 2D bin packing, as used for texture atlases.

Simple library for 2D bin packing, as used for texture atlases.

Pub package Pub publisher Dart Analysis

Features #

Takes a list of rectangles and packs them into a larger rectangle, with the goal of minimizing the larger rectangle's size.

Uses the algorithm described at https://github.com/TeamHypersomnia/rectpack2D

Usage #

import 'package:binpack/binpack.dart';

// Create a list of key and rectanges.
// The key can be anything specific to your application.
final rects = [
    ('image1.png', Rectangle(0, 0, 100, 200)), // Image 100x200 pixels
    ('image2.png', Rectangle(0, 0, 32, 64)),
    ('image3.png', Rectangle(0, 0, 128, 100)),
    ('image4.png', Rectangle(0, 0, 300, 400)),
];

// Target the max size 4096 x 4096
final results = Binpacker(4096, 4096).pack(rects);

// The rectangles are now packed and their positions available:
print(results.placements);

Example #

Packing 168 rects (from a game) into 4060x4065, with 95.7% efficiency. Example Packed Image

1
likes
140
pub points
19%
popularity

Publisher

verified publisherbramp.net

Simple library for 2D bin packing, as used for texture atlases.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-2-Clause (LICENSE)

Dependencies

collection

More

Packages that depend on binpack