diff options
| author | Jules Laplace <jules@okfoc.us> | 2016-05-10 22:55:35 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2016-05-10 22:55:35 -0400 |
| commit | 792c0fa390fe23efcf98049a14b8e3880987bf30 (patch) | |
| tree | b5c3994a69e14af7ef2734ea959e108349f397eb /js/ui | |
| parent | 63e1ae4898aeac4073f887bb1db9156286b08c63 (diff) | |
randomly slide the canvas
Diffstat (limited to 'js/ui')
| -rw-r--r-- | js/ui/nopaint.js | 59 |
1 files changed, 49 insertions, 10 deletions
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) |
