Skip to content

[css-color-5] Remove special casing of 100% leftover from the color-mix() calculation algorithm #14014

@weinig

Description

@weinig

The color-mix() calculation algorithm currently special cases a leftover value of 100% (which happens if all the percentages were specified as 0%) in step 2:

  1. If leftover is 100%, return transparent black, converted to the specified interpolation.

We already have to handle the case of 0% values in the color-mix(), for cases where 0% is used but not for all the items, (e.g. color-mix(in srgb, red 0%, blue 0%, green 100%)), so the special casing should not be necessary to get a result. (NOTE: Currently, there is an issue with division by zero here, see #14013, so this is assuming we resolve that).

Removing step 2 would result in slightly different values, they would always be 100% transparent, due to 100% leftover translating to 0% alpha, but would no longer always be specifically transparent black.

The benefit of this, other than simplifying the algorithm, would be to remove a discontinuity when iteratively reducing the percentages (e.g. the difference between color-mix(in srgb, red 0.1%, blue 0.1%) and color-mix(in srgb, red 0%, blue 0%), and maintaining powerless/none values (e.g. color-mix(in srgb, color(srgb none 0 1) 0%, color(srgb none 1 0) 0%).

cc @svgeesus

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions