tiled icon indicating copy to clipboard operation
tiled copied to clipboard

Image Layer improvements: repetition, subrects, and scaling

Open eishiya opened this issue 2 years ago • 6 comments

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:

  • [x] 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 Ctrl to 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.

eishiya avatar Aug 10 '21 16:08 eishiya

I desperately need image layer scaling. It's very useful for bringing in a sketch of a map and then tracing over it.

Bryan-Legend avatar Aug 17 '22 19:08 Bryan-Legend

@Bryan-Legend For this purpose, you can add the sketch to an "Image Collection" tileset and place it as a tile object, since those can be resized. After resizing the tile object to the desired size, you could lock its layer to prevent selecting it by accident.

bjorn avatar Aug 18 '22 08:08 bjorn

Thanks! That's finally what I did. Doesn't seem like it would be too difficult to add scale or size properties to the image layer.

On Thu, Aug 18, 2022 at 2:09 AM Thorbjørn Lindeijer < @.***> wrote:

@Bryan-Legend https://github.com/Bryan-Legend For this purpose, you can add the sketch to an "Image Collection" tileset and place it as a tile object, since those can be resized. After resizing the tile object to the desired size, you could lock its layer to prevent selecting it by accident.

— Reply to this email directly, view it on GitHub https://github.com/mapeditor/tiled/issues/3114#issuecomment-1219168410, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHAUOGP7CZMWHCMLUK2E7DVZXVS5ANCNFSM5B4NWKZQ . You are receiving this because you were mentioned.Message ID: @.***>

Bryan-Legend avatar Aug 18 '22 15:08 Bryan-Legend

Doesn't seem like it would be too difficult to add scale or size properties to the image layer.

Sure, when not accompanied by any visual tools to scale them but instead just using a property, it's similar in scope to the addition of the repeat options. I'm personally not inclined to duplicate the functionality of tile objects though, which I think are better because they even have a visual resize tool. But of course, tile objects can't currently repeat, though that has also been requested.

bjorn avatar Aug 19 '22 10:08 bjorn

I'm personally not inclined to duplicate the functionality of tile objects though

Shall I repeat my spiel from the OP about how Tile Objects and Image Layers handle different needs and how Tile Objects are overkill for background layers? xP I also feel like you keep assuming that it's as quick and easy to create a Tile Object as an Image Layer, which is not the case: Tile Objects require both a layer and an object to be created, and they require a tile, which means a tileset must also be created that contains your reference/background image(s). Image Layers are a much better way to accomplish certain tasks, just like Tile Layers are a much better way to accomplish some tasks that could technically be accomplished with grid-aligned Tile Objects xP

eishiya avatar Aug 19 '22 12:08 eishiya