summaryrefslogtreecommitdiff
path: root/js/ui/nopaint.js
diff options
context:
space:
mode:
authorJules <jules@asdf.us>2016-06-09 18:37:51 -0400
committerJules <jules@asdf.us>2016-06-09 18:37:51 -0400
commitac5a2c5a1fe7cdc98ee132c1608bbbb58bb30faa (patch)
tree94a67178037f66c62a95011c9ff08ca966935058 /js/ui/nopaint.js
parent52dc58d2dcab4ca692ac1e376798a95686eea0b5 (diff)
parent04ddff5f226dd17630a2caf1b971f30c1589a4fc (diff)
Merge branch 'master' of asdf.us:ascii
Diffstat (limited to 'js/ui/nopaint.js')
-rw-r--r--js/ui/nopaint.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/js/ui/nopaint.js b/js/ui/nopaint.js
index 74ddadf..9011953 100644
--- a/js/ui/nopaint.js
+++ b/js/ui/nopaint.js
@@ -747,6 +747,42 @@ var nopaint = (function(){
},
})
+ var SliceTool = ShaderTool.extend({
+ type: "slice",
+ dx: 0,
+ dy: 0,
+ speed: 1,
+ is_recursive: true,
+ start: function(){
+ this.__start()
+ this.is_y = Math.random() > 0.3
+ this.limit = this.is_y ? canvas.h : canvas.w
+ this.position = randint(this.limit)
+ this.direction = 1
+ },
+ before_shade: function(){
+ if (Math.random() < 0.6) {
+ this.position = mod(this.position + 1, this.limit)
+ }
+ if (Math.random() > 0.8) {
+ this.direction = randsign()
+ }
+ },
+ shade: function(src, dest, lex, x, y, w, h){
+ if (this.is_y) {
+ if (y >= this.position) {
+ var copy = src.get(x + this.direction, y)
+ lex.assign(copy)
+ }
+ }
+ else if (x >= this.position) {
+ var copy = src.get(x, y + this.direction)
+ lex.assign(copy)
+ }
+ return true
+ },
+ })
+
var ScaleTool = ShaderTool.extend({
type: "scale",
scale: 1,
@@ -848,6 +884,7 @@ var nopaint = (function(){
nopaint.add_tool( new CycleTool({ weight: 1 }) )
nopaint.add_tool( new ScaleTool({ weight: 3 }) )
nopaint.add_tool( new RotateTool({ weight: 3 }) )
+ nopaint.add_tool( new SliceTool({ weight: 4 }) )
nopaint.add_tool( new ColorizeTool({ weight: 1 }) )
nopaint.regenerate_weights()