summaryrefslogtreecommitdiff
path: root/js/ui/brush.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/ui/brush.js')
-rw-r--r--js/ui/brush.js120
1 files changed, 60 insertions, 60 deletions
diff --git a/js/ui/brush.js b/js/ui/brush.js
index 9bc80a5..4cf7495 100644
--- a/js/ui/brush.js
+++ b/js/ui/brush.js
@@ -1,60 +1,60 @@
var brush = (function(){
-
- var brush = new Matrix (5, 5, function(x,y){
- var lex = new Lex (x,y)
- lex.build()
- return lex
- })
+
+ var brush = new Matrix (5, 5, function(x,y){
+ var lex = new Lex (x,y)
+ lex.build()
+ return lex
+ })
- brush.modified = false
+ brush.modified = false
brush.bind = function(){
- var last_point = [0,0]
- var dragging = false
+ var last_point = [0,0]
+ var dragging = false
- brush.forEach(function(lex, x, y){
+ brush.forEach(function(lex, x, y){
- if (lex.bound) return
- lex.bound = true
-
- var point = [x,y]
- lex.span.addEventListener('contextmenu', function(e){
- e.preventDefault()
- })
- lex.span.addEventListener('mousedown', function(e){
- e.preventDefault()
- current_canvas = brush
- brush.modified = true
- dragging = true
- erasing = (e.which == "3" || e.ctrlKey)
- if (erasing) {
- lex.clear()
- }
- else {
- lex.fill(brush.fg, brush.bg)
- }
- lex.focus()
- })
- lex.span.addEventListener('mousemove', function(e){
- e.preventDefault()
- if (! dragging) {
- return
- }
- erasing = (e.which == "3" || e.ctrlKey)
- if (erasing) {
- lex.clear()
- }
- else {
- lex.fill(brush.fg, brush.bg)
- }
- lex.focus()
- })
- })
- window.addEventListener("mouseup", function(){
- dragging = false
- })
- }
+ if (lex.bound) return
+ lex.bound = true
+
+ var point = [x,y]
+ lex.span.addEventListener('contextmenu', function(e){
+ e.preventDefault()
+ })
+ lex.span.addEventListener('mousedown', function(e){
+ e.preventDefault()
+ current_canvas = brush
+ brush.modified = true
+ dragging = true
+ erasing = (e.which == "3" || e.ctrlKey)
+ if (erasing) {
+ lex.clear()
+ }
+ else {
+ lex.fill(brush.fg, brush.bg)
+ }
+ lex.focus()
+ })
+ lex.span.addEventListener('mousemove', function(e){
+ e.preventDefault()
+ if (! dragging) {
+ return
+ }
+ erasing = (e.which == "3" || e.ctrlKey)
+ if (erasing) {
+ lex.clear()
+ }
+ else {
+ lex.fill(brush.fg, brush.bg)
+ }
+ lex.focus()
+ })
+ })
+ window.addEventListener("mouseup", function(){
+ dragging = false
+ })
+ }
brush.expand = function(i){
var w = this.w = clamp(this.w+i, 1, 9), h = this.h = clamp(this.h+i, 1, 9)
@@ -68,15 +68,15 @@ var brush = (function(){
this.expand(-i)
}
- brush.char = " "
- brush.fg = 0
- brush.bg = 1
- brush.opacity = 1
-
- brush.draw_fg = true
- brush.draw_bg = true
- brush.draw_char = true
-
- return brush
+ brush.char = " "
+ brush.fg = 0
+ brush.bg = 1
+ brush.opacity = 1
+
+ brush.draw_fg = true
+ brush.draw_bg = true
+ brush.draw_char = true
+
+ return brush
})() \ No newline at end of file