Provides primitives to capture screenshots.
- Source:
Methods
(static) canvas(win, left, top, width, height, highlightsopt, canvasopt, flagsopt) → {HTMLCanvasElement}
Low-level interface to draw a rectangle off the framebuffer.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
win |
DOMWindow | The DOM window used for the framebuffer, and providing the interfaces for creating an HTMLCanvasElement. |
|
left |
number | The left, X axis offset of the rectangle. |
|
top |
number | The top, Y axis offset of the rectangle. |
|
width |
number | The width dimension of the rectangle to paint. |
|
height |
number | The height dimension of the rectangle to paint. |
|
highlights |
Array.<Node> |
<optional> |
Optional array of nodes, around which a border will be marked to highlight them in the screenshot. |
canvas |
HTMLCanvasElement |
<optional> |
Optional canvas to reuse for the screenshot. |
flags |
number |
<optional> |
Optional integer representing flags to pass to drawWindow; these are defined on CanvasRenderingContext2D. |
- Source:
Returns:
The canvas on which the selection from the window's framebuffer has been painted on.
- Type
- HTMLCanvasElement
(static) element(node, highlightsopt) → {HTMLCanvasElement}
Take a screenshot of a single element.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
node |
Node | The node to take a screenshot of. |
|
highlights |
Array.<Node> |
<optional> |
Optional array of nodes, around which a border will be marked to highlight them in the screenshot. |
- Source:
Returns:
The canvas element where the element has been painted on.
- Type
- HTMLCanvasElement
(static) toBase64(canvas) → {string}
Encode the contents of an HTMLCanvasElement to a Base64 encoded string.
Parameters:
Name | Type | Description |
---|---|---|
canvas |
HTMLCanvasElement | The canvas to encode. |
- Source:
Returns:
A Base64 encoded string.
- Type
- string
(static) toHash(canvas) → {string}
Hash the contents of an HTMLCanvasElement to a SHA-256 hex digest.
Parameters:
Name | Type | Description |
---|---|---|
canvas |
HTMLCanvasElement | The canvas to encode. |
- Source:
Returns:
A hex digest of the SHA-256 hash of the base64 encoded string.
- Type
- string
(static) viewport(win, highlightsopt) → {HTMLCanvasElement}
Take a screenshot of the window's viewport by taking into account the current offsets.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
win |
DOMWindow | The DOM window providing the document element to capture, and the offsets for the viewport. |
|
highlights |
Array.<Node> |
<optional> |
Optional array of nodes, around which a border will be marked to highlight them in the screenshot. |
- Source:
Returns:
The canvas element where the viewport has been painted on.
- Type
- HTMLCanvasElement