feat:2.4.5 数一数填一填和数一数选一选开发
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
import { BaseMathDrawService } from './baseMathDraw';
|
||||
import { drawCountingSelectContent } from './countingSelectContentDraw';
|
||||
|
||||
/**
|
||||
* 数一数选一选/填一填绘制服务
|
||||
* 组合使用基础绘制服务和内容区域绘制服务
|
||||
* 支持两种模式:'select'(选一选)和 'fill'(填一填)
|
||||
*/
|
||||
class CountingSelectDraw extends BaseMathDrawService {
|
||||
countingData: {
|
||||
problems: Array<{
|
||||
count: number;
|
||||
imageIndex: number;
|
||||
imageType: 'fruits' | 'twelve-animals';
|
||||
options?: number[];
|
||||
correctIndex?: number;
|
||||
}>;
|
||||
} | null;
|
||||
mode: 'select' | 'fill';
|
||||
|
||||
constructor(
|
||||
canvas: Canvas,
|
||||
ctx: RenderingContext,
|
||||
options?: Record<string, any>,
|
||||
) {
|
||||
super(canvas, ctx, options);
|
||||
this.countingData = null;
|
||||
this.mode = 'select'; // 默认选一选模式
|
||||
}
|
||||
|
||||
async draw(
|
||||
countingData: {
|
||||
problems: Array<{
|
||||
count: number;
|
||||
imageIndex: number;
|
||||
imageType: 'fruits' | 'twelve-animals';
|
||||
options?: number[];
|
||||
correctIndex?: number;
|
||||
}>;
|
||||
},
|
||||
mode: 'select' | 'fill' = 'select',
|
||||
) {
|
||||
if (!countingData || !countingData.problems) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.setPrintConfig();
|
||||
this.countingData = countingData;
|
||||
this.mode = mode;
|
||||
this.clear();
|
||||
this.setPaper();
|
||||
|
||||
// 绘制Header
|
||||
if (this.headerType !== 'minimal') {
|
||||
await this.drawHeader();
|
||||
} else {
|
||||
this.drawMiniHeader();
|
||||
}
|
||||
|
||||
// 绘制内容区域
|
||||
this.drawDivider();
|
||||
await drawCountingSelectContent({
|
||||
canvas: this.canvas,
|
||||
ctx: this.ctx,
|
||||
countingData: this.countingData,
|
||||
mode: this.mode,
|
||||
canvasWidth: this.canvasWidth,
|
||||
startY: this.currentY,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default CountingSelectDraw;
|
||||
Reference in New Issue
Block a user