Image Layer improvements: repetition, subrects, and scaling
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 12.9k
- Forks
- 2k
- Avg merge
- 4h 27m
- Merged PRs (30d)
- 8
Description
Although Image Layers aren't a major feature of Tiled and bjorn has expressed reluctance to do anything more with them, I think they have a lot of potential for things that don't make as much sense with Tile and Object layers.
Although it's true that the job Image Layers can do currently can be done by Tile Objects within Tiled, object layers seem like overkill and require more work to set up to do the same task. Parsers can also optimize the use of Image Layers in ways that they can't with Tile Objects, since Objects are generally assumed to be dynamic, whereas Image Layers can be treated as a special case of Tile Layers that have their own tile size and a single tile in them.
A couple of improvements to Image Layers would make them more than worthy of their place as a separate layer type in Tiled:
-
One feature request that's come up multiple times on Discord and here is the ability to set an Image Layer to repeat (tile) in X, Y, or both. This would make them very useful for background art that isn't made out of tiles or has an unusual size. This is especially useful for maps that use parallax. The automatic repetition of a large background image is already a common technique in 2D games, and Image Layers would allow Tiled to represent this in a way very similar to how game engines do it, which is different from a tile layer in that the repetitions are generated at runtime and don't exist in the layer data.
Added in 0e7f813 -
A feature that only I seem to have requested: the ability to set a subrect of the chosen image to use, instead of always using the entire image. This would allow Image Layers to be used with atlases or to use slightly different portions of the same image (e.g. to compensate for parallax in neighbouring maps). When/if spritesheet tilesets (#2863) are implemented, Tile Objects will be able to do this too, but as mentioned above, I don't believe Tile Objects are as good a solution for things like this as Image Layers are.
-
An occasionally requested feature: Scale the image in the Image Layer, via X and Y scale factor properties. Currently, the only way to have a scaled background image, such as one might want as a reference, is to put it into a Tileset (typically a Collection of Images) and place it as a Tile Object on some special reference Object Layer, where it can then be scaled (with
Ctrlto maintain the aspect ratio, if need be). For things like reference images, it would be much simpler to use an Image Layer. Of course, this feature would benefit people using Image Layers for in-game art as well. (Edit: Apparently there's already an issue open for this, #1306)
Image Layers are useful in their own right and aren't just a worse Tile Object layer, and they deserve some love.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Image Layer implementation and the editor paths for image selection and display; no files or tests are named. Read issue #1306 before taking on scaling, and verify the remaining subrect and scaling behaviors against the requested use cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- desktop, game-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100