summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/matrix.js3
-rw-r--r--js/ui/nopaint.js59
2 files changed, 51 insertions, 11 deletions
diff --git a/js/matrix.js b/js/matrix.js
index de59e17..1aeb929 100644
--- a/js/matrix.js
+++ b/js/matrix.js
@@ -58,7 +58,7 @@ Matrix.prototype.demolish = function (){
this.forEach(function(lex){
lex.demolish()
})
- while (this.rapper.firstChild) {
+ while (this.rapper && this.rapper.firstChild) {
this.rapper.removeChild(this.rapper.firstChild);
}
this.aa.forEach(function(row){
@@ -124,6 +124,7 @@ Matrix.prototype.build = function(){
}
Matrix.prototype.append = function(rapper){
rapper = this.rapper = rapper || this.rapper
+ if (! this.rapper) return
this.aa.forEach(function(row, y){
var div = document.createElement("div")
row.forEach(function(lex, x) {
diff --git a/js/ui/nopaint.js b/js/ui/nopaint.js
index 3768f39..4528cbf 100644
--- a/js/ui/nopaint.js
+++ b/js/ui/nopaint.js
@@ -4,7 +4,7 @@ var nopaint = (function(){
controls.no = new Tool (nopaint_no_el)
controls.no.use = function(state){
- undo.undo()
+ nopaint.undo()
controls.paint.focus()
}
@@ -351,16 +351,55 @@ var nopaint = (function(){
},
})
-// nopaint.add_tool( new SolidBrush({ weight: 3 }) )
-// nopaint.add_tool( new EraseBrush({ weight: 5 }) )
-// nopaint.add_tool( new RandomBrush({ weight: 4 }) )
-// nopaint.add_tool( new HueBrush({ weight: 6 }) )
-// nopaint.add_tool( new LetterBrush({ weight: 4 }) )
-// nopaint.add_tool( new RandomLetterBrush({ weight: 14 }) )
-// nopaint.add_tool( new CloneBrush({ weight: 8 }) )
-// nopaint.add_tool( new FillTool({ weight: 4 }) )
-// nopaint.add_tool( new FillLetterTool({ weight: 6 }) )
+ /* Slide Tools */
+
+ var SlideTool = NopaintTool.extend({
+ type: "slide",
+ dx: 0,
+ dy: 0,
+ speed: 5,
+ start: function(){
+ undo.save_rect(0, 0, canvas.w, canvas.h)
+ this.speed = floor(randrange(1, 3))
+ this.canvas = canvas.clone()
+ this.dx = randint(3)-1
+ this.dy = randint(3)-1
+ if (! this.dx && ! this.dy) {
+ this.dx = 1
+ this.dy = 0
+ }
+ },
+ paint: function(t){
+ if ((t % this.speed) == 0) {
+ var w = canvas.w
+ var h = canvas.h
+ var i = this.dx
+ var j = this.dy
+ this.canvas.assign(canvas)
+ for (var x = 0; x < w; x++) {
+ for (var y = 0; y < h; y++) {
+ var lex = this.canvas.get(x+i, y+j)
+ canvas.get(x, y).assign(lex)
+ }
+ }
+ }
+ },
+ finish: function(){
+ this.canvas.demolish()
+ }
+ })
+
+ nopaint.add_tool( new SolidBrush({ weight: 4 }) )
+ nopaint.add_tool( new EraseBrush({ weight: 6 }) )
+ nopaint.add_tool( new RandomBrush({ weight: 4 }) )
+ nopaint.add_tool( new HueBrush({ weight: 6 }) )
+ nopaint.add_tool( new LetterBrush({ weight: 4 }) )
+ nopaint.add_tool( new RandomLetterBrush({ weight: 16 }) )
+ nopaint.add_tool( new CloneBrush({ weight: 10 }) )
+ nopaint.add_tool( new FillTool({ weight: 4 }) )
+ nopaint.add_tool( new FillLetterTool({ weight: 6 }) )
nopaint.add_tool( new StarsTool({ weight: 6 }) )
+ nopaint.add_tool( new SlideTool({ weight: 5 }) )
nopaint.regenerate_weights()
nopaint.toggle(true)