既然您的问题是“为我提供解决方案”...
我采取了完全不同的方法!
我做了一个示例,它不是一个完整的即用型解决方案,但希望对它有很好的启发。
<div>
<svg viewBox="0 0 600 600">
<circle id="bal1"/>
<circle id="bal2" cx="300" cy="120" r="50" fill="magenta"/>
<circle id="bal3" cx="100" cy="500" r="60" fill="cyan" stroke="rgba(0,0,0,0.5)" stroke-width="3"/>
<circle id="bal4" cx="350" cy="450" r="30" fill="red"/>
<text id="txt1" dominant-baseline="middle" text-anchor="middle"><tspan id="tsp1"/></text>
<text id="txt2" x="300" y="120" dominant-baseline="middle" text-anchor="middle"><tspan>50%</tspan></text>
<text id="txt3" x="100" y="500" dominant-baseline="middle" text-anchor="middle"><tspan>60%</tspan></text>
<text id="txt4" x="350" y="450" dominant-baseline="middle" text-anchor="middle" dy="5"><tspan>30%</tspan></text>
</svg>
</div>
和
html, body, div, svg { height: 100vh;
width: 100vw }
html, body { font-size: 0.05em } /* needed for using rem */
#txt1 { font-size: 70rem }
#txt2 { font-size: 50rem }
#txt3 { font-size: 60rem }
#txt4 { font-size: 30rem } /* mind the corresponding to the radius */
#bal4 { fill: red }
#bal1 { fill: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'><radialGradient id='grad'><stop offset='0%' stop-color='%23ff00cc'/><stop offset='100%' stop-color='%23333399'/></radialGradient></svg>#grad") purple }
和
/* first radius */
var br1 = 70;
/* here you will have to insert math to avoid overlapping */
var bal1 = document.getElementById('bal1');
var txt1 = document.getElementById('txt1');
bal1.setAttribute("cx", "100");
bal1.setAttribute("cy", "90");
bal1.setAttribute("r", br1);
txt1.setAttribute("x", "100");
txt1.setAttribute("y", "90");
document.getElementById("tsp1").innerHTML = br1 + "%";
所以球 #1 的位置/文本 #1 的值是动态的。
请更好地在https://codepen.io/anon/pen/pqzpKP查看它的实际应用
现在我假设您将使用它来剪辑文本。
在这种情况下,将 svg 设为外部(例如使用 PHP),并使用 CSS 之类的
div#bla { shape-outside: url('/img/balls.php?r1=70&r2=etc'); /* url-encode? */
shape-margin: 8px;
shape-image-threshold: 0.5;