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

Support tiled 9-slice scaling (in addition to the stretched 9-slice scaling we already support) #14609

Open
Lazerbeak12345 opened this issue May 4, 2024 · 1 comment
Labels
Feature request Issues that request the addition or enhancement of a feature Formspec @ Script API

Comments

@Lazerbeak12345
Copy link

Lazerbeak12345 commented May 4, 2024

Problem

In the latest version of minetest (in fact, since formspec version 2) there is support for 9-slice image scaling.

As is alluded to on the wikipedia page that the documentation refrences, there's 2 ways of handling the image.

(ascii demo for example)

1 | 2 | 3
4 | 5 | 6
7 | 8 | 9

Minetest only supports stretched 9-tiles. This means that if you do some pixel art in 2 4 5 6 or 8, that pixel art will be stretched. This limits the types of pixel art that can be made for formspecs & etc.

Solutions

Provide a way, for all 9-tile systems, to indicate to minetest the following:

  • Should tiles 2 5 6 and 8 be stretched?
  • What about the last tile? Crop it or stretch it (What if the content space is not divisible by the size of 5?)?

This could look like:

background9[<X>,<Y>;<W>,<H>;<texture name>;<auto_clip>;<middle>;<repeat>]

  • 9-sliced background. See https://en.wikipedia.org/wiki/9-slice_scaling
  • Middle is a rect which defines the middle of the 9-slice.
    • x - The middle will be x pixels from all sides.
    • x,y - The middle will be x pixels from the horizontal and y from the vertical.
    • x,y,x2,y2 - The middle will start at x,y, and end at x2, y2. Negative x2 and y2 values will be added to the width and height of the texture, allowing it to be used as the distance from the far end.
    • All numbers in middle are integers.
      -If auto_clip is true, the background is clipped to the formspec size (x and y are used as offset values, w and h are ignored)
  • repeat may be exactly one of these values, or two (seperated by a comma). If there's two values, the first is the X and the second is the Y dementions
    • stretch ....
    • repeat ....
    • round ....
    • space ....
  • Available since formspec version ???

Alternatives

Keep it as-is?

Additional context

A popular CC-BY-4.0 asset pack on itchio that serves as an example of textures that don't (currently) work in minetest is this one (i'm not affiliated): https://crusenho.itch.io/complete-ui-essential-pack

The behavior I'm requesting is possible in CSS-3 via border-image-repeat, if an example is needed.

@Lazerbeak12345 Lazerbeak12345 added the Feature request Issues that request the addition or enhancement of a feature label May 4, 2024
@Lazerbeak12345 Lazerbeak12345 changed the title Support tiled 9-slice scaling Support tiled 9-slice scaling (in addition to the stretched 9-slice scaling we already support) May 4, 2024
@Desour
Copy link
Member

Desour commented May 4, 2024

Related: #10497

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature request Issues that request the addition or enhancement of a feature Formspec @ Script API
Projects
None yet
Development

No branches or pull requests

2 participants