CKTIS / CSS
ellipse() — elliptical shape geometry
`ellipse()` defines a basic shape with horizontal and vertical radii plus an optional center position relative to a reference box.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
ellipse( <radial-size>? [ at <position> ]? )ellipse() defines a basic shape with horizontal and vertical radii plus an optional center position relative to a reference box.
The example clips a red rectangle with ellipse(40px 20px at 50px 30px). Alpha at the center and just inside the radii is 255, while points beyond either axis are 0; ellipse(-1px 20px at center) is invalid because its radius is negative.
Grammar: ellipse( <radial-size>? [ at <position> ]? ).
A horizontal radius percentage resolves against the width of the <reference-box>, and a vertical one against its height. An omitted center means center, and an omitted size means closest-side. farthest-side, closest-corner, and farthest-corner are also allowed. The shape works in clip-path and shape-outside; a zero radius collapses it, and the two radii are not interchangeable in a non-square box.
Examples
const render=async()=>{
const svg='<svg xmlns="http://www.w3.org/2000/svg" width="100" height="60"><foreignObject width="100" height="60"><div xmlns="http://www.w3.org/1999/xhtml" style="width:100px;height:60px;background:red;clip-path:ellipse(40px 20px at 50px 30px)"></div></foreignObject></svg>';
const image=new Image(); image.src='data:image/svg+xml;charset=utf-8,'+encodeURIComponent(svg); await image.decode();
const canvas=document.createElement('canvas'); canvas.width=100; canvas.height=60;
const context=canvas.getContext('2d'); context.drawImage(image,0,0);
const alpha=(x,y)=>context.getImageData(x,y,1,1).data[3];
return [alpha(50,30),alpha(89,30),alpha(95,30),alpha(50,49),alpha(50,55)];
};
const alpha=await render();
const negativeRadius=CSS.supports('clip-path','ellipse(-1px 20px at center)');
console.log('center='+alpha[0]+'; horizontal-in/out='+alpha[1]+'/'+alpha[2]+'; vertical-in/out='+alpha[3]+'/'+alpha[4]+'; negative-radius='+negativeRadius);Result
center=255; horizontal-in/out=243/0; vertical-in/out=255/0; negative-radius=false
`ellipse()` defines a basic shape with horizontal and vertical radii plus an optional center position relative to a reference box.