Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!