Skip to content

boxToClip

reference
1 min readUpdated

Kind: Function

Source: atloria-monorepo/apps/screenshot-worker/src/app/screenshot/services/crop.service.ts

Convert a percent box (0-100 of the natural image) into a Playwright clip rect in PIXELS, framing the target with padPct of breathing room on every side and clamped to the image bounds so the clip never runs off-canvas.

Signature

ts
function boxToClip(box: BoxPct, imgW: number, imgH: number, padPct): ClipRect

Parameters

NameType
boxBoxPct
imgWnumber
imgHnumber
padPctany

Returns: ClipRect

Was this page helpful?

Download as PDF