Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

185
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda