diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-11-22 18:32:08 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-11-22 18:32:08 -0500 |
| commit | 5907322e23673884ceb48d2a07f930337bdf18db (patch) | |
| tree | b4135ed5c0dca4959d0c618484af40cfcf980fcd /js/draw.js | |
| parent | 8c544b08e8a855635007147cf21e795d74876025 (diff) | |
stroking brush
Diffstat (limited to 'js/draw.js')
| -rw-r--r-- | js/draw.js | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -4,11 +4,22 @@ function draw (lex, x, y, erasing) { stamp (canvas, brush, x, y, erasing) } +function line (lex, a, b, erasing) { + var len = dist(a[0], a[1], b[0], b[1]) + var bw = 1 + var x, y, i; + for (var i = 0; i < len; i += bw) { + x = lerp(i / len, a[0], b[0]) + y = lerp(i / len, a[1], b[1]) + 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 + s = round( s + x-hh ) + t = round( t + y-hh ) if (s >= 0 && s < canvas.w && t >= 0 && t < canvas.h) { if (erasing) { canvas.aa[t][s].erase(lex) |
