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

Invert dark favicons (#114) #222

Closed
wants to merge 4 commits into from
Closed

Conversation

mmktomato
Copy link
Contributor

@mmktomato mmktomato commented Dec 16, 2018

I've fixed #114 . I added an external library in order to detect dark favicon.
https://github.com/fast-average-color/fast-average-color

@mmktomato
Copy link
Contributor Author

Oops, I didn't notice that CI is failed. I'll fix it later.

@Croydon Croydon self-requested a review December 17, 2018 08:19
@Croydon Croydon assigned Croydon and mmktomato and unassigned Croydon Dec 17, 2018
@Croydon Croydon added this to the 0.13.0 milestone Dec 17, 2018
@Croydon Croydon added cat:accessibility Improvements for accessibility feat:themes feat:core labels Dec 17, 2018
@Croydon
Copy link
Owner

Croydon commented Dec 17, 2018

Thank you so much for working on this!

I have merged this via e901efc in the 0.13.0 branch and gave it a bit of fine tuning via dda4587 and 7f8d4d3

It is live now in the dev version. I want to use it for a few days in "real world browsing" before I merge it into master, but looks pretty good 👍

@mmktomato
Copy link
Contributor Author

Thanks for merging and refinement! Could you close this PR after you merge it into master?

@Croydon
Copy link
Owner

Croydon commented Dec 17, 2018

Could you close this PR after you merge it into master?

Yes, I will do this.

My first impression is, that it will need some further work. Likely some calculation of the contrast between the average icon color and the tab color to determinate if it should get inverted. Right now the Netflix logo is getting inverted even though it is (in my opinion) very noticeable and doesn't need to get inverted. Same with the YouTube icon, which would also get inverted when I wouldn't have changed the brightness threshold. I guess red icons in general are likely counted as dark, even when they would be easily see-able in the dark themes.

Also I guess I will make the inversion optional feature of some sort

@mmktomato
Copy link
Contributor Author

mmktomato commented Dec 17, 2018

I've pushed other commits to following branch.
https://github.com/mmktomato/vertical-tabs-reloaded/tree/invert-dark-favicons

763b3a1

Skips inversion when some errors occur.

b03cd49

Gives 'mode' param to FastAverageColor. 'precision' should give us precise result, I think.

4b82758

Uses rgb values to detect dark color instead of 'color.isDark'. I refer this StackOverflow.
https://stackoverflow.com/questions/13762864/image-dark-light-detection-client-sided-script

function setText(text, averageColor, id){
  if(averageColor[0] <= 80 && averageColor[1] <= 80 && averageColor[2] <= 80){
     document.getElementById(id).innerHTML = "<font color='#ffffff'>"+text+"</font>";
  }
  else if(averageColor[0] >= 150 && averageColor[1] >= 150 && averageColor[2] >= 150){
     document.getElementById(id).innerHTML = "<font color='#000000'>"+text+"</font>";
  } 
}

I put threshold value back to 128 because 'color.isDark' is no longer used.

e9c3b1a

Fixes list errors. ....I always fotget about lint 😓

inverted

What do you think these changes?

@mmktomato
Copy link
Contributor Author

https://github.com/mmktomato/vertical-tabs-reloaded/tree/invert-dark-favicons

It works good for me. I will recreate another pull request. So I will close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat:accessibility Improvements for accessibility feat:core feat:themes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants