feat: 绘制基础类重构

This commit is contained in:
R524809
2026-04-10 15:06:11 +08:00
parent a911da6181
commit e74fd3709c
17 changed files with 1091 additions and 278 deletions
+11 -12
View File
@@ -1,3 +1,8 @@
/**
* 找一找涂色,文字涂色服务
* 根据文字列表绘制到Canvas
*/
import { BaseDrawService } from '../core/draw/baseDraw';
/**
* 计算示例区域圆的中心点
@@ -70,16 +75,11 @@ class TextDrawService extends BaseDrawService {
this.clear();
this.setPaper();
// 绘制Header
if (this.headerType !== 'minimal') {
await this.drawHeader();
} else {
await this.drawMiniHeader();
}
await this.drawHeader();
this.drawDivider();
this.drawLegend();
this.drawContent();
await this.drawPrintFooter();
}
/** 绘制示例
@@ -94,13 +94,12 @@ class TextDrawService extends BaseDrawService {
const { ctx, colors, characters } = this;
if (characters.length <= 0) return;
// 逻辑像素尺寸(原始尺寸除以3
this.currentY = this.headerType === 'minimal' ? 68 : 110; // 200/3≈67, 304/3≈101
const legendTopY = this.currentY;
const radius = 22; // 65/3≈22
const rectWidth = 60; // 180/3=60
const rectHeight = 27; // 80/3≈27
const startX = 87 + radius; // (260+65)/3≈108
const startY = this.currentY + 10 + radius; // (30+65)/3≈32
const startY = legendTopY + 10 + radius; // (30+65)/3≈32
const len = characters.length || 4;
const centers = calculateCircleCenters(
this.canvasWidth,
@@ -148,7 +147,7 @@ class TextDrawService extends BaseDrawService {
);
});
this.currentY = this.headerType === 'minimal' ? 178 : 230; // 522/3=174, 612/3=204
this.currentY = startY + radius + 14 + rectHeight + 24;
this.drawDivider();
}
@@ -157,7 +156,7 @@ class TextDrawService extends BaseDrawService {
if (characters.length <= 0) return;
const len = characters.length;
const rows = this.headerType === 'minimal' ? 9 : 8;
const rows = 8;
const radius = 27; // 80/3≈27
const fontSize = 24; // 72/3=24