diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-05-06 01:57:11 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-05-06 01:57:11 -0400 |
| commit | f650127c109fb65a589388cefb51eb990b151612 (patch) | |
| tree | 026bbb4921cd103b4eec3636393f537c6e903299 /js/ui/controls.js | |
| parent | 05f454468e71d61ae4f0674223066efa118955b0 (diff) | |
experimental palette
Diffstat (limited to 'js/ui/controls.js')
| -rw-r--r-- | js/ui/controls.js | 74 |
1 files changed, 30 insertions, 44 deletions
diff --git a/js/ui/controls.js b/js/ui/controls.js index 734472d..1a8011c 100644 --- a/js/ui/controls.js +++ b/js/ui/controls.js @@ -7,18 +7,14 @@ var controls = (function(){ brush.generate = controls.cross.generate brush.generate() drawing = true - filling = false brush.modified = false } controls.cross.generate = function(){ - brush.forEach(function(lex,x,y) { - if ((x+y)%2) { - lex.clear() - } - else { - lex.assign(brush) - } - }) + brush.fill(brush) + blit.cross(brush) + } + controls.cross.done = function(){ + drawing = false } controls.circle = new Tool (circle_el) @@ -29,20 +25,11 @@ var controls = (function(){ brush.modified = false } controls.circle.generate = function(){ - var fg = brush.fg, bg = brush.bg - var hw = brush.w/2|0, hh = brush.h/2|0 - brush.forEach(function(lex,x,y) { - var len = Math.sqrt(Math.pow(x-hw,2)+Math.pow(y-hh,2)) - if (len > Math.abs(hw)) { - lex.clear() - } - else { - lex.assign(brush) - } - }) + brush.fill(brush) + blit.circle(brush) } controls.circle.done = function(){ - drawing = false + drawing = false } controls.square = new Tool (square_el) @@ -53,11 +40,10 @@ var controls = (function(){ drawing = true } controls.square.generate = function(){ - var fg = brush.fg, bg = brush.bg - brush.fill(fg,bg) + brush.fill(brush) } controls.square.done = function(){ - drawing = false + drawing = false } controls.text = new Tool (text_el) @@ -82,7 +68,7 @@ var controls = (function(){ document.body.classList.add("bucket") } controls.fill.done = function(){ - filling = false + filling = false document.body.classList.remove("bucket") } @@ -93,26 +79,26 @@ var controls = (function(){ controls.webcam = new Tool (webcam_el) controls.webcam.load = function(){ - this.loaded = true - webcam_close.addEventListener("click", function(){ controls.webcam.blur() }) - window.addEventListener("message", function(e){ - if (e.origin !== window.location.origin) return - controls.webcam.blur() - controls.circle.focus() - import_textarea.value = e.data - clipboard.import_colorcode() - }) + this.loaded = true + webcam_close.addEventListener("click", function(){ controls.webcam.blur() }) + window.addEventListener("message", function(e){ + if (e.origin !== window.location.origin) return + controls.webcam.blur() + controls.circle.focus() + import_textarea.value = e.data + clipboard.import_colorcode() + }) } controls.webcam.use = function(){ - if (! this.loaded) { - this.load() - } - webcam_iframe.src = "webcam.html" - webcam_rapper.style.display = "block" + if (! this.loaded) { + this.load() + } + webcam_iframe.src = "webcam.html" + webcam_rapper.style.display = "block" } controls.webcam.done = function(){ - webcam_iframe.src = "" - webcam_rapper.style.display = "none" + webcam_iframe.src = "" + webcam_rapper.style.display = "none" } controls.grid = new Checkbox (grid_el) @@ -281,9 +267,9 @@ var controls = (function(){ canvas.resize(canvas.w, h) } - add_custom_el.addEventListener("click", function(){ - custom.clone() - }) + add_custom_el.addEventListener("click", function(){ + custom.clone() + }) } |
