Coder Social home page Coder Social logo

finscn / maxrectsbinpack Goto Github PK

View Code? Open in Web Editor NEW

This project forked from 06wj/maxrectsbinpack

2.0 3.0 1.0 85 KB

MaxRects Algorithm JavaScript implementation

Home Page: https://06wj.github.io/MaxRectsBinPack/demo/test.html

License: MIT License

JavaScript 100.00%

maxrectsbinpack's Introduction

rects-bin-pack npm runkit

MaxRects Algorithm JavaScript implementation

demo

usage

  • init bin pack
    /**
    * MaxRectanglesBinPack
    * @param {Number} width The container width
    * @param {Number} height The container height
    * @param {Boolean} [allowRotate=false] Whether to allow rotate the rects
    */
    const pack = new MaxRectsBinPack.MaxRectsBinPack(512, 256, false);
    
  • add rectangles
    const rectangles = [{
        width: 20,
        height: 100,
        id: '1'
    }, {
        width: 200,
        height: 70,
        id: '2'
    }, {
        width: 30,
        height: 70,
        id: '3'
    }];
    /**
     * Insert a set of rectangles
     * @param  {Rect[]} rectangles The set of rects, allow custum property
     * @param  {Number} method The pack rule, allow value is BestShortSideFit, BestLongSideFit, BestAreaFit, BottomLeftRule, ContactPointRule
     * @return {Rect[]} The result of bin pack.
     */
    const result = pack.insert2(rectangles, MaxRectsBinPack.BestShortSideFit)
    

Dev

  • run npm install to install dependencies
  • run npm run dev to watch and develop
  • run npm run build to build

License

MIT License

maxrectsbinpack's People

Contributors

finscn avatar 06wj avatar

Stargazers

James Edward Lewis II avatar Haroldo de Oliveira Pinheiro avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

mkwong98

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.