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
73 lines
2.1 KiB
export const getShapeStyleFuction = (style, properties) => {
|
|
if (properties.backgroundColor)
|
|
style.fill = properties.backgroundColor
|
|
|
|
if (properties.gradientColor && style.fill !== properties.gradientColor)
|
|
style.fillGradient = properties.gradientColor
|
|
|
|
if (properties.borderColor)
|
|
style.stroke = properties.borderColor
|
|
|
|
if (properties.borderWidth)
|
|
style.strokeWidth = properties.borderWidth
|
|
|
|
if (properties.strokeLineCap) {
|
|
style.strokeLineCap = properties.strokeLineCap
|
|
style.strokeLinecap = properties.strokeLineCap
|
|
}
|
|
|
|
if (properties.borderStyle) {
|
|
if (properties.borderStyle === 'solid') {
|
|
style.strokeDashArray = '0'
|
|
// nodeResize里的bug导致的,array小写了
|
|
style.strokeDasharray = '0'
|
|
}
|
|
if (properties.borderStyle === 'dashed') {
|
|
style.strokeDashArray = `${properties.strokeDashWidth},${properties.strokeDashSpace}`
|
|
style.strokeDasharray = `${properties.strokeDashWidth},${properties.strokeDashSpace}`
|
|
}
|
|
if (properties.borderStyle === 'dotted') {
|
|
style.strokeDashArray = `${properties.strokeDashWidth},${properties.strokeDashSpace}`
|
|
style.strokeDasharray = `${properties.strokeDashWidth},${properties.strokeDashSpace}`
|
|
}
|
|
if (properties.borderStyle === 'hidden')
|
|
style.stroke = style.fill
|
|
}
|
|
|
|
if (properties.strokeDashoffset) {
|
|
style.strokeDashoffset = properties.strokeDashoffset
|
|
}
|
|
|
|
return style
|
|
}
|
|
|
|
export const getTextStyleFunction = (style, properties) => {
|
|
if (properties.fontColor)
|
|
style.color = properties.fontColor
|
|
|
|
if (properties.backgroundColor)
|
|
style.background.fill = properties.backgroundColor
|
|
|
|
if (properties.fontSize)
|
|
style.fontSize = properties.fontSize
|
|
|
|
if (properties.fontFamily)
|
|
style.fontFamily = properties.fontFamily
|
|
|
|
if (properties.lineHeight)
|
|
style.lineHeight = properties.lineHeight
|
|
|
|
if (properties.textAlign)
|
|
style.textAlign = properties.textAlign
|
|
|
|
if (properties.fontWeight)
|
|
style.fontWeight = properties.fontWeight
|
|
|
|
if (properties.textDecoration)
|
|
style.textDecoration = properties.textDecoration
|
|
|
|
if (properties.fontStyle)
|
|
style.fontStyle = properties.fontStyle
|
|
|
|
return style
|
|
}
|