0

I try to build a website with a color picker.

For that, I would like to use some sort of semicircle with which you can choose the hue and a triangle with which you can choose the saturation and lightness.

See the triangle in the middle

I got my semicircle/color wheel and also the triangle shape so I only need the background/color of the triangle.

For that, I need a linear-gradient in another linear-gradient (like a gradient-array).

#colorTriangle {
 width: 250px;
 height: 200px;
 background-image: linear-gradient(hsl(0, 100%, 50%), linear-gradient(hsl(0, 0%, 100%), hsl(0, 100%, 0%)));
 clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}
<div id="colorTriangle"></div>

isherwood
61.4k16 gold badges122 silver badges173 bronze badges
asked Feb 28, 2024 at 16:52
1
  • Please see How to Ask and take the tour, then revise your title to ask a clear, specific question. Commented Feb 28, 2024 at 19:49

2 Answers 2

1

Since your triangle supposed to be equilateral, its height would be h = (a√3)/2.
Or here we can use h = 0.866a.

And instead of linear-gradient I'd use radial-gradient:

#colorTriangle {
 --a: 250px;
 width: var(--a);
 height: calc(.866 * var(--a));
 background-color:#777;
 background-image: 
 radial-gradient(circle at 50% 0, hsl(0, 100%, 50%), #0000 var(--a)),
 radial-gradient(circle at 100% 100%, hsl(0, 0%, 100%), #0000 var(--a)), 
 radial-gradient(circle at 0 100%, hsl(0, 100%, 0%), #0000 var(--a));
 background-blend-mode:hard-light;
 clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}
<div id="colorTriangle"></div>

answered Feb 28, 2024 at 20:38
Sign up to request clarification or add additional context in comments.

Comments

0

The linear-gradient term should not appear twice in your property value. You're effectively nesting gradients here. Take the second one out, along with the extra closing parenthesis.

#colorTriangle {
 width: 250px;
 height: 200px;
 background-image: linear-gradient(
 hsl(0, 100%, 50%), 
 hsl(0, 0%, 100%), 
 hsl(0, 100%, 0%)
 );
 clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}
<div id="colorTriangle"></div>

answered Feb 28, 2024 at 19:50

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.