mapbox / mapbox/mapbox-gl-js

stretchX and stretchY causes sdf icons to be deformed

Open
#10,026 4 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug :lady_beetle:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

**mapbox-gl-js version**: 1.12.0

**browser**: Chrome 85

### Steps to Trigger Behavior

1. Add an sdf image with `stretchX` or `stretchY`
2. Add a symbol layer using the sdf image as an icon

### Link to Demonstration

[https://jsfiddle.net/px6vkwm2/](https://jsfiddle.net/px6vkwm2/)

### Expected Behavior

I'd like to use `icon-color` to dynamically change the color of an icon image. This requires the icon image to be `sdf: true`. I'd also like to set stretchable areas of the icon image so it gracefully scales around the symbol text.

Below is a sample of what I'm trying to achieve. This was not done in Mapbox GL JS but it seems like all the features are here. I was hoping I could combine `icon-color`, `stretchX`, `stretchY`, `icon-text-fit`, and `icon-anchor` to allow dynamic text and color for point labels all using the same `icon-image`. Unfortunately I've ran into this issue with sdf and stretchable areas and #10025.

![image](https://user-images.githubusercontent.com/814812/95512899-1e5f7100-097f-11eb-85fc-630391dc2ee5.png)

### Actual Behavior

The icon image is deformed

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the deformation in the linked JSFiddle using an SDF image with stretchX or stretchY in a symbol layer. Compare the behavior with and without SDF while combining icon-color, icon-text-fit, and icon-anchor; done means stretchable SDF icons scale without deformation and retain dynamic coloring.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
computer-graphics, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.