Hex To RGBA Converter Online Tool
Có thể bạn quan tâm
This online Hex to RGBA converter tool helps you to convert one Hex color (base 16) into a RGBA color (base 10, with Opacity), and test the result color within the website.
the Color System used in HTML is also be written down as Hex number, from #000000 (pure black) to #FFFFFF (pure white). For example, #123456 means the Red is "12" (in range "00" to "FF"), the Green is "34", the Blue is "56". The Hex color system also support 3-digits color, for example, color #e1a is equivalent to #ee11aa.
The RGBA color ("R" stands for "Red", "G" stands for "Green", "B" stands for "Blue") is specified how much red, green and blue light are combined together, and what the overall opacity. The syntax is rgba(16,110,190,0.7).
Step 1: Get the hex number of each sub-color (Red, Green and Blue), and the opacity.
Step 2: Convert each hex number into decimal number.
Step 3: Write the RGBA Color result String in correct syntax.
Example 1: Convert Hex Color "#106ebe" (with opacity 80%) to RGBA Color (result is "rgba(16,110,190,0.8)"):
Step 1: | Hex Color "#106ebe": Red(0x10), Green(0x6e), Blue(0xbe) |
Step 2: | Red: (0x10)->(16), Green: (0x6e)->(110), Blue: (0xbe)->(190) |
Step 3: | Hex Color "#106ebe" opacity 80% -> rgba(16,110,190,0.8) |
Example 2: Convert Hex Color "#ea3" (with opacity 100%) to RGB Color (result is "rgba(238,170,51,1)"):
Step 1: | Hex Color "#ea3" -> "#eeaa33" |
Step 2: | Hex Color "#eeaa33": Red(0xee), Green(0xaa), Blue(0x33) |
Step 3: | Red: (0xee)->(238), Green: (0xaa)->(170), Blue: (0x33)->(51) |
Step 4: | Hex Color "#ea3", opacity 100% -> rgba(238,170,51,1) |
Wikipedia (Web colors): https://en.wikipedia.org/wiki/Web_colors
Wikipedia (RGBA color space): https://en.wikipedia.org/wiki/RGBA_color_space
import re def rgba_to_hex(rgba_color): rgb_color = re.search('\(.*\)', rgba_color).group(0).replace(' ', '').lstrip('(').rstrip(')') [r, g, b, o] = rgb_color.split(',') [r, g, b] = [int(x) for x in [r, g, b]] o = float(o) * 100 o = str(o) + '%' # check if in range 0~255 assert 0 <= r <= 255 assert 0 <= g <= 255 assert 0 <= b <= 255 r = hex(r).lstrip('0x') g = hex(g).lstrip('0x') b = hex(b).lstrip('0x') # re-write '7' to '07' r = (2 - len(r)) * '0' + r g = (2 - len(g)) * '0' + g b = (2 - len(b)) * '0' + b hex_color = '#' + r + g + b + ', with opacity:' + o return hex_color rgba_input = 'rgba(7,110,190,0.95)' hex_output = rgba_to_hex(rgba_input) print('Hex color result is:{0}'.format(hex_output)) ------------------- Hex color result is:#076ebe, with opacity:95.0% Related Tools Hex to Decimal Decimal to Hex Octal to Decimal Decimal to Octal Binary to Decimal Decimal to Binary Binary to Hex Hex to Binary ASCII Table Hex to ASCII String ASCII String to Hex Binary to Text Text to Binary Fraction to Decimal Decimal to Fraction Percent to Decimal Decimal to Percent Percent to Fraction Fraction to Percent Hex to RGB RGB to Hex Hex to RGBA RGBA to Hex Roman Numerals Chart 1-1000 Roman Numerals to Numbers Numbers to Roman Numerals Other Tools By Category Image Utilities Formatter & Minifier Internet Testing Hash & Cryptography Number Conversion Text & String Utilities Copyright 2018-2024 coding.tools all rights reserved English 简 繁Từ khóa » Html To Rgba Converter
-
HEX 2 RGBA Color Calculator | By @Devoth
-
RGBA And Hex Color Converter - CSS Generator Tool
-
Color Converter - W3Schools
-
Color To Hex And Rgba Converter - Popular Blocks
-
HTML Color Codes - What's Your Color
-
Convert HTML To RGBA / URL To RGBA (Online & Free) - Convertio
-
RGBA To HEX Converter - Simple CSS Media Query Generator
-
HEX To RGBA Converter Online - 10015 Tools
-
Convert Hex To RGBA - Javascript - Stack Overflow
-
How To Convert Hex To RGBA Value Using JavaScript - GeeksforGeeks
-
RGBA To HEX Converter - HTMLCSSFreebies
-
Hex To RGB Color Converter
-
Color Code Converter | Color Conversion
-
Html – Convert RGBA To HEX - ITecNote