guido = {
const col_top = ['#fff','#ccc','#999','#666','#333','#000','#333','#666','#999','#ccc'];
const col_down = ['#fff','#ccc','#999','#666','#333','#000','#333','#666','#999','#ccc'];
const shift_top = 2;
const shift_down = 2;
const u = 10;
const wu = 320;
const hu = 320;
const width = wu*u;
const height = hu*u;
const margin = u*8;
const board_height = height/2.4 + 2*margin;
const board_width = width/2.4 + 2*margin;
const u_diamond = 0.71;
let data_top, data_down, new_top, new_down, r, l, x, y, digit_top, digit_down, tx, ty;
const { canvas, context } = createCanvas(board_width, board_height);
const pixelRatio = resize(canvas, board_width, board_height, );
context.scale(pixelRatio, pixelRatio);
context.globalAlpha = 1;
context.fillStyle = '#fff';
context.fillRect(0, 0, board_width, board_height);
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 = 0; w < wu; ++w) {
if(w < h){
new_top = 0;
new_down = 0;
} else {
r = data_top[h-1][w];
l = data_top[h-1][w-1];
new_top = alg_down(l, r);
r = data_down[h-1][w];
l = data_down[h-1][w-1];
new_down = alg_down(l, r);
}
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) {
context.resetTransform();
digit_top = data_top[h][w];
if(w > h){
x = w*u - h*u/2 + u/2 + margin;
y = height/2 - h*u/2 - u/2 + margin;
context.translate(x, y);
context.rotate(Math.PI / 4);
context.translate(-1*x, -1*y);
digit_top = (digit_top + shift_top)%10;
context.fillStyle = col_top[digit_top];
context.fillRect(x, y, u*u_diamond, u*u_diamond);
context.resetTransform();
}
digit_down = data_down[h][w];
if(w > h & h>0){
x = w*u - h*u/2 + u/2 + margin;
y = height/2 + h*u/2 - u/2 + margin;
context.translate(x, y);
context.rotate(Math.PI / 4);
context.translate(-1*x, -1*y);
digit_down = (digit_down + shift_down)%10;
context.fillStyle = col_down[digit_down];
context.fillRect(x, y, u*u_diamond, u*u_diamond);
context.resetTransform();
}
}
}
return canvas;
}