Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rgb values to 0 to 1 scale

Tags:

math

rgb

I'm trying to calculate some RGB colors (0 - 255) for a 0 to 1 scale. Does anyone knows a online converter or it exists a math formula?

Lets say that I want to convert 125 RGB with (0 to 255 scale) to a 0 to 1 scale.

like image 513
el.severo Avatar asked Jun 01 '12 10:06

el.severo


People also ask

What is RGB value scale?

A color's RGB value indicates its red, green, and blue intensity. Each intensity value is on a scale of 0 to 255, or in hexadecimal from 00 to FF. RGB values are used in HTML, XHTML, CSS, and other web standards.

Why is RGB on a scale from 0 to 255?

It really comes down to math and getting a value between 0-1. Since 255 is the maximum value, dividing by 255 expresses a 0-1 representation. Each channel (Red, Green, and Blue are each channels) is 8 bits, so they are each limited to 256, in this case 255 since 0 is included.

What colour do the RGB values 0.1 0.1 0.1 represent?

The RGB color 0, 1, 0 is a dark color, and the websafe version is hex 000000.

When RGB values are 0 0 0 What color do you see?

Black is the zero value at RGB(0,0,0), and White is maximum at RGB(255,255,255).


2 Answers

It's simply a case of dividing your RGB value, call it x by 255:

If x = 95 then your value is 95/255 = 0.373 (to 3 d.p.)

like image 105
Widor Avatar answered Oct 02 '22 12:10

Widor


a = x / 255 

or

x = a * 255 

where x is the RGB value and a is your desired result.

like image 45
Sirko Avatar answered Oct 02 '22 10:10

Sirko