Values from interpolate-hcl can be negative
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
**mapbox-gl-js version**: v1.12.0
**browser**: Node, Chrome
### Steps to Trigger Behavior
Create an expression using `interpolate-hcl` between `red` and `white`.
```
const {expression} = require('mapbox-gl/dist/style-spec')
expression.createExpression(['interpolate-hcl', ['linear'], 2 / 9, 0, 'red', 1, 'white'], {type: 'color'}).value.expression
```
Sometimes the values are negative. Perhaps this is due to floating point errors? I'm trying to create a map legend with 10 stops, so often the `label` value is 2/9, 4/9, etc.
### Link to Demonstration
https://jsbin.com/boxanun/edit?html,output
### Expected Behavior
Returned RGB values should be positive, in the range of `0..1`.
### Actual Behavior
RGB values can be negative
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 with the expression.createExpression entry point in mapbox-gl/dist/style-spec and reproduce the interpolate-hcl case using the provided Node or Chrome example. Trace the resulting RGB values and verify the behavior against the expected 0..1 range; the issue is done when the reported interpolation no longer returns negative RGB values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100