diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-12-12 00:05:37 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-12-12 00:05:37 -0500 |
| commit | a0b65f2e1a81b6fec30b4c1c2b2764c8dbcd64a9 (patch) | |
| tree | be95e2ee25e68d4543216007fdb9cf4345ea5d3e /js/ui | |
| parent | 4c7134419292002e1ff4c6b6100a7a9ec37ced43 (diff) | |
flood fill
Diffstat (limited to 'js/ui')
| -rw-r--r-- | js/ui/brush.js | 2 | ||||
| -rw-r--r-- | js/ui/canvas.js | 3 | ||||
| -rw-r--r-- | js/ui/controls.js | 12 |
3 files changed, 16 insertions, 1 deletions
diff --git a/js/ui/brush.js b/js/ui/brush.js index c7cf583..50f6e07 100644 --- a/js/ui/brush.js +++ b/js/ui/brush.js @@ -68,8 +68,10 @@ var brush = (function(){ this.expand(-i) } + brush.char = " " brush.fg = 0 brush.bg = 1 + brush.opacity = 1 return brush diff --git a/js/ui/canvas.js b/js/ui/canvas.js index c70b135..206cbee 100644 --- a/js/ui/canvas.js +++ b/js/ui/canvas.js @@ -29,6 +29,9 @@ var canvas = current_canvas = (function(){ else if (selecting) { selection.down(e, lex, point) } + else if (filling) { + draw.fill(brush, x, y) + } lex.focus() }) lex.span.addEventListener("mousemove", function(e){ diff --git a/js/ui/controls.js b/js/ui/controls.js index 293cd1d..bbf93cc 100644 --- a/js/ui/controls.js +++ b/js/ui/controls.js @@ -7,6 +7,7 @@ var controls = (function(){ brush.generate = controls.circle.generate brush.generate() drawing = true + filling = false selection.hide() brush.modified = false } @@ -30,6 +31,7 @@ var controls = (function(){ brush.generate() brush.modified = false drawing = true + filling = false selection.hide() } controls.square.generate = function(){ @@ -42,6 +44,7 @@ var controls = (function(){ brush.generate = controls.text.generate brush.generate() drawing = false + filling = false selection.hide() } controls.text.generate = function(){ @@ -50,9 +53,15 @@ var controls = (function(){ controls.select = new Tool (select_el) controls.select.use = function(){ drawing = false + filling = false selection.show() } - controls.text.generate = function(){ + + controls.fill = new Tool (fill_el) + controls.fill.use = function(){ + drawing = false + filling = true + selection.hide() } controls.clear = new Tool (clear_el) @@ -137,6 +146,7 @@ var controls = (function(){ controls.square, controls.circle, controls.text, + controls.fill, controls.select, controls.clear, controls.grid, |
