From be7bceae980da077106e339aacaa89e4e66550f8 Mon Sep 17 00:00:00 2001 From: Xen0Xys Date: Wed, 12 Jun 2024 11:48:48 +0200 Subject: [PATCH] :art: Move getViewData from View.js to Aladin.js --- src/js/Aladin.js | 24 ++++++++++++++++++++++++ src/js/View.js | 13 ------------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/js/Aladin.js b/src/js/Aladin.js index 92d89006..d95cc7cc 100644 --- a/src/js/Aladin.js +++ b/src/js/Aladin.js @@ -2191,6 +2191,30 @@ aladin.on("positionChanged", ({ra, dec}) => { return await this.view.getCanvasArrayBuffer("image/png", null, null, withLogo); } + /** + * Return the current view as a the desired data type + * Parameters : + * - dataType: 'url', 'arraybuffer', 'blob' + * - imgType: 'image/png', 'image/jpeg' + * - width: width in pixels of the image to output + * - height: height in pixels of the image to output + * - withLogo: boolean to display the Aladin Lite logo + * + * @API + */ + View.prototype.getViewData = async function (dataType, imgType, width, height, withLogo=true){ + switch (dataType) { + case "url": + return await this.getCanvasDataURL(imgType, width, height, withLogo); + case "arraybuffer": + return await this.getCanvasArrayBuffer(imgType, width, height, withLogo); + case "blob": + return await this.getCanvasBlob(imgType, width, height, withLogo); + default: + throw new Error("Unknown data type: " + dataType); + } + } + /** * Return the current view WCS as a key-value dictionary * Can be useful in coordination with getViewDataURL diff --git a/src/js/View.js b/src/js/View.js index 5464e606..7f1bbfee 100644 --- a/src/js/View.js +++ b/src/js/View.js @@ -522,19 +522,6 @@ export let View = (function () { }); } - View.prototype.getViewData = async function (dataType, imgType, width, height, withLogo=true){ - switch (dataType) { - case "url": - return await this.getCanvasDataURL(imgType, width, height, withLogo); - case "arraybuffer": - return await this.getCanvasArrayBuffer(imgType, width, height, withLogo); - case "blob": - return await this.getCanvasBlob(imgType, width, height, withLogo); - default: - throw new Error("Unknown data type: " + dataType); - } - } - View.prototype.selectLayer = function (layer) { if (!this.imageLayers.has(layer)) { console.warn(layer + ' does not exists. So cannot be selected');