dashStyle.js 472 B

12345678910111213
  1. import { isArray, isNumber } from '../../core/util.js';
  2. export function normalizeLineDash(lineType, lineWidth) {
  3. if (!lineType || lineType === 'solid' || !(lineWidth > 0)) {
  4. return null;
  5. }
  6. lineWidth = lineWidth || 1;
  7. return lineType === 'dashed'
  8. ? [4 * lineWidth, 2 * lineWidth]
  9. : lineType === 'dotted'
  10. ? [lineWidth]
  11. : isNumber(lineType)
  12. ? [lineType] : isArray(lineType) ? lineType : null;
  13. }