473,406 Members | 2,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Getting the color code with alpha level

46
Hi all,

if i am having the input as rgb color code and alpha level. Now i want to calculate the rgb color code with applying the alpha level into the rgb color code. Is there any idea folks.

for example,
if supplied color code is #ec933a with alpha level is 60(approx)
we will have to get the output like this #fbebd9.

This is just for example i said.
May 3 '08 #1
5 3107
acoder
16,027 Expert Mod 8TB
If you alert the element's style.color property you should get the rgb values.

However, alpha values are not part of rgb. Use the opacity property to control the alpha level. I assume you're trying to create an approximation effect of some sort.
May 3 '08 #2
Velhari
46
If you alert the element's style.color property you should get the rgb values.

However, alpha values are not part of rgb. Use the opacity property to control the alpha level. I assume you're trying to create an approximation effect of some sort.
Hi,

Thanks for Reply. I am working to getting the color from the user, using that colorcode i will have to calculate the colorcode(with alpha level) which applied after some alpha level on user input. These things i plan to do through Javascript calculation.
Is it possible? and how to do this.
For example,
In google calendar before creating the event in calendar, we had to choose the color of the calendar. Then, the event created and displayed in the calendar based on the color(of calendar) chosen earlier.
Here I notice that, In that event display, they have applied the color (we chosen for the calendar) for the borders and not for background of event. I think that they performed some calculation for to display the background color with some alpha level applied to the color we chose earlier.
May 5 '08 #3
hsriat
1,654 Expert 1GB
For example,
In google calendar before creating the event in calendar, we had to choose the color of the calendar. Then, the event created and displayed in the calendar based on the color(of calendar) chosen earlier.
Here I notice that, In that event display, they have applied the color (we chosen for the calendar) for the borders and not for background of event. I think that they performed some calculation for to display the background color with some alpha level applied to the color we chose earlier.
They don't apply any alpha to the color to provide background. They just increase its brightness.

There's a difference between alpha and brightness. Alpha is transparency of the element.

So just forget about alpha and calculate the relative brighter version of the color selected by your user. Programmatacally (I'm not sure if this word exists), its not a single line code to calculate the relative brighter version.
You need to convert HEX color code to RGB, then RGB to HSL (or HSB). In the HSL format, increment the L (luminosity) value, and convert the new HSL value to HEX, again through the same cycle. This calculated HEX code is what you require.

However, I case you are giving few color options to the user, instead of writing the code, just calculate the relatively brighter versions of your color with a photo editor (GIMP or PHOTOSHOP) for once and save them corresponding to each color in an array in your code. And use the corresponding color when required.
May 5 '08 #4
Velhari
46
So just forget about alpha and calculate the relative brighter version of the color selected by your user.
You need to convert HEX color code to RGB, then RGB to HSL (or HSB). In the HSL format, increment the L (luminosity) value, and convert the new HSL value to HEX, again through the same cycle. This calculated HEX code is what you require.
Hi,

I follow the steps as said by you. Its really working too great. Thanks for your Idea.
May 5 '08 #5
hsriat
1,654 Expert 1GB
Hi,

I follow the steps as said by you. Its really working too great. Thanks for your Idea.
You are welcome :)
May 5 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: John Hunter | last post by:
I have a largish data set (1000 observations x 100 floating point variables), and some of the of the data are missing. I want to try a variety of clustering, neural network, etc, algorithms on the...
303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
4
by: Fernando Rodríguez | last post by:
Hi, While iterating through a list I'd like to know not just the current element, but also its index. Is there a better way than this: i = 0 newList = for element in aList:...
20
by: Mark Hahn | last post by:
Prothon is pleased to announce another major release of the language, version 0.1.2, build 710 at http://prothon.org. This release adds many new features and demonstrates the level of maturity...
7
by: Robert Ferber | last post by:
Hi, I can't find any good documentation about the Python-database module, all I found was this rudimentary (no examples, no references) piece here: http://www.python.org/peps/pep-0249.html ...
2
by: Alpha | last post by:
Hi, I just added a new form with Crystl report viewer but one of my other form suddently starts giving me an error message when I rebuild the code. The error is complainig about the class name. ...
11
by: Yaniv | last post by:
Hi How can I convert Uint32 variable to System.drawing.color ?? Thanks in advanced Yaniv
1
by: JustinCarmony | last post by:
I'm using a DataAdapter to fill a DataSet to display a list of items in a custom way. I'm not using the GridView or any server controls like that. This is my code: <code> SqlConnection sqlConn...
4
Shakss2
by: Shakss2 | last post by:
Hello all, I have a table name "info" which looks like, ProjectID Consultantname 1 Alpha 1 Beta 1 Charlie 2 James 2 ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.