function sierpinski(sketch, A, B, C, nivel) {
if(nivel == 0) {
sketch.fill(0,0,255);
sketch.triangle(A[0],A[1],B[0],B[1],C[0],C[1]);
} else {
let D = [];
let E = [];
let F = [];
pontoNoSegmento(A,C,D,0.5);
pontoNoSegmento(C,B,E,0.5);
pontoNoSegmento(B,A,F,0.5);
sierpinski(sketch,A,D,F,nivel-1);
sierpinski(sketch,D,C,E,nivel-1);
sierpinski(sketch,F,E,B,nivel-1);
}
}