MCPcopy Create free account
hub / github.com/ScaleML/AgentSPEX / exportToPng

Function exportToPng

yaml-flow-editor/src/utils/image.ts:80–101  ·  view source on GitHub ↗

* Export as high-resolution PNG * pixelRatio controls pixel density - higher values produce clearer images * Output image pixels = width * pixelRatio × height * pixelRatio

(
  element: HTMLElement,
  width: number,
  height: number,
  viewport: { x: number; y: number; zoom: number },
  options: Required<ExportOptions>
)

Source from the content-addressed store, hash-verified

78 * Output image pixels = width * pixelRatio × height * pixelRatio
79 */
80async function exportToPng(
81 element: HTMLElement,
82 width: number,
83 height: number,
84 viewport: { x: number; y: number; zoom: number },
85 options: Required<ExportOptions>
86): Promise<string> {
87 return toPng(element, {
88 backgroundColor: options.backgroundColor,
89 width: width,
90 height: height,
91 pixelRatio: options.scale, // Use pixelRatio for higher pixel density
92 style: {
93 width: `${width}px`,
94 height: `${height}px`,
95 transform: `translate(${viewport.x}px, ${viewport.y}px) scale(${viewport.zoom})`,
96 border: 'none',
97 outline: 'none',
98 },
99 filter: createNodeFilter(),
100 });
101}
102
103/**
104 * Export as SVG (vector graphics, infinitely scalable)

Callers 1

downloadImageFunction · 0.85

Calls 1

createNodeFilterFunction · 0.85

Tested by

no test coverage detected