interpolate-lab gives the same result as RGB interpolate (rgb2xyz/xyz2rgb scale 0-1 channels by 255)
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
调研方向
从 src/style-spec/util/color_spaces.ts 开始,追踪 Color 通道值经过 rgb2xyz 和 xyz2rgb 的过程;issue 指出该转换应用了不必要的 255 倍缩放。检查 issue 中提到的色彩空间 fixtures,并更新反映当前输出的 fixtures。完成标准是 repro 产生预期的 Lab 和 HCL 值,且没有负通道值。
由索引模型根据 Issue 内容生成。
描述
mapbox-gl-js version
style-spec only: @mapbox/mapbox-gl-style-spec 14.34.2 (same code on main 1f3879d)
Browser and version
Not browser specific (Node v26.13.0)
Expected behavior
interpolate-lab and interpolate-hcl interpolate in CIELAB/HCL. For the repro below, MapLibre's style spec (26.5.1, which fixed the same code in maplibre/maplibre-style-spec#94) gives:
lab black->white: [ 0.4663, 0.4663, 0.4663, 1 ]
lab red->blue: [ 0.7568, 0, 0.534, 1 ]
hcl red->blue: [ 0.9606, 0, 0.5259, 1 ]
(d3-interpolate gives the same values to 8-bit precision.)
Actual behavior
lab black->white: [ 0.5, 0.5, 0.5, 1 ]
rgb black->white: [ 0.5, 0.5, 0.5, 1 ]
lab red->blue: [ 0.5, 0, 0.5, 1 ]
hcl red->blue: [ 0.7783, -0.0837, 0.5091, 1 ]
interpolate-lab is identical to interpolate, and interpolate-hcl produces a negative channel (#10054).
Link to the demonstration
Not applicable: reproduced with the style-spec package in Node.
Steps to trigger the unexpected behavior
const { expression } = require("@mapbox/mapbox-gl-style-spec");
const spec = { type: "color", "property-type": "data-driven", expression: { interpolated: true, parameters: ["zoom", "feature"] } };
const ev = (e) => {
const c = expression.createExpression(e, spec).value.evaluate({ zoom: 0 }, { properties: {} });
return [c.r, c.g, c.b, c.a].map((v) => +v.toFixed(4));
};
console.log("lab black->white:", ev(["interpolate-lab", ["linear"], 0.5, 0, "black", 1, "white"]));
console.log("rgb black->white:", ev(["interpolate", ["linear"], 0.5, 0, "black", 1, "white"]));
console.log("lab red->blue:", ev(["interpolate-lab", ["linear"], 0.5, 0, "red", 1, "blue"]));
console.log("hcl red->blue:", ev(["interpolate-hcl", ["linear"], 0.5, 0, "red", 1, "blue"]));
src/style-spec/util/color_spaces.ts has x /= 255 in rgb2xyz and 255 * (...) in xyz2rgb, but Color channels are in [0, 1]. The values therefore always fall in the linear segments of the sRGB and Lab transfer functions. Removing the 255 factor in both places fixes it (fixtures generated with the current code would need updating).
Relevant log output
Nothing beyond the output shown in the steps above.
Credit: https://ucsbplse.github.io/
- 主要语言
- TypeScript
- 星标
- 12.5k
- 派生
- 2.4k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
mapbox/mapbox-gl-js 的其他 Issue
-
bug :lady_beetle: performance :zap:
难度 2/5 1-3 小时 新手友好度 82/100
mapbox/mapbox-gl-js#13752 · 1 条评论 ·
-
TypeError: Cannot read properties of undefined (reading 'get') when a map is removed while a color-theme LUT is decoding可能已有人在做 @Piyush495 于 36 天前认领。 未关闭auto-triaged bug :lady_beetle:
难度 2/5 1-3 小时 新手友好度 82/100
mapbox/mapbox-gl-js#13737 · 1 条评论 ·
-
auto-triaged bug :lady_beetle:
难度 2/5 1-3 小时 新手友好度 84/100
mapbox/mapbox-gl-js#13723 · 2 条评论 ·
-
auto-triaged bug :lady_beetle:
难度 1/5 1 小时以内 新手友好度 86/100
mapbox/mapbox-gl-js#13717 ·
-
>= v3.21 Symbol layer without feature-state expression crash the map可能已有人在做 @liueric-dev 于 77 天前认领。 未关闭auto-triaged bug :lady_beetle:
难度 2/5 1-3 小时 新手友好度 74/100
mapbox/mapbox-gl-js#13714 · 1 个 reaction ·
查看 mapbox/mapbox-gl-js 的全部 Issue
相似的 Issue
-
idea-scout idea:453
难度 2/5 1-3 小时 新手友好度 83/100
jeanibarz/agent-notebook#453 ·
维护者通常 1 天内回复
-
level/task
难度 1/5 1 小时以内 新手友好度 95/100
wazuh/wazuh-dashboard-plugins#9642 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 91/100
unicef/adt-studio#1112 ·
维护者通常 2 天内回复
-
feature request good first issue
难度 2/5 1-3 小时 新手友好度 88/100
TabularisDB/tabularis#1513 ·
维护者通常 2 天内回复
-
难度 1/5 1 小时以内 新手友好度 75/100