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
+15 -10
View File
@@ -1,3 +1,14 @@
/**
* 图形涂色服务
* 根据图形类型绘制到Canvas
*
* 支持的图形类型:
* - circle:圆形
* - ellipse:椭圆
* - square:正方形
* - rectangle:矩形
* - triangle:三角形
*/
import { BaseDrawService } from '../core/draw/baseDraw';
import { ShapeCard } from '../constants/shapes';
import { drawShape } from './drawShape';
@@ -25,12 +36,7 @@ class ShapeDrawService 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();
@@ -40,12 +46,11 @@ class ShapeDrawService extends BaseDrawService {
const { ctx, shapes } = this;
if (shapes.length <= 0) return;
// 逻辑像素尺寸(原始尺寸除以3
this.currentY = this.headerType === 'minimal' ? 75 : 110; // 200/3≈67, 304/3≈101
const legendTopY = this.currentY;
const shapeSize = 67; // 200/3≈67
const rectWidth = 60; // 180/3=60
const rectHeight = 27; // 80/3≈27
const startY = this.currentY + 42; // 125/3≈42
const startY = legendTopY + 42; // 125/3≈42
const len = shapes.length;
// 计算示例图形的间距
@@ -76,7 +81,7 @@ class ShapeDrawService extends BaseDrawService {
);
});
this.currentY = this.headerType === 'minimal' ? 180 : 220; // 532/3≈177, 622/3≈207
this.currentY = startY + shapeSize / 2 + 3 + rectHeight + 28;
this.drawDivider();
}