interpolate-lab gives the same result as RGB interpolate (rgb2xyz/xyz2rgb scale 0-1 channels by 255)

Đang mở Phù hợp với người mới
#13,751 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
backend, testing

Hướng nghiên cứu

Bắt đầu trong src/style-spec/util/color_spaces.ts và theo dõi luồng các giá trị kênh của Color qua rgb2xyz và xyz2rgb; issue cho biết phép chuyển đổi áp dụng hệ số tỷ lệ 255 không cần thiết. Kiểm tra các fixture không gian màu được nhắc đến trong issue và cập nhật những fixture phản ánh đầu ra hiện tại. Hoàn tất khi repro tạo ra các giá trị Lab và HCL mong đợi mà không có kênh âm.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

auto-triaged bug :lady_beetle:
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/

Ngôn ngữ chính
TypeScript
Star
12.5k
Fork
2.4k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của mapbox/mapbox-gl-js

Tất cả issue của mapbox/mapbox-gl-js

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.