lineStyle.js 812 B

12345678910111213141516171819202122
  1. var makeStyleMapper = require("./makeStyleMapper");
  2. var getLineStyle = makeStyleMapper([['lineWidth', 'width'], ['stroke', 'color'], ['opacity'], ['shadowBlur'], ['shadowOffsetX'], ['shadowOffsetY'], ['shadowColor']]);
  3. var _default = {
  4. getLineStyle: function (excludes) {
  5. var style = getLineStyle(this, excludes);
  6. var lineDash = this.getLineDash(style.lineWidth);
  7. lineDash && (style.lineDash = lineDash);
  8. return style;
  9. },
  10. getLineDash: function (lineWidth) {
  11. if (lineWidth == null) {
  12. lineWidth = 1;
  13. }
  14. var lineType = this.get('type');
  15. var dotSize = Math.max(lineWidth, 2);
  16. var dashSize = lineWidth * 4;
  17. return lineType === 'solid' || lineType == null ? null : lineType === 'dashed' ? [dashSize, dashSize] : [dotSize, dotSize];
  18. }
  19. };
  20. module.exports = _default;