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

Allow rotation #3

Closed
ksesong opened this issue Apr 19, 2019 · 5 comments
Closed

Allow rotation #3

ksesong opened this issue Apr 19, 2019 · 5 comments

Comments

@ksesong
Copy link

ksesong commented Apr 19, 2019

Thanks for the library! Is there any plans to allow rotation of the rects to pack more in a given bin?

@soimy
Copy link
Owner

soimy commented May 8, 2019

@ksesong Is it OK to just allow 0 or 90-degree rotation in packing? I'll be working on this soon

@ksesong
Copy link
Author

ksesong commented May 8, 2019

Yes, this was what I had in mind, and it should cover most situations.

@soimy
Copy link
Owner

soimy commented May 9, 2019

Done via 7e914bc
@ksesong Can you do some test and report back?

@ksesong
Copy link
Author

ksesong commented May 10, 2019

I did some testing, and it does work in my situation (which is quite basic to be honest, so I can't talk about more complex scenarios). Thanks!
I would also mention in the description how you expect the rect to be rotated if rot is true (-90 degrees centered around the top-right corner).

@ksesong ksesong closed this as completed May 10, 2019
@soimy
Copy link
Owner

soimy commented May 10, 2019

@ksesong For the rects in the bin, only width, height, rot(boolean) is given as results. CW/CCW will have the same width \ height so that decision is yours when you actually composite your altas.

Take a lot at these code as an example:
https://github.com/soimy/msdf-bmfont-xml/blob/f1e5b6c58712a2461d150da015af3939863c3f42/index.js#L199-L204

      bin.rects.forEach(rect => {
        if (rect.data.imageData) {
          if (rect.rot) {
            rect.data.imageData.rotate(90);
          }
          img.composite(rect.data.imageData, rect.x, rect.y);
      }

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

No branches or pull requests

2 participants