CSS effects guides

Check a CSS filter on a black status icon

·

A status icon is already saved as a black image. Match it to harbor green with CSS and compare the painted color with the target before applying it to the interface.

HEX Color to CSS Filter

Fit the black reference to harbor green

Select Harbor green. The target is #39745d, which is RGB 57, 116, 93. The workspace fits the CSS values against the opaque black source and displays the target and CSS preview.

The model for this preset gives #39745d. In the tested Chromium canvas the measured pixel was #38725b, or RGB 56, 114, 91. The largest absolute channel difference was 2. Compare the measured value in your browser.

W3C Filter Effects Module Level 1, filter functionsWHATWG Canvas 2D pixel manipulation

Apply the copied declaration to the icon

Select Copy CSS filter and paste the full declaration into the icon's CSS rule. Keep the filter functions in their generated order. Each acts on the result of the previous function.

Review the center of a filled part of the icon first. Edge pixels can include transparency, which blends with the background. Start with a black icon if you are comparing its filled area with the reference.

W3C Filter Effects Module Level 1, filter functions

Compare a gray target with the colored filter

Enter #808080 and select Generate CSS filter. The gray target needs only invert(50.196%) on the black reference. The colored preset uses additional transformations to change the balance between channels.

When a precise palette color is required, use the displayed channel difference to decide whether the rendered filter is close enough.

W3C Filter Effects Module Level 1, filter functionsWHATWG Canvas 2D pixel manipulation

Common questions

Is the error shown as a percentage?

It is a difference on the 0–255 channel scale. The tool reports the largest difference across red, green and blue.

Does the icon lose its transparent background?

The generated color functions keep the input alpha. An antialiased or translucent pixel still blends with the background.

Sources

Put it into practice.

Related guides