From 07c329b44d29d63a57d53c375bc95e877f9f3dca Mon Sep 17 00:00:00 2001 From: Fr3deric Date: Sun, 10 Mar 2019 00:07:48 +0100 Subject: [PATCH] more pattern types --- baumgen.js | 55 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/baumgen.js b/baumgen.js index 8ee676c..3899142 100644 --- a/baumgen.js +++ b/baumgen.js @@ -75,7 +75,7 @@ class Pattern { apply(branch) { var crownpath = branch.crown._path; for (let p of this.generate(crownpath.bounds)) { - var pp = p.intersect(crownpath, {trace: false}); + var pp = p.intersect(crownpath, {trace: this._intersect_trace}); pp.strokeWidth = 1.5; pp.strokeColor = 'black'; } @@ -89,12 +89,14 @@ class Pattern { } -class HatPattern extends Pattern { - constructor({tasize=7, grid=17}={}) +class MiniLinePattern extends Pattern { + constructor({tasize=7, grid=17, hat=true}={}) { super('hat') this.tasize = tasize; this.grid = grid; + this.hat = hat; + this._intersect_trace = false; } generate(bounds) { @@ -105,7 +107,9 @@ class HatPattern extends Pattern { var yy = bounds.y + y*this.grid; var p = new Path(); p.add(new Point(xx, yy+this.tasize)); - p.add(new Point(xx + this.tasize/2, yy)); + if(this.hat) { + p.add(new Point(xx + this.tasize/2, yy)); + } p.add(new Point(xx + this.tasize, yy+this.tasize)); ret.push(p); } @@ -114,6 +118,33 @@ class HatPattern extends Pattern { } } +class RandomCirclePattern extends Pattern { + constructor({radius=3, grid=15}={}) + { + super('hat') + this.radius = radius; + this.grid = grid; + this._intersect_trace = true; + } + + generate(bounds) { + var ret = []; + for(var y=0; y