About colour hex code locking

Recommended Posts

I am working on spritesheets and found out a little problem. Since I can't mix some of the colour accurately, I often search for the hex code of a particular colour. And I have to also change the value of the colour to get the brighter colour and darker colour. I found that after every time I change the value, the hex code actually changes a little bit. This problem is hardly seen but when I apply overlay blending, the changes become more obvious. So I need to retype the hex code to obtain original colour.


If there is a "hex code lock" option, that is all the sliders changes will be based on the typed in hex code, then the colour palette will be more convenient to use.

Share this post

Link to post
Share on other sites

You cannot change value without changing Hex-code. hex-code is very definition of a color, if a color changes slightly, hex code will also change according to it. the color is stored in computer as combination of three primary light color red,green,blue.

Where as, 

HSV format is invention  i.e. alternative representations of the RGB color model, designed computer graphics researchers to more closely align with the way human vision perceives color-making attributes. Hue is the color picked, saturation like amount of water mixed into it and value is like mixing of white or black color in given hue. 


RGB or Hex-code varies according following formula.


HSV to RGB conversion formula

When 0 ≤ H < 360, 0 ≤ S ≤ 1 and 0 ≤ V ≤ 1:

C = V × S

X = C × (1 - |(H / 60°) mod 2 - 1|)

m = V - C


(R,G,B) = ((R'+m)×255, (G'+m)×255, (B'+m)×255)


As you can see , if you change V, the RGB is re-calibrated. If Hex code is locked, then HSV will also become locked,

Share this post

Link to post
Share on other sites

What I mean is that when the value is changed, it will change the RGB values. For example there is a colour which has value of 50. When I change value to 25, it becomes another colour, with another hex code. But when I change it back to 50, the hex code is not the original one. I think this comes from the approximation error when I use the slider. The "lock" option I suggest will always approximate according to the original hex code. That is if I change value from 50 to 25, then change it from 25 to 50 again, the hex code will go back to the original colour. This is what I mean "locking it". 


The result will be that the variation of value is reversible. If I change value from 50 to 25, then from this 25 to 75, the result will be the colour if I change from 50 to 75. Then the original hex code is actually conservative. I hope this makes sense but I don't really know the program behind. I am just suggesting a little feature.

Share this post

Link to post
Share on other sites

The problem comes from the fact that you are mixing color modes.


When you select a color using a hex code, you are using the RGB color space to define the color.


When you move the V slider, you are using the HSV color space to define the color.


The problem arises because there is not a one-to-one ratio between the RGB and HSV color spaces.  The slight differences in hex code are a result of the conversion from HSV color to RGB color.


If you wish to have a "lock" on the hex code values, restrict yourself to only adjusting the color using the R, G, and B sliders.

Share this post

Link to post
Share on other sites

I want to update something. I caught it. I knew how it happened. I said that the colour changed, this was found when I applied overlay blending. Now I saw it happened again. I am not sure if this is a bug but I will tell you what I saw.


I am using a colour with hex code 745A3A. For convenience, I set both primary colour and secondary colour to be this colour but one of them has its value changed. The HSV says that H = 33, S = 50, V = 45. 


And you can try to reproduce this little error. Add 1 to V, then switch colour by using X, then switch again. It changes from H = 33 to H = 32, V = 46 to V = 45.


So what I saw about the overlay blending was not wrong. I am aware of this issue after looking at what Pratyush said. I thought when I use HSV, then changing V should keep H and S the same. After some time of drawing, H = 33 became H = 24. I was aware that the colour becomes more orangeish.


I think the H and V shifting was the reason why I thought there was error in the colour palette.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.