Skip to content

@shbernal/ts-pptx


@shbernal/ts-pptx / index / clipPath

Function: clipPath()

clipPath(shape, w, h): GeometryPoint[]

Defined in: src/clip.ts:159

Resolve a ClipShape to a freeform points path filling a w × h box, ready to hand to addImage({ points }).

w/h are the image box's size in inches and must match the w/h the picture is drawn at — the path is emitted in the box's own coordinate space, not normalized (see the module note above).

Parameters

shape

ClipShape

the named silhouette and its options

w

number

image box width (inches)

h

number

image box height (inches)

Returns

GeometryPoint[]

the freeform path, for addImage({ points })

Example

ts
const w = 5.22, h = 7.5
slide.addImage({
  path: 'cover.jpg', x: 0, y: 0, w, h,
  points: clipPath({ kind: 'half-disc', flat: 'right' }, w, h),
  sizing: { type: 'cover' },   // center-crop the photo into the "D"
})