Cytoscape: export image to Blob

This commit is contained in:
Cerberuser
2018-06-29 14:40:50 +07:00
parent 231b41bccf
commit 7f9333c308
2 changed files with 47 additions and 9 deletions
+25 -2
View File
@@ -343,17 +343,29 @@ const positions = oneOf({a: {x: 100, y: 100}}, (node: cytoscape.NodeCollection):
// TODO: cy.style
// $ExpectType String
cy.png({
output: oneOf('base64uri', 'base64', 'blob', undefined),
output: oneOf('base64uri', 'base64', undefined),
bg: oneOf('#ffffff', undefined),
full: true,
scale: 2,
maxWidth: 100,
maxHeight: 100
});
// $ExpectType Blob
cy.png({
output: 'blob',
bg: oneOf('#ffffff', undefined),
full: true,
scale: 2,
maxWidth: 100,
maxHeight: 100
});
aliases(cy.jpg, cy.jpeg);
// $ExpectType String
cy.jpg({
output: oneOf('base64uri', 'base64', 'blob', undefined),
output: oneOf('base64uri', 'base64', undefined),
bg: oneOf('#ffffff', undefined),
full: true,
scale: 2,
@@ -361,6 +373,17 @@ cy.jpg({
maxHeight: 100,
quality: 0.5
});
// $ExpectType Blob
cy.jpg({
output: 'blob',
bg: oneOf('#ffffff', undefined),
full: true,
scale: 2,
maxWidth: 100,
maxHeight: 100,
quality: 0.5
});
cy.json(cy.json());
// Types possible to call methods
+22 -7
View File
@@ -1052,10 +1052,6 @@ declare namespace cytoscape {
* http://js.cytoscape.org/#core/export
*/
interface ExportOptions {
/**
* output Whether the output should be 'base64uri' (default), 'base64', or 'blob'.
*/
output?: "base64uri" | "base64" | "blob";
/**
* The background colour of the image (transparent by default).
*/
@@ -1077,6 +1073,18 @@ declare namespace cytoscape {
*/
maxHeight?: number;
}
interface ExportStringOptions extends ExportOptions {
/**
* output Whether the output should be 'base64uri' (default), 'base64', or 'blob'.
*/
output?: "base64uri" | "base64";
}
interface ExportBlobOptions extends ExportOptions {
/**
* output Whether the output should be 'base64uri' (default), 'base64', or 'blob'.
*/
output?: "blob";
}
interface ExportJpgOptions extends ExportOptions {
/**
@@ -1086,22 +1094,29 @@ declare namespace cytoscape {
*/
quality?: number;
}
interface ExportJpgStringOptions extends ExportJpgOptions, ExportStringOptions {
}
interface ExportJpgBlobOptions extends ExportJpgOptions, ExportBlobOptions {
}
interface CoreExport {
/**
* Export the current graph view as a PNG image in Base64 representation.
*/
png(options?: ExportOptions): string;
png(options?: ExportStringOptions): string;
png(options?: ExportBlobOptions): Blob;
/**
* Export the current graph view as a JPG image in Base64 representation.
*/
jpg(options?: ExportJpgOptions): string;
jpg(options?: ExportJpgStringOptions): string;
jpg(options?: ExportJpgBlobOptions): Blob;
/**
* Export the current graph view as a JPG image in Base64 representation.
*/
jpeg(options?: ExportJpgOptions): string;
jpeg(options?: ExportJpgStringOptions): string;
jpeg(options?: ExportJpgBlobOptions): Blob;
/**
* Export the graph as JSON, the same format used at initialisation.