* @param {string} iconStr Support 'image://' or 'path://' or direct svg path. * @param {Object} [opt] Properties of `module:zrender/Element`, except `style`. * @param {Object} [rect] {x, y, width, height} * @return {module:zrender/Element} Icon path or image element.
(iconStr, opt, rect)
| 18136 | * @return {module:zrender/Element} Icon path or image element. |
| 18137 | */ |
| 18138 | function createIcon(iconStr, opt, rect) { |
| 18139 | opt = extend({rectHover: true}, opt); |
| 18140 | var style = opt.style = {strokeNoScale: true}; |
| 18141 | rect = rect || {x: -1, y: -1, width: 2, height: 2}; |
| 18142 | |
| 18143 | if (iconStr) { |
| 18144 | return iconStr.indexOf('image://') === 0 |
| 18145 | ? ( |
| 18146 | style.image = iconStr.slice(8), |
| 18147 | defaults(style, rect), |
| 18148 | new ZImage(opt) |
| 18149 | ) |
| 18150 | : ( |
| 18151 | makePath( |
| 18152 | iconStr.replace('path://', ''), |
| 18153 | opt, |
| 18154 | rect, |
| 18155 | 'center' |
| 18156 | ) |
| 18157 | ); |
| 18158 | } |
| 18159 | } |
| 18160 | |
| 18161 | /** |
| 18162 | * Return `true` if the given line (line `a`) and the given polygon |