JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q37377F
  • License ISC

Bin pack cut optimize

Package Exports

  • cut-optimizer

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cut-optimizer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Cut Optimize

Read this in other languages: English, Português-BR.

Bin pack Lib to cut optimize.

This lib has basead in code and post in blog by Jake Gordon.

Installation

Use the package manager npm to install.

npm i cut-optimizer --save

Javascript Usage

var cut_optimizer = require("cut-optimizer");
var cut_opt = new cut_optimizer.CutOptimizer();
var shapes = [
    new cut_optimizer.Shape(10, 22), // OR { height: 10, width: 22 }
    new cut_optimizer.Shape(12, 220),// OR { height: 12, width: 22 }
    new cut_optimizer.Shape(13, 230),// OR { height: 13, width: 22 }
    new cut_optimizer.Shape(13, 20),// OR { height: 13 width: 20 }
    new cut_optimizer.Shape(120, 241)// OR { height: 120, width: 241}
];
console.log(cut_opt.optimize(shapes));


//Output
/*{ width: 241,
  height: 158,
  items: 
   [ { width: 241, height: 120, item: [Object], x: 0, y: 0 },
     { width: 230, height: 13, item: [Object], x: 0, y: 120 },
     { width: 220, height: 12, item: [Object], x: 0, y: 133 },
     { width: 20, height: 13, item: [Object], x: 0, y: 145 },
     { width: 22, height: 10, item: [Object], x: 20, y: 145 } ] }
/*

Typescript Usage

import { CutOptimizer, Shape } from "cut-optimizer";

let cut_opt: CutOptimizer = new CutOptimizer();

let shapes: Shape [] =[
 new Shape(10, 22),
 new Shape(12, 220),
 new Shape(13, 230),
 new Shape(13, 20),
 new Shape(120, 241)
]
console.log(cut_opt.optimize(shapes));

//Output
/*{ width: 241,
  height: 158,
  items: 
   [ { width: 241, height: 120, item: [Object], x: 0, y: 0 },
     { width: 230, height: 13, item: [Object], x: 0, y: 120 },
     { width: 220, height: 12, item: [Object], x: 0, y: 133 },
     { width: 20, height: 13, item: [Object], x: 0, y: 145 },
     { width: 22, height: 10, item: [Object], x: 20, y: 145 } ] }
/*

Typescript Demo

Angular 6 Demo

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT