MCPcopy
hub / github.com/vercel/satori / buildClipPath

Function buildClipPath

src/builder/clip-path.ts:11–51  ·  view source on GitHub ↗
(
  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>
)

Source from the content-addressed store, hash-verified

9}
10
11export 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}

Callers 1

overflowFunction · 0.85

Calls 3

createShapeParserFunction · 0.85
buildXMLStringFunction · 0.85
genClipPathIdFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…