anna = {
const col = ['#00f','#000','#606','#666','#0f0','#09f','#930','#f60','#f0f','#fff'];
const col_down = ['#00f','#090','#c0c','#ccc','#0f0','#09f','#c60','#f93','#f0f','#fff'];
const u = 1.5;
const wu = 400;
const hu = 400;
const width = wu*u*2;
const height = hu*u*2;
const margin = 2*20;
const board_height = height;
const board_width = width;
let data_top, data_down, new_top, new_down, r, l, x, y, digit_top, digit_down;
let ray = 0.7;
let trans_x = (board_width - width)/2;
let trans_y = (board_height - height)/2;
const { canvas, context } = createCanvas();
const pixelRatio = resize(canvas, board_width + 2*margin, board_height + 2*margin, );
context.globalAlpha = 1;
context.scale(pixelRatio, pixelRatio);
context.fillStyle = '#000';
context.fillRect(0, 0, board_width+2*margin, board_height+2*margin);
const base = get_pi_txt(wu+1);
data_top = [[]];
data_down = [[]];
data_top[0] = base;
data_down[0] = base;
for (let h = 1; h < hu; ++h){
data_top[h] = [];
data_down[h] = [];
for (let w = 1; w < wu; ++w) {
if(w > (wu-h)){
new_top = 0;
new_down = 0;
} else {
r = data_top[h-1][w+1];
l = data_top[h-1][w];
new_top = alg_paon(l, r, 2, 10);
r = data_down[h-1][w+1];
l = data_down[h-1][w];
new_down = alg_paon(l, r, 2, 20);
}
data_top[h][w] = new_top;
data_down[h][w] = new_down;
}
}
for (let h = 0; h < hu; ++h){
for (let w = 0; w < wu; ++w) {
digit_top = data_top[h][w];
if(digit_top != 0){
x = u*w*2 + h*u + margin/2 + trans_x;
y = (hu-h)*u + margin/2 + trans_y;
context.fillStyle = col[digit_top];
context.fillRect(x, y, u, u);
}
digit_down = Math.round(data_down[h][w])%10;
if(digit_down != 0){
if(digit_top == digit_down) {
} else if(digit_top == 4 | digit_top == 9 | digit_top == digit_down){
context.globalAlpha = 1;
context.fillStyle = col_down[digit_down];
} else {
context.globalAlpha = 0.4;
context.fillStyle = col[digit_down];
}
x = u*w*2 + h*u + margin/2 + trans_x;
y = h*u + margin/2 + hu*u + trans_y;
context.fillRect(x, y, u, u);
}
context.globalAlpha = 1;
}
}
return canvas;
}