Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rgb value as variable

How do I store a variable value in a rgb() ? I use this code which isn't working:

<script>
var R=200;
var colval="rgb(R,10,100)";
</script>

I want it to be like this:

<script>
var colval="rgb(200,10,100)";
</script>

but somehow it doesn't store R right , putting quotes around 200 or R isn't working either.

like image 554
steven Avatar asked May 22 '11 13:05

steven


People also ask

How do you store RGB in a variable?

Update the enum, and all of the places you've used Color. Blue will update. To get the long value of the RGB value to store, I just threw the value into the Immediate window and copied the output. The output will be 14390640.

What are the values of RGB?

RGB Color Values Each parameter (red, green, and blue) defines the intensity of the color with a value between 0 and 255. This means that there are 256 x 256 x 256 = 16777216 possible colors!

How do you write RGB values?

The format of the RGB Value The format of an RGB value in the functional notation is 'rgb(' followed by a comma-separated list of three numerical values (three integer values(0-255, 0-255, 0-255)) followed by ')'.

How do you interpret RGB values?

RGB defines the values of red (the first number), green (the second number), or blue (the third number). The number 0 signifies no representation of the color and 255 signifies the highest possible concentration of the color.


1 Answers

I assume you're using JavaScript:

<script>
    var R = 200;
    var colval = "rgb(" + R + ",10,100)";
</script>

Results in colval = rgb(200,10,100)

like image 102
alexn Avatar answered Oct 16 '22 21:10

alexn