Coder Social home page Coder Social logo

Comments (4)

soimy avatar soimy commented on May 18, 2024

The purpose of save method is to save the freerects of a packer for later use, ie. adding more rects into the packer without overlapping the previous packed rects position.

The final result of the packed rects are stored in every rects position inside packer.bins, example of access them:

packer.bins.forEach(bin => {
    console.log(bin.rects);
});

This repo is just a simple packing algorithm module, so you have to find your own way storing them.

from maxrects-packer.

JohannesHoffmann avatar JohannesHoffmann commented on May 18, 2024

Thank you for your quick response!
I missread the readme about the purpose of the saving method. Maybe renaming it to saveSettings is more clearly for developers?
Second,i need to send the packed bin as a post reqest. The packers -> bin -> rects holding instances of the rect class. Serialize this to get a plain js object makes the rects look like this: { _x: 0, _y: 0, _width: 100, _height: 100}. This is why i thought the save method will create an correct rect without the underscores.

sure i found my own way already but maybe this are points to improve this simple nice module?

from maxrects-packer.

soimy avatar soimy commented on May 18, 2024

The packer.bin.rects are Array of Objects extended from IRectangle interface, take a look at:

export interface IRectangle {
width: number
height: number
x: number
y: number
[propName: string]: any
}

You can simply use JSON.stringify() to serialize as json. For more complicated export, take a look at
https://github.com/soimy/atlasify/blob/master/src/exporter.ts

from maxrects-packer.

soimy avatar soimy commented on May 18, 2024

BTW, Let's move this post to discussions

from maxrects-packer.

Related Issues (18)

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.