Color.addScalar(scalar: number): Color
The Color.addScalar()
method adds a scalar value to the red, green and blue components of a Color
.
color.addScalar(scalar);
scalar
- A number representing the scalar value to add to each component of the Color
. This value will be added to the red, green and blue values of the color.Color
object.The Color.addScalar()
method adds a scalar value to the red, green and blue components of a Color
. This is useful when applying color tinting or fading effects, as it allows a single value to be applied to all components simultaneously.
When a scalar value is added to a color component, the resulting value is clamped between 0 and 1. Therefore, adding a larger scalar value may not result in an expected change in color appearance.
const color = new THREE.Color(0xff0000); // red
color.addScalar(0.5); // adds 0.5 to the red, green and blue values