GithubHelp home page GithubHelp logo

doc22940 / tints-and-shades Goto Github PK

View Code? Open in Web Editor NEW

This project forked from edelstone/tints-and-shades

1.0 0.0 0.0 9.9 MB

๐ŸŒˆ Display tints and shades of a given hex color in 10% increments.

Home Page: https://maketintsandshades.com

CSS 31.44% HTML 48.64% JavaScript 19.92%

tints-and-shades's Introduction

ย Tint & Shade Generator

What is the Tint & Shade Generator?

The purpose of this tool is to accurately produce tints (lighter variants) and shades (darker variants) of a given hex color in 10% increments.

Why is this tool unique?

It takes the math seriously. In my experience similar tools get the calculation incorrect due to rounding errors or other inconsistencies.

Testing shows that the output matches Chrome DevTools' calculation method as well as the Sass tint and shade functions.

When would I use this?

It's best used when you already have some base colors but would like complimentary colors for gradients, borders, backgrounds, shadows or other elements.

This is useful for designers who may be communicating color intent to developers who use Sass or PostCSS in their builds. It's also a solid way to quickly preview what tints and shades look like for a base color you may be considering for your design.

Calculation method

The given hex color is first converted to RGB. Then each component of the RGB color has the following calculation performed on it, respectively.

  • Tints: New value = current value + ((255 - current value) x tint factor)
  • Shades: New value = current value x shade factor

The new value is rounded if necessary, and then converted back to hex for display.

Example calculation

Let's say we want tints and shades of Rebecca Purple, #663399.

10% tint

  1. #663399 is converted to the RGB equivalent of 102, 51, 153
  2. R: 102 + ((255 - 102) x .1) = 117.3, rounded to 117
  3. G: 51 + ((255 - 51) x .1) = 71.4, rounded to 71
  4. B: 153 + ((255 - 153) x .1) = 163.2, rounded to 163
  5. RGB 117, 71, 163 is converted to the hex equivalent of #7547a3

10% shade

  1. #663399 is converted to the RGB equivalent of 102, 51, 153
  2. R: 102 x .9 = 91.8, rounded to 92
  3. G: 51 x .9 = 45.9, rounded to 46
  4. B: 153 x .9 = 137.7, rounded to 138
  5. RGB 92, 46, 138 is converted to the hex equivalent of #5c2e8a

Feedback and contributing

This project is open source and I'd love your help!

If you notice a bug or want a feature added please file an issue on GitHub. If you don't have an account there, just email me the details.

If you're a developer and want to help with the project, please comment on open issues or create a new one and communicate your intentions. Once we agree on a path forward you can just make a pull request and take it to the finish line.

Support this project

The Tint & Shade Generator will always be free but your support is greatly appreciated.

Credits

Michael Edelstone designed and organized the project with big-time assistance from Nick Wing on the color scripts.

Many thanks to Joel Carr, Sebastian Gutierrez, Tim Scalzo, Aman Agarwal, and Aleksandr Hovhannisyan for their valuable contributions.

Fine print

tints-and-shades's People

Contributors

aleksandrhovhannisyan avatar amanagarwal041 avatar edelstone avatar joelcarr avatar pepas24 avatar tjscalzo avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.