solar apricot
solar apricot

Reputation: 429

get a lighter color from threejs Color

I need to get a lighter shade from a variable color in threejs. Is there a quick way of doing this? basically just lighten whatever color is given. I am looking through https://threejs.org/docs/#api/en/math/Color and i dont see anything obvious, but I am not also familiar with color manipulation and if there's a simple way of just adding something of multiplying something to get the result I need. Any advice is appreciated!

Upvotes: 1

Views: 884

Answers (2)

cg-zhou
cg-zhou

Reputation: 563

The Color can be constructed from HSL:

const color6 = new THREE.Color("hsl(0, 100%, 50%)");

Using the third parameter lightness is more appropriate in your case.

Here is a HSL color demo:

https://www.w3schools.com/colors/colors_hsl.asp

It is more directly to change HSL color by function offsetHSL:

https://threejs.org/docs/#api/en/math/Color.offsetHSL

Hope it works :)

Upvotes: 2

solar apricot
solar apricot

Reputation: 429

I think I found a way, by simply doing:

myColor.lerp(new Color("#FFF"), .7);

Upvotes: 1

Related Questions