Skip to content

Commit

Permalink
📝 Improve function naming and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Xen0Xys committed Jun 12, 2024
1 parent 76df6f1 commit 8779f6d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
11 changes: 9 additions & 2 deletions src/js/Aladin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2180,8 +2180,15 @@ aladin.on("positionChanged", ({ra, dec}) => {
return canvasDataURL;
};

Aladin.prototype.getViewImageBuffer = async function (withLogo) {
return await this.view.getCanvasBuffer("image/png", null, null, withLogo);
/**
* Return the current view as a png ArrayBuffer
* Parameters :
* - withLogo (optional): boolean to display the Aladin Lite logo
*
* @API
*/
Aladin.prototype.getViewArrayBuffer = async function (withLogo) {
return await this.view.getCanvasArrayBuffer("image/png", null, null, withLogo);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/js/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ export let View = (function () {
this.catalogCanvas.style.cursor = cursor;
};

View.prototype.getCanvasContext = async function (imgType, width, height, withLogo=true) {
View.prototype.getCanvas = async function (imgType, width, height, withLogo=true) {
const loadImage = function (url) {
return new Promise((resolve, reject) => {
const image = new Image()
Expand Down Expand Up @@ -480,18 +480,18 @@ export let View = (function () {
}

/**
* return dataURL string corresponding to the current view
* Return dataURL string corresponding to the current view
*/
View.prototype.getCanvasDataURL = async function (imgType, width, height, withLogo=true) {
const c = await this.getCanvasContext(imgType, width, height, withLogo);
const c = await this.getCanvas(imgType, width, height, withLogo);
return c.toDataURL(imgType);
};

/**
* return ArrayBuffer corresponding to the current view
* Return ArrayBuffer corresponding to the current view
*/
View.prototype.getCanvasBuffer = async function (imgType, width, height, withLogo=true) {
const c = await this.getCanvasContext(imgType, width, height, withLogo);
View.prototype.getCanvasArrayBuffer = async function (imgType, width, height, withLogo=true) {
const c = await this.getCanvas(imgType, width, height, withLogo);
return new Promise((resolve, reject) => {
c.toBlob(blob => {
if (blob) {
Expand Down

0 comments on commit 8779f6d

Please sign in to comment.