Giter VIP home page Giter VIP logo

prow.js's Introduction

prow.js

Miscellaneous color tools for the web developer.

Documentation

prow.convert.hexToRGB

Converts hex to sRGB Returns an array of the form [r,g,b] where r, g, and b are integers between 0 and 255

Example usage
prow.convert.hexToRGB("#fff"); // Returns [ 255, 255, 255 ]

Hex can be:

  • "fff"
  • "ffffff"
  • "#fff"
  • "#ffffff"
  • "0xffffff"

prow.convert.RGBToHex

Converts sRGB to hex where rgb is an array of the form [r,g,b] where r, g, and b are integers between 0 and 255 Returns a string of the form "#ffffff"

Example usage
prow.convert.RGBToHex([255, 255, 255]); // Returns #ffffff

prow.convert.RGBToLinearRGB

Converts sRGB to linear RGB where rgb is an array of the form [r,g,b] where r, g, and b are integers between 0 and 255 Returns an array of the form [r,g,b] where r, g, and b are decimals between 0 and 1

Example usage
prow.convert.RGBToLinearRGB([255, 255, 255]); 
// Returns [0.003676507324047436,​​​​​​​​​​ 0.004024717018496307,​​​​ 0.024157632448504756 ]​​​​​

prow.getRelativeLuminance

Returns a decimal value representing the relative luminance of the given color. Color must be an sRGB array of the form [r,g,b]

Example usage
prow.getRelativeLuminance([255, 255, 255]); // Returns 0.9873055935982454​​​​​

prow.getContrastRatio

Returns the contrast ratio of the two given colors in fractional form. Takes two parameters which must be sRGB arrays of the form [r,g,b]

Example usage
prow.getContrastRatio([255,253,255], [1, 1, 1]); // Returns ​​​​​20.620931688099795

prow.js's People

Contributors

ferndot avatar ronitshar 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.