* Create a symbol element with given symbol configuration: shape, x, y, width, height, color * @param {string} symbolType * @param {number} x * @param {number} y * @param {number} w * @param {number} h * @param {string} color * @param {boolean} [keepAspect=false] whether to keep the ratio of
(symbolType, x, y, w, h, color, keepAspect)
| 33275 | * for path and image only. |
| 33276 | */ |
| 33277 | function createSymbol(symbolType, x, y, w, h, color, keepAspect) { |
| 33278 | // TODO Support image object, DynamicImage. |
| 33279 | |
| 33280 | var isEmpty = symbolType.indexOf('empty') === 0; |
| 33281 | if (isEmpty) { |
| 33282 | symbolType = symbolType.substr(5, 1).toLowerCase() + symbolType.substr(6); |
| 33283 | } |
| 33284 | var symbolPath; |
| 33285 | |
| 33286 | if (symbolType.indexOf('image://') === 0) { |
| 33287 | symbolPath = makeImage( |
| 33288 | symbolType.slice(8), |
| 33289 | new BoundingRect(x, y, w, h), |
| 33290 | keepAspect ? 'center' : 'cover' |
| 33291 | ); |
| 33292 | } |
| 33293 | else if (symbolType.indexOf('path://') === 0) { |
| 33294 | symbolPath = makePath( |
| 33295 | symbolType.slice(7), |
| 33296 | {}, |
| 33297 | new BoundingRect(x, y, w, h), |
| 33298 | keepAspect ? 'center' : 'cover' |
| 33299 | ); |
| 33300 | } |
| 33301 | else { |
| 33302 | symbolPath = new SymbolClz$2({ |
| 33303 | shape: { |
| 33304 | symbolType: symbolType, |
| 33305 | x: x, |
| 33306 | y: y, |
| 33307 | width: w, |
| 33308 | height: h |
| 33309 | } |
| 33310 | }); |
| 33311 | } |
| 33312 | |
| 33313 | symbolPath.__isEmptyBrush = isEmpty; |
| 33314 | |
| 33315 | symbolPath.setColor = symbolPathSetColor; |
| 33316 | |
| 33317 | symbolPath.setColor(color); |
| 33318 | |
| 33319 | return symbolPath; |
| 33320 | } |
| 33321 | |
| 33322 | /* |
| 33323 | * Licensed to the Apache Software Foundation (ASF) under one |
no test coverage detected