diff options
| author | Jules Laplace <jules@okfoc.us> | 2016-06-03 20:30:16 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2016-06-03 20:30:16 -0400 |
| commit | 448e55b683d9eeda3fd0f6c96287a4f3b70bc9a1 (patch) | |
| tree | 9932c8cf3327968905c31220c78b3d01c284ac67 /js | |
| parent | 448aff387b9c25b405c9eea0127d2edca8965f61 (diff) | |
phat brushes
Diffstat (limited to 'js')
| -rw-r--r-- | js/ui/nopaint.js | 52 | ||||
| -rw-r--r-- | js/util.js | 4 |
2 files changed, 54 insertions, 2 deletions
diff --git a/js/ui/nopaint.js b/js/ui/nopaint.js index da30e37..c76d269 100644 --- a/js/ui/nopaint.js +++ b/js/ui/nopaint.js @@ -452,6 +452,57 @@ var nopaint = (function(){ this.resize(3,2) }, }) + + var ShadowBrush = NopaintBrush.extend({ + type: "shadow", + pairs: [ + [ colors.yellow, colors.orange ], + [ colors.orange, colors.darkred ], + [ colors.red, colors.darkred ], + [ colors.lime, colors.green ], + [ colors.cyan, colors.teal ], + [ colors.cyan, colors.blue ], + [ colors.blue, colors.darkblue ], + [ colors.magenta, colors.purple ], + [ colors.lightgray, colors.darkgray ], + [ colors.darkgray, colors.black ], + [ colors.white, colors.lightgray ], + [ colors.white, colors.black ], + ], + shapes: [ + [[0],[1]], + [[0,0],[1,1]], + [[1,0,0],[1,1,1]], + [[0,0,1],[1,1,1]], + [[0,0,0],[1,1,1]], + [[0,0,0,0],[1,1,1,1]], + [[1,0,0,0],[null,1,1,1]], + [[0,0,0,1],[1,1,1,null]], + [[0,0],[1,0],[1,1]], + [[0,0],[0,1],[1,1]], + ], + reset: function( last_brush ){ + var pair = choice(this.pairs) + var shape = choice(this.shapes) + this.reorient( last_brush ) + brush.char = " " + console.log(shape[0].length, shape.length) + brush.resize(shape[0].length, shape.length) + brush.generate() + brush.rebuild() + brush.forEach(function(lex,x,y){ + if (shape[y][x] == null) { + lex.opacity = 0 + } + else { + lex.fg = lex.bg = pair[ shape[y][x] ] + lex.opacity = 1 + } + lex.build() + }) + }, + regenerate: function(){}, + }) var RandomBrush = SolidBrush.extend({ type: "random", @@ -766,6 +817,7 @@ var nopaint = (function(){ }) nopaint.add_tool( new SolidBrush({ weight: 5 }) ) + nopaint.add_tool( new ShadowBrush({ weight: 10 }) ) nopaint.add_tool( new EraseBrush({ weight: 5 }) ) nopaint.add_tool( new RandomBrush({ weight: 4 }) ) nopaint.add_tool( new HueBrush({ weight: 5 }) ) @@ -58,8 +58,8 @@ function choice(a){ return a[randint(a.length)] } function deg(n){ return n*180/PI } function rad(n){ return n*PI/180 } function xor(a,b){ a=!!a; b=!!b; return (a||b) && !(a&&b) } -function mod(n,m){ return n-(m * floor(n/m)) } -function modi(n,m){ return floor(n-(m * floor(n/m))) } +function mod(n,m){ n = n % m; return n < 0 ? (m + n) : n } +function modi(n,m){ return floor(mod(n,m)) } function dist(x0,y0,x1,y1){ return sqrt(pow(x1-x0,2)+pow(y1-y0,2)) } function angle(x0,y0,x1,y1){ return atan2(y1-y0,x1-x0) } function avg(m,n,a){ return (m*(a-1)+n)/a } |
