Questions tagged [rgb]

RGB stands for Red-Green-Blue and specifies a color using three values, which represent the respective amount of red, green, and blue in the color. RGB is the basis for the color model used by most color display devices nowadays.

The RGB color model is an additive color model in which red, green, and blue light are added together in various ways to reproduce a broad array of colors. The name of the model comes from the initials of the three additive primary colors, red, green, and blue. RGB is a color notation used in most computing devices nowadays.

RGB colors are represented by a tuple of three values (one per primary color), which are typically either bytes ranging from 0 to 255 or floating-point values ranging from 0.0 to 1.0.

3547 questions
47
votes
3 answers

Can I force jQuery.css("backgroundColor") returns on hexadecimal format?

I have an element like this:

My text with a sample highlight.

And the CSS class like this: .highlighted { background: #f0ff05; font-weight: normal; } But when I use a jQuery like…

user776290
43
votes
15 answers

Shift hue of an RGB Color

I'm trying to write a function to shift the hue of an RGB color. Specifically I'm using it in an iOS app, but the math is universal. The graph below shows how the R, G, and B values change with respect to the hue. Looking at that it seems like it…
Anthony Mattox
  • 7,048
  • 6
  • 43
  • 59
43
votes
5 answers

How do I use RGB color in Flutter?

I am trying to use it like this but it is giving me no color on text. Color.fromARGB(1, 239 ~/ 255, 58 ~/ 255, 121 ~/ 255)
Shehbaz Khan
  • 1,892
  • 3
  • 24
  • 31
42
votes
6 answers

Why do we always divide RGB values by 255?

Why do we always divide our RGB values by 255? I know that the range is from [0-1]. But why dive only by 255? Can anyone please explain me the concepts of RGB values?
Tabish Sohail
  • 1,040
  • 2
  • 9
  • 22
41
votes
3 answers

Extract RGB or 6 digit code from Seaborn palette

Seaborn has an option to create nice color palettes. I wish to use these palettes to generate colors that work well together in a map where countries are shaded according to some property. The following code produces 8 shades of purple from light to…
Pete
  • 767
  • 3
  • 9
  • 16
41
votes
7 answers

Fastest formula to get Hue from RGB

If you are given red, green, and blue values that range from 0-255, what would be the fastest computation to get just the hue value? This formula will be used on every pixel of a 640x480 image at 30fps (9.2 million times a second) so every little…
user3161533
  • 427
  • 1
  • 4
  • 6
39
votes
3 answers

How can I convert an RGB image to grayscale but keep one color?

I am trying to create an effect similar to Sin City or other movies where they remove all colors except one from an image. I have an RGB image which I want to convert to grayscale but I want to keep one color. This is my picture: I want to keep the…
Richard Knop
  • 81,041
  • 149
  • 392
  • 552
39
votes
5 answers

Set background colour of cell to RGB value of data in cell

I have a column containing RGB values, e.g.: 127,187,199 67,22,94 In Excel, is there any way I can use this to set the background colour of the cell?
Internet man
  • 1,115
  • 3
  • 13
  • 21
37
votes
6 answers

How do you get the RGB values from a Bitmap on Android?

I want to get RGB values of a Bitmap on Android but I can't do this so far. My aim is to obtain RGB values for each pixel of a Bitmap. Is there any specific function for Android or anything else? Also I wonder that do I need colorMatrix()…
barzos
  • 837
  • 3
  • 16
  • 25
37
votes
3 answers

How to generate random pastel (or brighter) color in Javascript?

Question: Is there is any way (in JS) to create a random color code using just bright colors, or pastel colors? I am building a simple website that gives a random quote when I click a button, and with that, the background color changes. The thing is…
Zzeks
  • 571
  • 2
  • 5
  • 9
37
votes
13 answers

Calculation of a mixed color in RGB

I want to be able to take two RGB-256 vectors and calculate the result of their mixture. Also I want to be able to give each vector a different weight. I've experimented with it using the Word color plate, and I've seen that while some colors do mix…
SIMEL
  • 8,745
  • 28
  • 84
  • 130
36
votes
10 answers

Background-color hex to JavaScript variable

I'm kind of new to JavaScript and jQuery and now I'm facing a problem: I need to post some data to PHP and one bit of the data needs to be the background color hex of div X. jQuery has the css("background-color") function and with it I can get RGB…
Removed_account
  • 3,999
  • 3
  • 20
  • 15
36
votes
2 answers

How to convert RGB PIL image to numpy array with 3 channels?

I am loading image with the following code image = PIL.Image.open(file_path) image = np.array(image) It works, but the size of array appears to be (X, X, 4), i.e. it has 4 layers. I would like normal RGB layers. Is it possible? UPDATE I found that…
Dims
  • 47,675
  • 117
  • 331
  • 600
34
votes
7 answers

How to get RGB components from Color in SwiftUI

If I have a SwiftUI Color: let col: Color = Color(red: 0.5, green: 0.5, blue: 0.5) How do I get the RGB components from col? Like this maybe: print(col.components.red) In UIKit, I could use UIColor.getRed but there doesn't seem to be an equivalent…
Div
  • 1,363
  • 2
  • 11
  • 28
34
votes
2 answers

From RGB to HSV in OpenGL GLSL

I need to pass from RGB color space to HSV .. I searched in internet and found two different implementations, but those give me different results: A: precision mediump float; vec3 rgb2hsv(float r, float g, float b) { float h = 0.0; float…
BQuadra
  • 789
  • 2
  • 11
  • 20