feat:V2.5.5方格推理
This commit is contained in:
@@ -282,4 +282,103 @@ export class BaseDrawService {
|
||||
// 重置为实线(避免影响后续绘制)
|
||||
ctx.setLineDash([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制符号(使用路径绘制)
|
||||
* @param x 符号中心X坐标
|
||||
* @param y 符号中心Y坐标
|
||||
* @param symbol 符号类型:'+', '-', '×', '✓'
|
||||
* @param size 符号大小
|
||||
*/
|
||||
drawSymbol(x: number, y: number, symbol: string, size: number): void {
|
||||
const { ctx } = this;
|
||||
ctx.save();
|
||||
ctx.translate(x, y);
|
||||
|
||||
const lineWidth = size * 0.15; // 线条宽度
|
||||
const halfSize = size / 2;
|
||||
const strokeLength = halfSize * 0.7; // 线条长度
|
||||
|
||||
ctx.strokeStyle = '#000';
|
||||
ctx.lineWidth = lineWidth;
|
||||
ctx.lineCap = 'round';
|
||||
ctx.lineJoin = 'round';
|
||||
|
||||
switch (symbol) {
|
||||
case '+':
|
||||
// 加号:横线和竖线
|
||||
ctx.beginPath();
|
||||
// 横线
|
||||
ctx.moveTo(-strokeLength, 0);
|
||||
ctx.lineTo(strokeLength, 0);
|
||||
// 竖线
|
||||
ctx.moveTo(0, -strokeLength);
|
||||
ctx.lineTo(0, strokeLength);
|
||||
ctx.stroke();
|
||||
break;
|
||||
|
||||
case '-':
|
||||
// 减号:横线
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(-strokeLength, 0);
|
||||
ctx.lineTo(strokeLength, 0);
|
||||
ctx.stroke();
|
||||
break;
|
||||
|
||||
case '×':
|
||||
// 乘号:两条斜线
|
||||
ctx.beginPath();
|
||||
// 左上到右下
|
||||
ctx.moveTo(-strokeLength * 0.7, -strokeLength * 0.7);
|
||||
ctx.lineTo(strokeLength * 0.7, strokeLength * 0.7);
|
||||
// 右上到左下
|
||||
ctx.moveTo(strokeLength * 0.7, -strokeLength * 0.7);
|
||||
ctx.lineTo(-strokeLength * 0.7, strokeLength * 0.7);
|
||||
ctx.stroke();
|
||||
break;
|
||||
|
||||
case '✓':
|
||||
// 对号:勾,整体更大,右侧的线更长
|
||||
const checkScale = 1.2; // 对号整体放大1.2倍
|
||||
ctx.beginPath();
|
||||
const checkStartX = -strokeLength * 0.5 * checkScale;
|
||||
const checkStartY = -strokeLength * 0.2 * checkScale;
|
||||
const checkMidX = -strokeLength * 0.1 * checkScale;
|
||||
const checkMidY = strokeLength * 0.3 * checkScale;
|
||||
const checkEndX = strokeLength * 1.0 * checkScale; // 增加右侧长度
|
||||
const checkEndY = -strokeLength * 0.4 * checkScale; // 稍微向上调整
|
||||
ctx.moveTo(checkStartX, checkStartY);
|
||||
ctx.lineTo(checkMidX, checkMidY);
|
||||
ctx.lineTo(checkEndX, checkEndY);
|
||||
ctx.stroke();
|
||||
break;
|
||||
|
||||
default:
|
||||
// 默认绘制加号
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(-strokeLength, 0);
|
||||
ctx.lineTo(strokeLength, 0);
|
||||
ctx.moveTo(0, -strokeLength);
|
||||
ctx.lineTo(0, strokeLength);
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制圆点
|
||||
*/
|
||||
drawDot(
|
||||
ctx: RenderingContext,
|
||||
x: number,
|
||||
y: number,
|
||||
radius: number,
|
||||
fillColor?: string,
|
||||
) {
|
||||
ctx.fillStyle = fillColor ?? '#93D333';
|
||||
ctx.beginPath();
|
||||
ctx.arc(x, y, radius, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user