* Create a image element from image url * @param {string} imageUrl image url * @param {Object} opts options * @param {module:zrender/core/BoundingRect} rect constrain rect * @param {string} [layout=cover] 'center' or 'cover'
(imageUrl, rect, layout)
| 16966 | * @param {string} [layout=cover] 'center' or 'cover' |
| 16967 | */ |
| 16968 | function makeImage(imageUrl, rect, layout) { |
| 16969 | var path = new ZImage({ |
| 16970 | style: { |
| 16971 | image: imageUrl, |
| 16972 | x: rect.x, |
| 16973 | y: rect.y, |
| 16974 | width: rect.width, |
| 16975 | height: rect.height |
| 16976 | }, |
| 16977 | onload: function (img) { |
| 16978 | if (layout === 'center') { |
| 16979 | var boundingRect = { |
| 16980 | width: img.width, |
| 16981 | height: img.height |
| 16982 | }; |
| 16983 | path.setStyle(centerGraphic(rect, boundingRect)); |
| 16984 | } |
| 16985 | } |
| 16986 | }); |
| 16987 | return path; |
| 16988 | } |
| 16989 | |
| 16990 | /** |
| 16991 | * Get position of centered element in bounding box. |
no test coverage detected