Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

182
Visualizações
Creating complex polygon

I have a formula to determine the diameter of a circle, so that, for any given rectangle, the top center and perimeter of the circle touch the top center and bottom corners of the rectangle.

diameter = width * width / 4 / height + height // width and height of the rectangle

enter image description here


However, what I now need to do is create a shape like below, which I know can be accomplished with clip-path: polygon(), possibly being made even simpler by using the evenodd fill-rule of polygon().


enter image description here


The problem is that I am unfamiliar with clip-path: polygon and suck at math, so I am not quite sure if it can be made even simpler by using the evenodd fill-rule, let alone how to go about generating the set of vertices to plot.

Obviously, a pure CSS solution is ideal. However, I can use JS if this is impossible to do with CSS alone.

Any ideas?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

A radial-gradient can do the job here:

.box {
  --w:200;
  --h:100;
  --d:calc((var(--w)*var(--w))/(4*var(--h)) + var(--h));
  width:calc(var(--w)*1px);
  height:calc(var(--h)*1px);
  background:
    radial-gradient(farthest-side,blue 98%,red) 
    top/calc(var(--d)*1px) calc(var(--d)*1px);
  border:1px solid;
}
<div class="box"></div>

<div class="box" style="--w:300"></div>

<div class="box" style="--h:50"></div>

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda