Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[filter-effects] tint() function #533

Open
Secret-chest opened this issue Oct 5, 2023 · 1 comment
Open

[filter-effects] tint() function #533

Secret-chest opened this issue Oct 5, 2023 · 1 comment

Comments

@Secret-chest
Copy link

Secret-chest commented Oct 5, 2023

Link to the current spec.

Currently, webpage authors looking to change the image's colouring to a scale of a specific colour must combine the existing filters to approximate said colour or resort to overlays, JavaScript or other methods.

With this in mind, I propose a new filter function:

tint(map, amount)

where map is a <color> or <gradient> used to tint the image, and amount is a <number> or <percentage> used to blend the original with the filtered version, 1 being completely filtered, like it is with sepia().

  • If map is a <color>, then the image is converted to a greyscale and the dark end is mapped to map, while the light end is mapped to white, other levels being blended accordingly.
  • If map is a gradient, then the image is converted to a greyscale and each level is mapped to a level of the gradient.

Example

Photo taken by me and available on https://commons.wikimedia.org/wiki/File:Muntii_Retezat_06.jpg under CC BY-SA. Processing done with GIMP.

First image is input, second is output, processed using this hypothetical value:
filter: tint(linear-gradient(#0d7fb8, #ffe600), 100%)

original
gradient

@nt1m nt1m transferred this issue from w3c/csswg-drafts Oct 8, 2023
@karip
Copy link

karip commented Oct 11, 2023

There was already a proposal for recolor() shorthand, which looks quite similar to your tint() function. However, it doesn't have the gradient option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants