diff options
Diffstat (limited to 'js/ui/nopaint.js')
| -rw-r--r-- | js/ui/nopaint.js | 63 |
1 files changed, 53 insertions, 10 deletions
diff --git a/js/ui/nopaint.js b/js/ui/nopaint.js index fc2b5a3..da6a74b 100644 --- a/js/ui/nopaint.js +++ b/js/ui/nopaint.js @@ -126,6 +126,7 @@ var nopaint = (function(){ }, start: function(last_brush){ + this.set_brush_mask() this.toggle_channels() this.reset( last_brush ) this.regenerate() @@ -181,14 +182,30 @@ var nopaint = (function(){ return b }, + set_brush_mask: function(){ + var r = Math.random() + if (r < 0.2) { + brush.mask = blit.square + } + else if (r < 0.6) { + brush.mask = blit.circle + } + else if (r < 0.9) { + brush.mask = blit.cross + } + else{ + brush.mask = blit.inverted_cross + } + }, + toggle_channels: function(){ - if (Math.random() < 0.01) { controls.bg.use(false) } + if (Math.random() < 0.001) { controls.bg.use(false) } else if (! brush.draw_bg && Math.random() < 0.25) { controls.bg.use(true) } - if (Math.random() < 0.2) { controls.fg.use(false) } + if (Math.random() < 0.1) { controls.fg.use(false) } else if (! brush.draw_fg && Math.random() < 0.5) { controls.fg.use(true) } - if (Math.random() < 0.05) { controls.char.use(false) } + if (Math.random() < 0.02) { controls.char.use(false) } else if (! brush.draw_char && Math.random() < 0.2) { controls.char.use(true) } }, @@ -297,22 +314,47 @@ var nopaint = (function(){ var CloneBrush = SolidBrush.extend({ type: "clone", + reset: function( last_brush ){ - this.opt.max_radius = randrange(5,20) + this.opt.max_radius = randrange(5, 20) this.reorient( last_brush ) - this.__resize(4,2) - this.clone_region() + this.resize(4,2) + this.clone_random_region() }, - clone_region: function(){ + clone_random_region: function(x, y){ var x = randrange(0, canvas.w - brush.w) var y = randrange(0, canvas.h - brush.h) - blit.copy_from(canvas, brush, floor(x-brush.w/2), floor(y-brush.h/2)) + this.clone_region(x, y) + }, + + clone_region: function(x, y){ + blit.copy_from(canvas, brush, round(x-brush.w/2), round(y-brush.h/2)) brush.mask(brush) }, + iterate: function( last_brush ){ + this.reorient( last_brush ) + }, + regenerate: function(){}, - resize: function(){}, + }) + + var SmearBrush = CloneBrush.extend({ + type: "smear", + + update: function(){ + var r = random() + var jitter_x = randnullsign() * xrand(2, 2) + var jitter_y = randnullsign() * xrand(2, 2) + this.clone_region( this.p.x + jitter_x, this.p.y + jitter_y ) + }, + + iterate: function( last_brush ){ + this.resize(4, 2) + this.update() + this.reorient( last_brush ) + } }) var StarsTool = NopaintBrush.extend({ @@ -528,7 +570,8 @@ var nopaint = (function(){ 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 SmearBrush({ weight: 16 }) ) + nopaint.add_tool( new FillTool({ weight: 3 }) ) nopaint.add_tool( new FillLetterTool({ weight: 6 }) ) nopaint.add_tool( new StarsTool({ weight: 3 }) ) nopaint.add_tool( new TranslateTool({ weight: 5 }) ) |
