All problems

Translucent groups become too dark in the glass overlay preview

Level 3 · node · Correctness · Repeated conversion of premultiplied color at a hierarchical compositing boundary

Scenario

A fictional glass ornament editor previews overlapping colors as a single RGBA pixel. Color pieces can be grouped, and each group has adjustable opacity. Individual pieces and opaque groups look correct, but translucent or nested groups appear darker than expected. Trace the color representation and group-processing contract between the public preview, recursive renderer, and pixel compositing functions.

Requirements

preview(nodes) returns the final [r,g,b,a] for nodes ordered from bottom to top. All channels and opacity range from 0 to 1. A paint node has the form {kind:'paint',rgba} with straight RGBA input, and a group node has the form {kind:'group',opacity,children}. Composite children in the same order on a transparent background first, apply group opacity once to that result, then composite it onto the outer layers. Use source-over compositing, premultiplied RGB internally, and straight RGBA for the public result. Return [0,0,0,0] when alpha is zero. Preserve the public interface and recursive group structure.

Acceptance criteria

  • Individual translucent pieces and opaque groups produce the same source-over result for the same ordering.
  • Reducing group opacity over a transparent background preserves the group's straight RGB color proportions.
  • A translucent group over an opaque background blends with the background according to alpha.
  • Nested group opacity is applied once per level, and empty or fully transparent groups do not affect other layers.