TextureAtlas | A simple script to generate texture atlases | Game Engine library

 by   operasoftware Python Version: Current License: Non-SPDX

kandi X-RAY | TextureAtlas Summary

kandi X-RAY | TextureAtlas Summary

TextureAtlas is a Python library typically used in Gaming, Game Engine applications. TextureAtlas has no vulnerabilities and it has low support. However TextureAtlas has 8 bugs, it build file is not available and it has a Non-SPDX License. You can download it from GitHub.

This is a short python script that takes a folder of images and generates a texture atlas from it. The images will be cropped to their non transparent bounding boxes. The script generates a CSS file and JSON file that can be used together with the texture atlas as well as an illustrative SVG/animation showing how the texture atlas is created.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              TextureAtlas has a low active ecosystem.
              It has 24 star(s) with 3 fork(s). There are 44 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 1 open issues and 0 have been closed. On average issues are closed in 2670 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of TextureAtlas is current.

            kandi-Quality Quality

              TextureAtlas has 8 bugs (0 blocker, 0 critical, 8 major, 0 minor) and 43 code smells.

            kandi-Security Security

              TextureAtlas has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              TextureAtlas code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              TextureAtlas has a Non-SPDX License.
              Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.

            kandi-Reuse Reuse

              TextureAtlas releases are not available. You will need to build from source code and install.
              TextureAtlas has no build file. You will be need to create the build yourself to build the component from source.
              It has 2001 lines of code, 15 functions and 7 files.
              It has high code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed TextureAtlas and discovered the below as its top functions. This is intended to give you an instant insight into TextureAtlas implemented functionality, and help decide if they suit your requirements.
            • Write SVG to a file
            • Height of the node
            • Width of the region
            • Insert r
            • Writes CSS to a file
            • Add all source images in a folder
            • Writes images to JSON file
            • Write a list of images
            • Finalize the image
            • Removes borders
            • Return the area of the image
            • Returns the maximum extent of the rectangle i
            • Height of the tree
            Get all kandi verified functions for this library.

            TextureAtlas Key Features

            No Key Features are available at this moment for TextureAtlas.

            TextureAtlas Examples and Code Snippets

            No Code Snippets are available at this moment for TextureAtlas.

            Community Discussions

            QUESTION

            TextureAtlas - how does it affect on RAM usage in open world game?
            Asked 2022-Jan-23 at 08:49

            I plan to use TextureAtlas in my open world 2d game.

            I need to load textures dynamically (because there are thousands of them, so I cannot load all at once). I plan to load textures that are needed at specific moment in gameplay. Also for some reasons I cannot have many texture atlases per map location.

            Generally, I must avoid situation that I read all textures (entire atlas), because RAM usage will be too large. How the TextureAtlas work? Is is possible to keep the atlas open during entire game, but read from the atlas (to the RAM) only chosen textures when needed without worrying about RAM usage?

            Best regards.

            ...

            ANSWER

            Answered 2022-Jan-22 at 22:59

            You cannot load portions of a TextureAtlas. It is all or nothing. You will have to use multiple atlases and carefully plan what to put in each atlas such that you don’t have to load all of them simultaneously.

            A Texture represents a single image loaded into GPU memory for use in OpenGL. A page of a TextureAtlas corresponds to a single Texture. Typically, you will have multiple TextureRegions on each page (Texture) of a TextureRegion. If you don’t, there’s no point in using TextureAtlas. The point of TextureAtlas is to avoid SpriteBatch having to flush vertex data and swap OpenGL textures for every sprite you draw. If you draw consecutive TextureRegions from the same Texture (or atlas page), they are batched together into a single mesh and OpenGL texture so it performs better.

            Libgdx doesn’t support loading individual pages of a TextureAtlas though. That would make it too complicated to use. So, if you are doing a lot of loading and unloading, I recommend avoiding multipage atlases. Use AssetManager to very easily load and unload what you need.

            Source https://stackoverflow.com/questions/70800960

            QUESTION

            Part of my animation is not working in SpriteKit
            Asked 2021-Dec-18 at 18:20
            init () {
                
                super.init(texture: nil, color: .clear, size: initialSize)
                // Create physicsBody based on a frame of the sprite
                // basically giving it gravity and physics components
                let bodyTexture = textureAtlas.textureNamed("MainCharacterFlying1")
                self.physicsBody = SKPhysicsBody(texture: bodyTexture, size: self.size)
                // Lose momentum quickly with high linear dampening
                self.physicsBody?.linearDamping = 0.9
                // weighs around 30 kg
                self.physicsBody?.mass = 30
                // no rotation
                self.physicsBody?.allowsRotation = false
                createAnimations()
                self.run(soarAnimation, withKey: "soarAnimation")
            }
            
            
            // Animations to make the main character seem like it is flying
            func createAnimations() {
                let rotateUpAction = SKAction.rotate(byAngle: 0, duration: 0.475)
                rotateUpAction.timingMode = .easeOut
                
                let rotateDownAction = SKAction.rotate(byAngle: -1, duration: 0.8)
                rotateDownAction.timingMode = .easeIn
                
                let flyFrames: [SKTexture] = [textureAtlas.textureNamed("MainCharacterFlying1"), textureAtlas.textureNamed("MainCharacterFlying2"),textureAtlas.textureNamed("MainCharacterFlying3"), textureAtlas.textureNamed("MainCharacterFlying4"),textureAtlas.textureNamed("MainCharacterFlying5"),textureAtlas.textureNamed("MainCharacterFlying4"),textureAtlas.textureNamed("MainCharacterFlying3"),textureAtlas.textureNamed("MainCharacterFlying2")]
                var flyAction = SKAction.animate(with: flyFrames, timePerFrame: 0.1)
                flyAction = SKAction.repeatForever(flyAction)
                flyAnimation = SKAction.group([flyAction,rotateUpAction])
                
                let soarFrames: [SKTexture] = [textureAtlas.textureNamed("MainCharacterFlying5")]
                var soarAction = SKAction.animate(with: soarFrames, timePerFrame: 1)
                soarAction = SKAction.repeatForever(soarAction)
                let soarAnimation = SKAction.group([soarAction,rotateDownAction])
            }
            
            ...

            ANSWER

            Answered 2021-Dec-18 at 18:20

            you declare let soarAnimation inside your createAnimations function, meaning it's not in scope when you call self.run(soarAnimation). Solution: declare soarAnimation as a class property. Alternate solution: have createAnimations() return the SKAction and grab it in init that way

            Source https://stackoverflow.com/questions/70404819

            QUESTION

            SKTileMapNode disappears when off-camera, does not reappear
            Asked 2021-Jul-11 at 16:53

            I have a SpriteKit platformer that uses a tile map for a background. The background in question is positioned 1 screen-height above the main content (it's positioned off-screen), acting as a forest canopy above the player. I accomplish that programmatically, like this:

            ...

            ANSWER

            Answered 2021-Jul-11 at 16:53

            It seems that I've solved the problem.

            I'm presenting my scene via SwiftUI SpriteView, which I had configured to allow background transparency, like this:

            Source https://stackoverflow.com/questions/68329838

            QUESTION

            Is there a way to deprecate or hide system framework API in Swift?
            Asked 2021-May-03 at 13:16

            For some context, I am using SpriteKit. I created an extension for SKTexture:

            ...

            ANSWER

            Answered 2021-Mar-30 at 06:59

            I guess it's impossible to deprecate a system API.

            You may override a default behaviour:

            Source https://stackoverflow.com/questions/66866039

            QUESTION

            It takes like 5 seconds to assign a 1000x1000 pixel texture to a SpriteSheetBundle in the Bevy game engine
            Asked 2021-Mar-08 at 01:19

            Is there a way of improving this situation or am i just using the engine wrong? I tried to go around this problem by first creating and spawning Images of the Background with lower Quality.

            ...

            ANSWER

            Answered 2021-Mar-08 at 01:19

            When compiling with the --release command line option, it runs much faster as the release profile have optimization enabled.

            See cargo documentation

            Source https://stackoverflow.com/questions/66516161

            QUESTION

            Performant method of drawing text onto a png file?
            Asked 2021-Mar-03 at 11:54

            I need to draw a two-dimensional grid of Squares with centered Text on them onto a (transparent) PNG file. The tiles need to have a sufficiently big resolution, so that the text does not get pixaleted to much.

            For testing purposes I create a 2048x2048px 32-bit (transparency) PNG Image with 128x128px tiles like for example that one:

            The problem is I need to do this with reasonable performance. All methods I have tried so far took more than 100ms to complete, while I would need this to be at a max < 10ms. Apart from that I would need the program generating these images to be Cross-Platform and support WebAssembly (but even if you have for example an idea how to do this using posix threads, etc. I would gladly take that as a starting point, too).

            Net5 Implementation ...

            ANSWER

            Answered 2021-Mar-03 at 11:54

            I was able to get all of the drawing (creating the grid and the text) down to 4-5ms by:

            • Caching values where possible (Random, StringFormat, Math.Pow)
            • Using ArrayPool for scratch buffer
            • Using the DrawString overload accepting a StringFormat with the following options:
              • Alignment and LineAlignment for centering (in lieu of manually calculating)
              • FormatFlags and Trimming options that disable things like overflow/wrapping since we are just writing small numbers (this had an impact, though negligible)
            • Using a custom Font from the GenericMonospace font family instead of SystemFonts.DefaultFont
              • This shaved off ~15ms
            • Fiddling with various Graphics options, such as TextRenderingHint and SmoothingMode
              • I got varying results so you may want to fiddle some more
            • An array of Color and the ToArgb function to create an int representing the 4x bytes of the pixel's color
            • Using LockBits, (semi-)unsafe code and Span to
              • Fill a buffer representing 1px high and size * countpx wide (the entire image width) with the int representing the ARGB values of the random colors
              • Copy that buffer size times (now representing an entire square in height)
              • Rinse/Repeat
              • unsafe was required to create a Span<> from the locked bit's Scan0 pointer
            • Finally, using GDI/native to draw the text over the graphic

            I was then able to shave a little bit of time off of the actual saving process by using the Image.Save(Stream) overload. I used a FileStream with a custom buffer-size of 16kb (over the default 4kb) which seemed to be the sweet spot. This brought the total end-to-end time down to around 40ms (on my machine).

            Source https://stackoverflow.com/questions/66241394

            QUESTION

            Libgdx not resolving collisions
            Asked 2020-Dec-15 at 07:22

            I am relatively new to libgdx and only started using it about a week ago. I am now facing a problem with my Box2D dynamic bodies. They render but are unable to interact with each other(they are affected by force applied to them though). I created those bodies using the free editor on GitHub. I've been struggling with this and I cant seem to see what is wrong.

            Here are all my classes:

            ...

            ANSWER

            Answered 2020-Dec-15 at 01:18

            You aren't setting collision masks which specify what collides with what i.e.

            Source https://stackoverflow.com/questions/65282958

            QUESTION

            LibGDX: Particle in html project
            Asked 2020-Oct-26 at 10:07

            In desktop and Android is Ok but in Html not work and freezing in this line:

            ...

            ANSWER

            Answered 2020-Oct-26 at 10:07

            The js console gives you an error message.

            Probably you are using a pre-1.9.10 particle effect with libgdx >= 1.9.10. The file format was changed, and while it was made backwards compatible on JVM platforms, this was not possible on HTML. You have to load and save the effect with the particle editor to solve this.

            Source https://stackoverflow.com/questions/64530238

            QUESTION

            How do I get a complete animation loop in one keystroke?
            Asked 2020-Oct-02 at 07:51

            What do I need to fix so that a single keystroke plays one full animation loop?

            Creating animation object:

            ...

            ANSWER

            Answered 2020-Oct-02 at 07:51

            The Animation class provided by LibGDX includes an .isAnimationFinished() function. This will return a boolean indicating when the animation has finished playing.

            In your case, I assume you're updating your elapsedTime variable in your update() function. So you can do something like:

            Source https://stackoverflow.com/questions/64083251

            QUESTION

            How to read Bevy events without consuming them?
            Asked 2020-Aug-31 at 17:25

            I am currently trying to use events to signal when the character jumps in my Bevy game. I want the system that handles player inputs to send a JumpedEvent which can then be received by other systems to perform the appropriate actions (set the correct player animations, velocity, sound, etc.) but the first system to read the event consumes it.

            Does Bevy provide a way to read events without consuming them?

            Here is my current code:

            ...

            ANSWER

            Answered 2020-Aug-31 at 17:25

            I just realized what I was doing wrong. I was using a single global resource EventReader to listen to the JumpedEvent instances being sent. Each EventReader only reads each event a single time. What I needed to do instead was to have an individual EventReader for each system that needed to listen for the event. I did this by using Local EventReaders for each system that needed to listen for the event. See below the modified code:

            Source https://stackoverflow.com/questions/63675140

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install TextureAtlas

            You can download it from GitHub.
            You can use TextureAtlas like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/operasoftware/TextureAtlas.git

          • CLI

            gh repo clone operasoftware/TextureAtlas

          • sshUrl

            git@github.com:operasoftware/TextureAtlas.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Game Engine Libraries

            godot

            by godotengine

            phaser

            by photonstorm

            libgdx

            by libgdx

            aseprite

            by aseprite

            Babylon.js

            by BabylonJS

            Try Top Libraries by operasoftware

            ssh-key-authority

            by operasoftwarePHP

            Emberwind

            by operasoftwareJavaScript

            dns-ui

            by operasoftwarePHP

            dragonfly

            by operasoftwareJavaScript

            operaprestodriver

            by operasoftwareJava