Skip to content

Commit

Permalink
Add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
larsmoa committed Jun 14, 2024
1 parent 5176954 commit ccb82e5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/kernel/src/cognite/generate-screenshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ async function generateScreenshot(
return newCanvas.toDataURL(type, quality);
}

/**
* Generates a small screenshot suitable for use as a preview. The
* screenshot is guaranteed to be less than 8Kb in size.
*
* @returns A image URL encoded as image/webp
*/
export const generateAppScreenshot = async () => {
const WIDTH = 308;
const HEIGHT = 176;
Expand All @@ -68,12 +74,17 @@ export const generateAppScreenshot = async () => {
return result;
};

/**
* Generate a screenshot of the running app in full resolution
* Note that this screenshot includes content not currently visible on screen (i.e.
* content that you would need to scroll to see)
* @returns Image URL encoded as image/webp.
*/
export const generateFullAppScreenshot = async () => {
const IMAGE_TYPE = "image/webp";
const el = document.querySelector(".block-container div") as HTMLDivElement;
const originalCanvas = (await html2canvas(el, {
allowTaint: true,
// foreignObjectRendering: true,
x: 0,
y: 0,
scrollX: 0,
Expand Down

0 comments on commit ccb82e5

Please sign in to comment.