Giter VIP home page Giter VIP logo

Comments (2)

rdb avatar rdb commented on May 30, 2024

Can't repro this using the following code:

from panda3d.core import *

a = PNMImage(2, 2)

a.set_xel_val(0, 0, 0)
a.set_xel_val(0, 1, 1)
a.set_xel_val(1, 0, 2)
a.set_xel_val(1, 1, 3)

print("Original:")
print(a.get_xel_val(0, 0), a.get_xel_val(0, 1), a.get_xel_val(1, 0), a.get_xel_val(1, 1))

a.flip(True, True, True)

print("Post transform:")
print(a.get_xel_val(0, 0), a.get_xel_val(0, 1), a.get_xel_val(1, 0), a.get_xel_val(1, 1))

It works as expected. Looking at the code I also see nothing wrong.

from panda3d.

izzyboris avatar izzyboris commented on May 30, 2024

You're right. The problem I'm actually running into is that the ordering of the operations seems to be inverted in my reference data (produced from the Tiled map editor). It appears that Tiled transposes from top-left to bottom-right (so [0, 1, 2, 3] turns into [0, 2, 1, 3]) whereas Panda3D transposes bottom-left to top-right ([0, 1, 2, 3] -> [3, 1, 2, 0]).

So the right approach in my case is to reverse the flip_x/flip_y when also transposing. So this seems to work:

                if flags.flipped_diagonally:
                    tmpimg.flip(flip_x=flags.flipped_vertically,
                                flip_y=flags.flipped_horizontally,
                                transpose=flags.flipped_diagonally)
                else:
                    tmpimg.flip(flip_x=flags.flipped_horizontally,
                                flip_y=flags.flipped_vertically,
                                transpose=flags.flipped_diagonally)

Otherwise a less efficient solution would be to perform a separate flip() and only transpose, followed by a flip for mirroring X/Y only.

That makes sense now. Thanks for your time.

from panda3d.

Related Issues (20)

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.