Coder Social home page Coder Social logo

virtualvivek / hexalpha Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 69 KB

This Light weight library provides opacity to #Hexadecimal Color values dynamically, written in pure javascript.It takes hexadecimal color as both a hex value or a css property variable with an alpha ie 0-9 value and provides alpha transparent color .

License: MIT License

JavaScript 100.00%
css hexadecimal color-scheme cssvariables hexadecimal-color alpha converter color-converter transparency alpha-in-hexadecimal-color

hexalpha's Introduction

A CSS library which provides opacity to Hexadecimal color values, it renders #hex color value to apply opacity at runtime

Web Library Size License: Apache Release

Usage

  1. From one color variable to another :

​
​
HexAlphaTo('--App_Color','0.5','--Alpha_Color');

  1. From a Hexadecimal color to a color variable :

​
​
HexAlphaTo('#018574','0.7','--Alpha_Color2');

  1. Assigning using color variable to a js variable :

​
​
let alphaColor = HexAlpha('--App_Color4','0.4');
document.getElementById("Img4Alpha").style.background=alphaColor;

  1. Assigning using Hexadecimal color to a js variable :

​
​
let alphaColor5 = HexAlpha('#C30052','0.5');
document.getElementById("Img5Alpha").style.background=alphaColor5;

How to start

Install it

Include library/HexAlpha.js in your target html file.

<script src='https://github.com/virtualvivek/HexAlpha/library/HexAlpha.js'></script>

Documentation

Function Results Arguments
A. HexAlphaTo('Color1','Alpha','Color2'); Takes Color1 apply Alpha and assign to Color2 3
B. HexAlpha('Color2','Alpha'); Returns a Hex Color from Color2 with an Alpha 2

A. about HexAlphaTo() :

HexAlphaTo( 'Color1' , 'Alpha' , 'Color2' );

A.1- Color1 -

'Color1' Type Example
:root { --Color; } Property variable var() HexAlphaTo('--Color','0.5','--Alpha_Color');
#16ab9c Hexadecimal Color HexAlphaTo('#16ab9c','0.7','--Alpha_Color');

A.2- Alpha (transparency factor) -

'Alpha' Opacity
1 100%
0.9 90%
0.8 80%
.. ..%
0.1 10%
0 0%

A.3- Color2 -

'Color2' Type Example
:root { --A_Color; } Property variable var() HexAlphaTo('--Color','0.5','--A_Color');

B. about HexAlpha() :

HexAlpha( 'Color' , 'Alpha' );

B.1- Color -

'Color' Type Example
:root { --Color; } Property variable var() HexAlpha('--Color','0.5');
#16ab9c Hexadecimal Color HexAlphaTo('#16ab9c','0.7');

B.2- Alpha (transparency factor) -

'Alpha' Opacity
1 100%
0.9 90%
0.8 80%
.. ..%
0.1 10%
0 0%

Browser Compatibility

Chrome Firefox Edge Safari Opera
Latest ✔ Latest ✔ Latest ✔ 9.1+ ✔ Latest ✔

License

HexAlpha Library is licensed under MIT license. View license.
Copyright (c) 2020-21 Vivek Verma .

hexalpha's People

Contributors

virtualvivek avatar

Stargazers

 avatar  avatar

Watchers

 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.