+9
-3
@@ -987,6 +987,8 @@ function drawGridCountdownTemplate() {
|
|||||||
const rows = Math.max(1, Math.ceil(items.length / cols));
|
const rows = Math.max(1, Math.ceil(items.length / cols));
|
||||||
const cardWidth = (canvas.width - 24 * scaleX - gap * (cols - 1)) / cols;
|
const cardWidth = (canvas.width - 24 * scaleX - gap * (cols - 1)) / cols;
|
||||||
const cardHeight = (contentHeight - gap * (rows - 1)) / rows;
|
const cardHeight = (contentHeight - gap * (rows - 1)) / rows;
|
||||||
|
const cardAreaRatio = Math.sqrt((cardWidth * cardHeight) / ((canvas.width * canvas.height) / 6));
|
||||||
|
const densityBoost = items.length <= 1 ? 1.65 : items.length === 2 ? 1.45 : items.length <= 4 ? 1.22 : 1;
|
||||||
|
|
||||||
items.forEach((item, index) => {
|
items.forEach((item, index) => {
|
||||||
const col = index % cols;
|
const col = index % cols;
|
||||||
@@ -1004,7 +1006,9 @@ function drawGridCountdownTemplate() {
|
|||||||
ctx.fillText('*', x + cardWidth - 8 * scaleX, y + 14 * scaleY);
|
ctx.fillText('*', x + cardWidth - 8 * scaleX, y + 14 * scaleY);
|
||||||
}
|
}
|
||||||
|
|
||||||
const nameSize = fitText(ctx, item.name, cardWidth - 18 * scaleX, Math.min(cardHeight * 0.22, 24 * scale), Math.max(11, 12 * scale), 'Microsoft YaHei', 'bold');
|
const namePreferredSize = Math.min(cardHeight * 0.24, 24 * scale * cardAreaRatio * densityBoost);
|
||||||
|
const nameMinSize = Math.max(11, 12 * scale);
|
||||||
|
const nameSize = fitText(ctx, item.name, cardWidth - 18 * scaleX, namePreferredSize, nameMinSize, 'Microsoft YaHei', 'bold');
|
||||||
ctx.fillStyle = '#000000';
|
ctx.fillStyle = '#000000';
|
||||||
ctx.textAlign = 'center';
|
ctx.textAlign = 'center';
|
||||||
ctx.font = `bold ${nameSize}px Microsoft YaHei`;
|
ctx.font = `bold ${nameSize}px Microsoft YaHei`;
|
||||||
@@ -1023,7 +1027,9 @@ function drawGridCountdownTemplate() {
|
|||||||
unitText = '天';
|
unitText = '天';
|
||||||
}
|
}
|
||||||
|
|
||||||
const numberSize = fitText(ctx, valueText, cardWidth * (unitText ? 0.5 : 0.72), Math.min(cardHeight * 0.44, 56 * scale), Math.max(16, 18 * scale), 'Arial Black', '900');
|
const numberPreferredSize = Math.min(cardHeight * 0.56, 56 * scale * cardAreaRatio * densityBoost);
|
||||||
|
const numberMinSize = Math.max(16, 18 * scale);
|
||||||
|
const numberSize = fitText(ctx, valueText, cardWidth * (unitText ? 0.5 : 0.72), numberPreferredSize, numberMinSize, 'Arial Black', '900');
|
||||||
ctx.fillStyle = valueColor;
|
ctx.fillStyle = valueColor;
|
||||||
ctx.font = `900 ${numberSize}px Arial Black`;
|
ctx.font = `900 ${numberSize}px Arial Black`;
|
||||||
const centerY = y + cardHeight * 0.68;
|
const centerY = y + cardHeight * 0.68;
|
||||||
@@ -1032,7 +1038,7 @@ function drawGridCountdownTemplate() {
|
|||||||
const numberWidth = ctx.measureText(valueText).width;
|
const numberWidth = ctx.measureText(valueText).width;
|
||||||
ctx.fillText(valueText, x + cardWidth / 2 - 8 * scaleX, centerY);
|
ctx.fillText(valueText, x + cardWidth / 2 - 8 * scaleX, centerY);
|
||||||
ctx.fillStyle = '#000000';
|
ctx.fillStyle = '#000000';
|
||||||
ctx.font = `bold ${Math.max(10, numberSize * 0.3)}px Microsoft YaHei`;
|
ctx.font = `bold ${Math.max(10, numberSize * 0.34)}px Microsoft YaHei`;
|
||||||
ctx.textAlign = 'left';
|
ctx.textAlign = 'left';
|
||||||
ctx.fillText(unitText, x + cardWidth / 2 - 8 * scaleX + numberWidth / 2 + 4 * scaleX, centerY + 6 * scaleY);
|
ctx.fillText(unitText, x + cardWidth / 2 - 8 * scaleX + numberWidth / 2 + 4 * scaleX, centerY + 6 * scaleY);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user