57 lines
1.5 KiB
TypeScript
57 lines
1.5 KiB
TypeScript
import { BaseMathDrawService } from './baseMathDraw';
|
|
import { drawCountMatchContent } from './countMatchContentDraw';
|
|
|
|
/**
|
|
* 数一数连一连绘制服务
|
|
* 组合使用基础绘制服务和内容区域绘制服务
|
|
*/
|
|
class CountMatchDraw extends BaseMathDrawService {
|
|
matchData: {
|
|
leftNumbers: number[];
|
|
rightNumbers: number[]; // 打乱顺序后的数字数组
|
|
} | null;
|
|
|
|
constructor(
|
|
canvas: Canvas,
|
|
ctx: RenderingContext,
|
|
options?: Record<string, any>,
|
|
) {
|
|
super(canvas, ctx, options);
|
|
this.matchData = null;
|
|
}
|
|
|
|
async draw(
|
|
matchData: { leftNumbers: number[]; rightNumbers: number[] },
|
|
imageType: string = 'twelve-animals',
|
|
) {
|
|
if (!matchData || !matchData.leftNumbers || !matchData.rightNumbers) {
|
|
return;
|
|
}
|
|
|
|
this.setPrintConfig();
|
|
this.matchData = matchData;
|
|
this.clear();
|
|
this.setPaper();
|
|
|
|
// 绘制Header
|
|
if (this.headerType !== 'minimal') {
|
|
await this.drawHeader();
|
|
} else {
|
|
this.drawMiniHeader();
|
|
}
|
|
|
|
// 绘制内容区域(数一数连一连)
|
|
this.drawDivider();
|
|
await drawCountMatchContent({
|
|
canvas: this.canvas,
|
|
ctx: this.ctx,
|
|
matchData: this.matchData,
|
|
canvasWidth: this.canvasWidth,
|
|
startY: this.currentY,
|
|
imageType,
|
|
});
|
|
}
|
|
}
|
|
|
|
export default CountMatchDraw;
|