Mondphasenexport verbessert
This commit is contained in:
@@ -2973,7 +2973,10 @@ function getMonthChartExportLogo() {
|
||||
return monthChartExportLogoPromise;
|
||||
}
|
||||
|
||||
async function composeExportCanvas(sourceCanvas, logoPosition) {
|
||||
async function composeExportCanvas(sourceCanvas, logoPosition, options) {
|
||||
const exportOptions = options && typeof options === 'object' ? options : {};
|
||||
const showCaption = exportOptions.showCaption !== false;
|
||||
const logoScale = Number.isFinite(Number(exportOptions.logoScale)) ? Number(exportOptions.logoScale) : 1;
|
||||
const exportCanvas = document.createElement('canvas');
|
||||
exportCanvas.width = sourceCanvas.width;
|
||||
exportCanvas.height = sourceCanvas.height;
|
||||
@@ -2990,7 +2993,7 @@ async function composeExportCanvas(sourceCanvas, logoPosition) {
|
||||
const logo = await getMonthChartExportLogo();
|
||||
if (logo) {
|
||||
const padding = Math.round(exportCanvas.width * 0.024);
|
||||
const targetWidth = Math.max(180, Math.min(320, Math.round(exportCanvas.width * 0.14)));
|
||||
const targetWidth = Math.max(90, Math.min(320, Math.round(exportCanvas.width * 0.14 * logoScale)));
|
||||
const targetHeight = Math.round(targetWidth * (logo.naturalHeight / Math.max(1, logo.naturalWidth)));
|
||||
const drawX = padding;
|
||||
const drawY = logoPosition === 'bottom-left'
|
||||
@@ -3000,7 +3003,7 @@ async function composeExportCanvas(sourceCanvas, logoPosition) {
|
||||
}
|
||||
|
||||
const caption = monthChartExportCaption();
|
||||
if (caption !== '') {
|
||||
if (showCaption && caption !== '') {
|
||||
const padding = Math.round(exportCanvas.width * 0.024);
|
||||
const fontSize = Math.max(26, Math.round(exportCanvas.width * 0.022));
|
||||
exportCtx.save();
|
||||
@@ -3509,7 +3512,7 @@ function monthChartCometRaDec(comet, date) {
|
||||
const exportWidth = MONTH_CHART_EXPORT_WIDTH;
|
||||
const exportHeight = Math.round(exportWidth * (220 / 1200));
|
||||
renderPhaseCanvas(exportWidth, exportHeight, 1, false);
|
||||
composeExportCanvas(canvas, 'bottom-left').then(function (exportCanvas) {
|
||||
composeExportCanvas(canvas, 'bottom-left', { showCaption: false, logoScale: 0.6 }).then(function (exportCanvas) {
|
||||
triggerCanvasDownload(exportCanvas || canvas, monthPhaseExportFilename());
|
||||
});
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user