Skip to content

Let a color callback decline a sample #30

Description

@ze2j

Proposal

Problem

color_callback is all or nothing. Once assigned, it sets the color of every
sample of the overlay. There is no way to color a few samples and leave the rest
to the default series color.

Returning the series color for the other samples does not work either. The
renderer uses a resolved copy of the style, built after the theme is applied, and
the user has no access to it.

Every other per-sample source can already decline. A color buffer entry declines
with NO_COLOR. alpha_callback, size_callback, and outline_width_callback
decline with a negative return. Color is the only one that cannot.

Proposal

Treat NO_COLOR returned by color_callback and outline_color_callback the
same way as an unset buffer entry: fall through to the next step.

Breaking change

NO_COLOR is Color(0, 0, 0, 0), so a callback that computes black at zero alpha
now declines instead of painting. The value is already useless: the alpha channel
of a returned color is overwritten by the resolved alpha, so such a sample paints
opaque black today, not transparent.

Migration is one line. Set the alpha channel to 1 before returning, which costs
nothing and puts the returned color out of reach of the sentinel.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions