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

Fix color-bleeding issues (all flags) #18

Merged
merged 1 commit into from
Feb 6, 2021

Conversation

climech
Copy link
Collaborator

@climech climech commented Feb 2, 2021

Fix color-bleeding issues (all flags)

This updates all 276 icons to remove (hopefully) all color-bleeding artifacts, both at the outer edges and inside. It was done by squaring all the icons, overlapping the shapes where needed, and finally applying a circular mask to all files using a custom script.

The artifacts were particularly visible on dark backgrounds at lower resolutions, e.g.:

<mask> was chosen over <clipPath> because the former results in slightly smaller file sizes (exactly 1 byte smaller 🙃).

The icons now follow a predictable structure:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
  <mask id="m">
    <circle cx="256" cy="256" r="256" fill="#fff"/>
  </mask>
  <g mask="url(#m)">
    <!-- masked contents -->
  </g>
</svg>

This also applies to flags with uniformly-colored edges such as jp.svg, where the mask doesn't make any difference as far as fixing any artifacts. It does however make the icons easier to work with programmatically, and the overall size difference after the update is very small (+1.6%).

Because the shapes invariably conform to a square now, it becomes possible to change the shape of the mask to something else, e.g. a square with rounded corners:

<mask id="m">
  <rect width="512" height="512" rx="25%" fill="#fff"/>
</mask>

Size difference

$ du -sb flags/ flags_updated/
196283 flags/
199332 flags_updated/

Minor changes

  • mh: make stripes converge on viewbox corner
  • as: snap triangle corners to viewbox corners
  • bh: make the "teeth" even
  • er: snap triangle corners to viewbox corners

These flags were found to be slightly malformed (not perfectly circular) which is now fixed:

  • bq-se
  • bt
  • cx
  • it-82
  • pg

The commit updates all 276 icons to remove (hopefully) all color-bleeding
artifacts, both at the outer edges and inside. This was achieved by squaring
all the icons, overlapping the shapes where needed, and finally applying a
circular mask to all files using a custom script.
@HatScripts HatScripts added enhancement New feature or request good first issue Good for newcomers labels Feb 2, 2021
@HatScripts
Copy link
Owner

Wow, this looks utterly amazing! How long did all this take you? That build script looks awesome too, and all the added documentation to go along with it. Seriously cool!

I've looked through the minor changes too and they all look to be good and up to scratch. I'll have a peruse through the full list of flags when I'm able to and report back to you. 😄

@climech
Copy link
Collaborator Author

climech commented Feb 2, 2021

Sure thing, glad you like it!

It took me about a week, and I became super-proficient at Inkscape keyboard shortcuts in the process 😄. I really wanted to use the flags in one of my projects, but the rendering artifacts were a big itch for me 😅

Edit: Thanks for the invite btw!

@HatScripts HatScripts merged commit 2225d10 into HatScripts:master Feb 6, 2021
@HatScripts
Copy link
Owner

It took me about a week, and I became super-proficient at Inkscape keyboard shortcuts in the process 😄. I really wanted to use the flags in one of my projects, but the rendering artifacts were a big itch for me 😅

Ah I see, that makes sense. They were a big itch for a lot of people it seemed, haha. Thank you once again for your awesome contribution to the repo. Merged 😄🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants