SVG / 088

Even-odd fill

重なる内側を抜く
輪郭をまたぐ回数の偶奇によって、塗る領域を決めます。

実際のHTML・CSSで描かれた見本です。

ラボで詳しく試す ↗

ひとつ試すなら

どこが変わるかを観察して、似た表現と見比べてみよう。

こんなときに

穴のある図形や、複数の輪郭からできたアイコン。

仕組みと使い方

同じパスでもfill-ruleによって内側の塗り方が変わります。

穴塗りevenodd図形
実装コードを見る
<style>
.sample{width:100%;height:100%;min-height:190px;display:grid;place-items:center;position:relative;overflow:hidden;box-sizing:border-box;font-family:Arial,'Hiragino Kaku Gothic ProN',Meiryo,sans-serif;color:#20211d;background:#f1f0e9;padding:22px}.sample *{box-sizing:border-box}.sample button,.sample input,.sample summary{font:inherit}.sample button,.sample summary,.sample label{touch-action:manipulation}.sample :focus-visible{outline:3px solid #6050bf;outline-offset:5px}.sample small{font-size:10px;line-height:1.5}.sample .editable{margin:0}.sample svg{max-width:100%;height:auto}
.sample svg{width:170px}
</style>
<div class="sample">
<svg viewBox="0 0 180 150" role="img" aria-label="内側が抜けた二重の星形"><path d="M90 5 175 140H5Z M90 48 135 122H45Z" fill="#b39bdd" fill-rule="evenodd"/></svg>
</div>