summaryrefslogtreecommitdiff
path: root/js/ui/nopaint.js
diff options
context:
space:
mode:
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()