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.js44
1 files changed, 34 insertions, 10 deletions
diff --git a/js/ui/brush.js b/js/ui/brush.js
index e1d140d..90422b7 100644
--- a/js/ui/brush.js
+++ b/js/ui/brush.js
@@ -43,7 +43,8 @@ var brush = (function(){
fillColor = brush.bg
lex.fill(brush)
}
- lex.focus()
+ brush.focus(x, y)
+ // lex.focus()
})
lex.span.addEventListener('mousemove', function(e){
e.preventDefault()
@@ -57,7 +58,8 @@ var brush = (function(){
else {
lex.fill(brush)
}
- lex.focus()
+ brush.focus(x, y)
+ //lex.focus()
})
})
window.addEventListener('mouseup', function(e){
@@ -65,16 +67,35 @@ var brush = (function(){
})
}
- brush.expand = function(i){
- var w = this.w = clamp(this.w+i, 1, 9), h = this.h = clamp(this.h+i, 1, 9)
- controls.width.char = ""+w
- controls.width.build()
- controls.height.char = ""+h
- controls.height.build()
+ brush.resize = function(w, h, min, max){
+ this.w = clamp(w, this.min, this.max)
+ this.h = clamp(h, this.min, this.max)
+ // brush.__proto__.resize.call(brush, w, h)
+ // this.w = w
+ // this.h = h
this.rebuild()
+ //brush.__proto__.rebuild.call(brush, w, h)
+ controls.brush_w.char = ""+this.w
+ controls.brush_w.build()
+ controls.brush_h.char = ""+this.h
+ controls.brush_h.build()
+ }
+ brush.size_add = function(w, h){
+ brush.resize(brush.w + w, brush.h + h)
+ }
+
+ brush.expand = function(i){
+ brush.size_add(i, i)
+ // var w = this.w = clamp(this.w+i, 1, 9), h = this.h = clamp(this.h+i, 1, 9)
+ // controls.width.char = ""+w
+ // controls.width.build()
+ // controls.height.char = ""+h
+ // controls.height.build()
+ // this.rebuild()
}
brush.contract = function(i){
- this.expand(-i)
+ brush.size_add(-i, -i)
+ // this.expand(-i)
}
brush.load = function(lex){
@@ -84,6 +105,9 @@ var brush = (function(){
brush.opacity = 1
}
+ brush.min = 1
+ brush.max = 100
+
brush.char = " "
brush.fg = 0
brush.bg = 1
@@ -95,4 +119,4 @@ var brush = (function(){
return brush
-})() \ No newline at end of file
+})()