Stamp the capture with the time.
Adds a timestamp label. The clock or custom formatter runs for every capture.
npm install @zumer/snapdom@latest @zumer/snapdom-plugins@latestUsage
import { snapdom } from '@zumer/snapdom';
import { timestampOverlay } from '@zumer/snapdom-plugins/timestamp-overlay';
const el = document.querySelector('#target');
const result = await snapdom(el, { plugins: [timestampOverlay({ position: 'top-right', format: 'date' })] });
const image = await result.toPng();
document.body.append(image);
Options
| Option | Type | Default | Description |
|---|---|---|---|
format | string | function | 'datetime' | 'datetime' | 'date' | 'time' | 'iso' | custom (Date) => string |
position | string | 'bottom-right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' |
background | string | 'rgba(0,0,0,0.6)' | Label background color |
color | string | '#fff' | Label text color |
fontSize | number | 11 | Font size in px |