(
v: {
left: number
top: number
width: number
height: number
path: string
matrix: string | undefined
id: string
currentClipPath: string | string
src?: string
},
style: Record<string, string | number>,
inheritedStyle: Record<string, string | number>
)
| 9 | } |
| 10 | |
| 11 | export function buildClipPath( |
| 12 | v: { |
| 13 | left: number |
| 14 | top: number |
| 15 | width: number |
| 16 | height: number |
| 17 | path: string |
| 18 | matrix: string | undefined |
| 19 | id: string |
| 20 | currentClipPath: string | string |
| 21 | src?: string |
| 22 | }, |
| 23 | style: Record<string, string | number>, |
| 24 | inheritedStyle: Record<string, string | number> |
| 25 | ) { |
| 26 | if (style.clipPath === 'none') return '' |
| 27 | |
| 28 | const parser = createShapeParser(v, style, inheritedStyle) |
| 29 | const clipPath = style.clipPath as string |
| 30 | |
| 31 | let tmp: { type: string; [p: string]: string | number } = { type: '' } |
| 32 | |
| 33 | for (const k of Object.keys(parser)) { |
| 34 | tmp = parser[k](clipPath) |
| 35 | if (tmp) break |
| 36 | } |
| 37 | |
| 38 | if (tmp) { |
| 39 | const { type, ...rest } = tmp |
| 40 | return buildXMLString( |
| 41 | 'clipPath', |
| 42 | { |
| 43 | id: genClipPathId(v.id), |
| 44 | 'clip-path': v.currentClipPath, |
| 45 | transform: `translate(${v.left}, ${v.top})`, |
| 46 | }, |
| 47 | buildXMLString(type, rest) |
| 48 | ) |
| 49 | } |
| 50 | return '' |
| 51 | } |
no test coverage detected
searching dependent graphs…