html - CSS 径向剪辑

标签 html css

我有一个圆圈 (png) 的图像,我想使用 clip 来遮盖其中的一部分。有这种径向夹吗? (假设我想将圆圈转换为饼图,例如仅 32%)使用剪辑蒙版

编辑:如果这不可能,也许关于 SVG 覆盖的提示会更好?

最佳答案

使用 canvas(和一小部分 jquery 来获取节点引用):

var ctx = $( '#canvasTag' )[0].getContext( '2d' );

// draw your image
ctx.drawImage( $( '#imgTag' )[0], x, y );

// change composite operation so that only the image below the arc below shows
ctx.globalCompositeOperation = 'destination-in';

// draw part of a circle
ctx.beginPath();
ctx.arc( x, y, radius, startAngle, endAngle, false ); // draw outer arc
ctx.lineTo( x, y );                                   // draw to center
ctx.closePath();
ctx.fill();

关于html - CSS 径向剪辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10355352/

相关文章:

html - 带有 clipPath 的 div 的单击事件在 angular.js 中不起作用

html - 渲染(错误)显示 : table-cell;

html - 调整固定在电脑上的整个网站大小?

html - 找不到更正我的输入文本框的方法

javascript - 当元素没有设置类名时的 DOM HTMLElement className 属性

javascript - 如何对齐全宽响应式 slider 上的导航按钮

javascript - 使用 javascript/jquery 创建动态 div

javascript - 如何使用 Jquery 将值附加到嵌套 div

javascript - 网站菜单在 Safari 浏览器中不显示某些内容

Javascript 使用 CSS 来旋转元素