Skip to content

ColorExtensions: scale alpha, and blend toward a backdrop in the active color space #1295

Open

Description

What

DoxReloaded's UI drawers carry three Faded helpers that name no game type. Two are identical, and the third is a related operation:

  • WinDrawer.Faded(Color color, float opacity) and MapNodeDrawer.Faded(Color color, float opacity): color.a *= opacity; return color;
  • ButtonGlyphDrawer.Faded(Color color, float opacity, Color backdrop): Color.Lerp(backdrop, color, opacity), done on .linear values and converted back with .gamma when QualitySettings.activeColorSpace is Linear, keeping color.a.

A third copy of the first landed in a parallel change the same day, which is the duplication this ask would end. Found by DoxReloaded PR #1302's lint for general-purpose code.

Ask

In Core/Extension/ColorExtensions.cs:

  • Color WithAlpha(this Color color, float alpha) and Color ScaleAlpha(this Color color, float factor).
  • Color BlendOver(this Color color, Color backdrop, float opacity), which lerps in linear space when the project's active color space is Linear and keeps color.a.

Evidence

3.7.2's ColorExtensions has ToHex, GetAverageColor and GetComplement, and no alpha or blend helper.

DISCLOSURE: LLM-GENERATED TEXT

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions