物管理前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.1 KiB

  1. export const getShapeStyleFuction = (style, properties) => {
  2. if (properties.backgroundColor)
  3. style.fill = properties.backgroundColor
  4. if (properties.gradientColor && style.fill !== properties.gradientColor)
  5. style.fillGradient = properties.gradientColor
  6. if (properties.borderColor)
  7. style.stroke = properties.borderColor
  8. if (properties.borderWidth)
  9. style.strokeWidth = properties.borderWidth
  10. if (properties.strokeLineCap) {
  11. style.strokeLineCap = properties.strokeLineCap
  12. style.strokeLinecap = properties.strokeLineCap
  13. }
  14. if (properties.borderStyle) {
  15. if (properties.borderStyle === 'solid') {
  16. style.strokeDashArray = '0'
  17. // nodeResize里的bug导致的,array小写了
  18. style.strokeDasharray = '0'
  19. }
  20. if (properties.borderStyle === 'dashed') {
  21. style.strokeDashArray = `${properties.strokeDashWidth},${properties.strokeDashSpace}`
  22. style.strokeDasharray = `${properties.strokeDashWidth},${properties.strokeDashSpace}`
  23. }
  24. if (properties.borderStyle === 'dotted') {
  25. style.strokeDashArray = `${properties.strokeDashWidth},${properties.strokeDashSpace}`
  26. style.strokeDasharray = `${properties.strokeDashWidth},${properties.strokeDashSpace}`
  27. }
  28. if (properties.borderStyle === 'hidden')
  29. style.stroke = style.fill
  30. }
  31. if (properties.strokeDashoffset) {
  32. style.strokeDashoffset = properties.strokeDashoffset
  33. }
  34. return style
  35. }
  36. export const getTextStyleFunction = (style, properties) => {
  37. if (properties.fontColor)
  38. style.color = properties.fontColor
  39. if (properties.backgroundColor)
  40. style.background.fill = properties.backgroundColor
  41. if (properties.fontSize)
  42. style.fontSize = properties.fontSize
  43. if (properties.fontFamily)
  44. style.fontFamily = properties.fontFamily
  45. if (properties.lineHeight)
  46. style.lineHeight = properties.lineHeight
  47. if (properties.textAlign)
  48. style.textAlign = properties.textAlign
  49. if (properties.fontWeight)
  50. style.fontWeight = properties.fontWeight
  51. if (properties.textDecoration)
  52. style.textDecoration = properties.textDecoration
  53. if (properties.fontStyle)
  54. style.fontStyle = properties.fontStyle
  55. return style
  56. }