javascript : String strColor.toRGBA()
javascript : String strColor.toRGBA()
Target:
Applicable with String Data Type.
Description :
convert string color to object { } having attributes. r,g,b,a,value and hex.
Note: return javascript object.
{ }.r = Red Value
{ }.g = Green Value
{ }.b = Blue Value
{ }.a = Alpha Value
{ }.value = rgba string
{ }.hex = Hexa color string
Syntax:
String.toRGBA()
Usase:
- "red".toRGBA()
It return object { r: 255, g: 0, b: 0, a: 1, value: "rgb(255, 0, 0)", hex : "#ff0000"} - "lightblue".toRGBA()
It return object { r: 173, g: 216, b: 230, a: 1, value: "rgb(173, 216, 230)", hex : "#add8e6"} - "rgb(128,128,55)".toRGBA()
It return object { r: 128, g: 128, b: 55, a: 1, value: "rgb(128, 128, 55)", hex : "#808037"} - "rgba(255,128,60,0.6)".toRGBA()
It return object { r: 255, g: 128, b: 60, a: 0.6, value: "rgba(255, 128, 60, 0.6)", hex : "#ff803c99"} - "#2abcde".toRGBA()
It return object { r: 42, g: 188, b: 222, a: 1, value: "rgb(42, 188, 222)", hex : "#2abcde"} - "#abcdef2a".toRGBA()
It return object { r: 171, g: 205, b: 239, a: 0.165, value: "rgba(171, 205, 239, 0.165)", hex : "#abcdef2a"} - "invalidColorString".toRGBA()
It return object { r: 0, g: 0, b: 0, a: 0, value: "rgba(0, 0, 0, 0)", hex : "#00000000"}
Download MYJS.js
MyJs is a collection of java script extension methods that enhances the JavaScript objects, class object, DOM element, domElementsCollections, Date, String, Number and other data type.
Include in you project landing page (master page) and it will extends your DOM and JavaScript Objects.
Comments
Post a Comment