Skip to content

Commit

Permalink
🎨 Move getViewData from View.js to Aladin.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Xen0Xys committed Jun 12, 2024
1 parent 45cab01 commit be7bcea
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
24 changes: 24 additions & 0 deletions src/js/Aladin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 0 additions & 13 deletions src/js/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit be7bcea

Please sign in to comment.