Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

zsevic/invert-rgb

Repository files navigation

invert-rgb

inverts color of the given DOM element

supported color formats
  • Hexadecimal #f0f, #ff00ff
  • RGB rgb(255, 255, 255)
  • RGBA rgba(0, 0, 0, 0.5)
  • HSL hsl(120, 100%, 50%) /* green */
  • HSLA hsla(120, 100%, 50%, 0.3) /* green with opacity */
  • Predefined/Cross-browser color names red, green, blue

Installation

npm install invert-rgb

Usage

const { invertRgb } = require('invert-rgb')
let element = document.getElementById('#test') 
invertRgb(element, 'border-color') /* red -> rgb(255, 0, 0) -> rgb(0, 255, 255) */ 
invertRgb(element, 'background-color') /* rgb(23, 128, 255) -> rgb(232, 127, 0) */ 
invertRgb(element, 'color') /* #abc -> rgb(170, 187, 204) -> rgb(85, 68, 51) */ 

Demo

before

before

after

after

Setup for demo

npm install
webpack