1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
function draw (lex, x, y, erasing) { stamp (canvas, brush, x, y, erasing) } function stamp (canvas, brush, x, y, erasing) { hh = brush.w/2|0 brush.forEach(function(lex, s, t){ s += x-hh t += y-hh if (s >= 0 && s < canvas.w && t >= 0 && t < canvas.h) { if (erasing) { canvas.aa[t][s].erase(lex) } else { canvas.aa[t][s].clone(lex) } } }) }