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

Nine-part resizable images #4143

Closed
lucaswoj opened this issue Feb 1, 2017 · 6 comments
Closed

Nine-part resizable images #4143

lucaswoj opened this issue Feb 1, 2017 · 6 comments
Labels
cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.) feature 🍏

Comments

@lucaswoj
Copy link
Contributor

lucaswoj commented Feb 1, 2017

From @1ec5 on November 26, 2016 20:1

As part of moving style images inline (#220), we should add support for resizable images, also known as border images in CSS and on Qt, stretchable images on iOS, nine-part images on macOS, and nine-patch images on Android.

In combination with the icon-text-fit property added in #461, a resizable image would automatically resize to fit a label, but we’d be able to avoid distorting its corners or any outline baked into it. The “corner” parts of the image would remain as-is regardless of the image’s rendered size, while “edge” parts of the image could be either stretched or repeated, depending on the use case.

Just to kick things off, the proposed syntax below is loosely based on CSS3’s border-image properties:

{
  "de-federal": {
    "width": 6,
    "height": 6,
    "x": 824,
    "y": 642,
    "pixelRatio": 2,
    "slice": [5, 5, 5, 5],
    "repeat": ["stretch", "repeat"]
  }
}

This feature would allow styles such as Mapbox Streets to consolidate several style images that currently differ only in the number of digits that fit within them, and these images could be much smaller, making the overall sprite sheet more compact. Some reflen-specific images would still be required for exotic shapes, such as the Interstate and U.S. Route shields.

/cc @mapbox/cartography-cats @mapbox/gl

Copied from original issue: mapbox/mapbox-gl-style-spec#581

@lucaswoj
Copy link
Contributor Author

lucaswoj commented Feb 1, 2017

From @cammace on November 28, 2016 17:4

I've been running into this distortion issue with the images i've been adding to the map during runtime. It would be great to also be able to use icon-color on the nine-patch images.

@lucaswoj
Copy link
Contributor Author

lucaswoj commented Feb 1, 2017

From @kkaefer on November 29, 2016 13:25

Might be subsumed by mapbox/mapbox-gl-style-spec#222?

@lucaswoj
Copy link
Contributor Author

lucaswoj commented Feb 1, 2017

From @1ec5 on November 29, 2016 22:39

Not necessarily. While both nine-part images and a truly scalable image format have some overlap of use cases (especially for highway shields), there’s a lot of good tooling and native platform support around nine-part images that likely won’t be compatible with any custom image format we develop. So nine-part images would be desirable for better platform integration at least.

@1ec5 1ec5 added the cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.) label Feb 3, 2017
@1ec5
Copy link
Contributor

1ec5 commented Aug 18, 2018

The current road name label in the navigation SDK could take advantage of this option to display a road name in a rounded rectangle. The iOS implementation uses a native view (mapbox/mapbox-navigation-ios#1576), but runtime styling would be desirable for the Android implementation (mapbox/mapbox-navigation-android#1222) for various reasons, so this feature would allow us to achieve the same effect on both platforms. The current road name label is never scaled, so a vector icon wouldn’t be an improvement over a nine-part image.

shield-280-junipero-serra-fwy

@andrewharvey
Copy link
Collaborator

for people tracking this issue, it continues at #8917

@kkaefer should we close this issue in lieu of #8917 ?

@ryanhamley
Copy link
Contributor

Closed by #8997 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.) feature 🍏
Projects
None yet
Development

No branches or pull requests

5 participants