我一直在搜索stackoverflow并且没有找到答案,所以这里......
我有一个总线的自定义SVG图像路径(见下文)并正确绘制并“切出”我希望透明的部分,而不是前灯。我查看了http://www.w3.org/TR/SVG/paths.html#PathData处的SVG路径数据文档,但必须遗漏一些内容。我不知道(在路径数据中,或者可能不在其中)识别填充的内容以及透明蒙版或非填充区域的内容。这就是我正在使用的。
var busSvg = {
// Bus body
// 282 wide... 322 wide with the sides added
top : 'c-4,-20,-18,-30,-38,-38 c-20,-8,-68,-18,-113,-19 c-35,1,-83,11,-113,19 c-20,8,-34,10,-38,38',
left : ' l-20,150 v170',
bottom : ' h26 v25 c0,30,45,30,45,0 v-25 h200 v25 c0,30,45,30,45,0 v-25 h26',
right : ' v-170 l-20,-150z',
// Marquee
marquee : 'm-60,10 h-182 c-20,0,-20,-25,0,-25 h182 c20,0,20,25,0,25z',
// Windshield
windshield : 'm-220,150 c-11,0,-14,-8,-12,-16 l12,-85 c2,-10,5,-17,18,-17 h220 c13,0,17,7,18,17 l12,85, c1,8,-1,16,-12,16 h-235z',
// Tires
tire_left : 'm15,100 c0,30,45,30,45,0 c0,-30,-45,-30,-45,0',
tire_right : 'm180,0 c0,30,45,30,45,0 c0,-30,-45,-30,-45,0',
};
var busIcon = {
path: 'M0,-100 '+busSvg['top']+busSvg['left']+busSvg['bottom']+busSvg['right']+busSvg['marquee']+busSvg['windshield']+busSvg['tire_left']+busSvg['tire_right'],
fillColor: "red",
fillOpacity: 1,
scale: .3, //.05,
strokeColor: "black",
strokeWeight: .5
};