Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alphabetical grouping #17

Open
visgotti opened this issue Jul 5, 2020 · 3 comments
Open

alphabetical grouping #17

visgotti opened this issue Jul 5, 2020 · 3 comments

Comments

@visgotti
Copy link

visgotti commented Jul 5, 2020

Wondering if there's a way to do this? don't want to spend time digging into the source code if not needed, but if this isn't possible I'll implement it myself- anything insightful that'll help me implement this if I need to dig in?

@soimy
Copy link
Owner

soimy commented Jul 6, 2020

@visgotti Can you describe the meaning of alphabetical grouping? I cannot get it.
Currently, you can group your bins by the tag system.

Check this out:

test("adds to bins with tag matching on", () => {
packer.options.tag = true;
packer.add(1000, 1000, {number: 1});
packer.add(10, 10, {number: 2});
packer.add(1000, 1000, {number: 3, tag: "one"});
packer.add(1000, 1000, {number: 4, tag: "one"});
packer.add(10, 10, {number: 5, tag: "one"});
packer.add(10, 10, {number: 6, tag: "one"});
packer.add(10, 10, {number: 7, tag: "two"});
packer.next();
packer.add(10, 10, {number: 8, tag: "two"});
expect(packer.bins.length).toBe(5);
expect(packer.bins[0].rects.length).toBe(2);
expect(packer.bins[0].tag).toBeUndefined();
expect(packer.bins[1].rects.length).toBe(3);
expect(packer.bins[1].tag).toBe("one");
expect(packer.bins[2].rects.length).toBe(1);
expect(packer.bins[2].tag).toBe("one");
expect(packer.bins[packer.bins.length - 1].rects.length).toBe(1);
expect(packer.bins[packer.bins.length - 1].tag).toBe("two");
});

@visgotti
Copy link
Author

visgotti commented Jul 8, 2020

so I have sprites.. like walk_frame_1, walk_frame_2 etc. I want these to be binned together, but I also want them one after another in the sprite sheet.

@soimy
Copy link
Owner

soimy commented Jul 9, 2020

That's not packer's job, you feed the data with width/height/tag and packer return the bins with position data.
Try isolate the filename as the tag, and sort the returning bin data in the program which calling maxrect-packer's API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants