set_rgb_g

( <-- Back to Sporkl Function Library )


void set_rgb_g ( rgb color, int val )


Sets the green component of an rgb value.



Arguments:

color:
val:
Rgb color value to set green component of
Value to set green component of color to

Returns:

Nothing.

Notes:

Although the range of red, green, and blue components of rgb values are in the interval [0,255], the val argument of this function has a much larger range. When the value of val is outside of the valid range of [0,255], the value the component is actually set to is saturated to within the valid range. That is, if val is less than 0, the green component of color is set to 0, and if val is greater than 255, the green component of color is set to 255.

Example:

The code:

rgb c;

set_rgb_g(c,135);

print("The green component of c is now " + str(rgb_g(c)) + "\n");

set_rgb_g(c,300);

print("The green component of c is now " + str(rgb_g(c)) + "\n");

set_rgb_g(c,-20);

print("The green component of c is now " + str(rgb_g(c)) + "\n");

produces the following output:

The green component of c is now 135
The green component of c is now 255
The green component of c is now 0









sporkforge