RGB


Definition: Returns a whole number representing an RGB color value.

 

If you are a Web designer you might very well find yourself needing to calculate RGB color values. Although Windows PowerShell doesn't include a built-in method or function for calculating RGB values you can write a simple equation that will do the math for you. In the following example, we assign values to three different variables, representing the three color components: $blue, $green, $red. We then calculate the RGB value and store the result in the variable $a:

 

$blue = 10
$green= 10
$red = 10

$a = [long] ($blue + ($green * 256) + ($red * 65536))

 

When you run these commands and then echo back the value of $a you should get the following:

 

657930