|
|
@ -92,7 +92,7 @@ class Pattern { |
|
|
|
class MiniLinePattern extends Pattern { |
|
|
|
class MiniLinePattern extends Pattern { |
|
|
|
constructor({tasize=7, grid=17, hat=true}={}) |
|
|
|
constructor({tasize=7, grid=17, hat=true}={}) |
|
|
|
{ |
|
|
|
{ |
|
|
|
super('hat') |
|
|
|
super('miniline') |
|
|
|
this.tasize = tasize; |
|
|
|
this.tasize = tasize; |
|
|
|
this.grid = grid; |
|
|
|
this.grid = grid; |
|
|
|
this.hat = hat; |
|
|
|
this.hat = hat; |
|
|
@ -121,7 +121,7 @@ class MiniLinePattern extends Pattern { |
|
|
|
class RandomCirclePattern extends Pattern { |
|
|
|
class RandomCirclePattern extends Pattern { |
|
|
|
constructor({radius=3, grid=15}={}) |
|
|
|
constructor({radius=3, grid=15}={}) |
|
|
|
{ |
|
|
|
{ |
|
|
|
super('hat') |
|
|
|
super('randomcircle') |
|
|
|
this.radius = radius; |
|
|
|
this.radius = radius; |
|
|
|
this.grid = grid; |
|
|
|
this.grid = grid; |
|
|
|
this._intersect_trace = true; |
|
|
|
this._intersect_trace = true; |
|
|
@ -145,6 +145,35 @@ class RandomCirclePattern extends Pattern { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LinePattern extends Pattern { |
|
|
|
|
|
|
|
constructor({grid=5, angle=Math.random()*2*Math.PI}={}) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
super('line') |
|
|
|
|
|
|
|
this.grid = grid; |
|
|
|
|
|
|
|
this.angle = angle; |
|
|
|
|
|
|
|
this._intersect_trace = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
generate(bounds) { |
|
|
|
|
|
|
|
var ret = []; |
|
|
|
|
|
|
|
var r = Math.random() * 360; |
|
|
|
|
|
|
|
for(var x=0; x<bounds.width * 3; x += this.grid) { |
|
|
|
|
|
|
|
var p = new Path(); |
|
|
|
|
|
|
|
p.add(new Point(bounds.x - bounds.width + x, |
|
|
|
|
|
|
|
bounds.y - bounds.height)); |
|
|
|
|
|
|
|
p.add(new Point(bounds.x - bounds.width + x, |
|
|
|
|
|
|
|
bounds.y + bounds.height * 2)); |
|
|
|
|
|
|
|
p.rotate(this.angle * 360 / (2*Math.PI), |
|
|
|
|
|
|
|
new Point(bounds.x + bounds.width * 0.5, |
|
|
|
|
|
|
|
bounds.y + bounds.height * 0.5)); |
|
|
|
|
|
|
|
ret.push(p); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ret; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Crown { |
|
|
|
class Crown { |
|
|
|
constructor(length, width, shape) { |
|
|
|
constructor(length, width, shape) { |
|
|
@ -368,7 +397,7 @@ function draw() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var ptrn = null; |
|
|
|
var ptrn = null; |
|
|
|
var ptrnrand = Math.random() * 5; |
|
|
|
var ptrnrand = Math.random() * 6; |
|
|
|
if(ptrnrand < 1) { |
|
|
|
if(ptrnrand < 1) { |
|
|
|
ptrn = new MiniLinePattern(); |
|
|
|
ptrn = new MiniLinePattern(); |
|
|
|
} else if(ptrnrand < 2) { |
|
|
|
} else if(ptrnrand < 2) { |
|
|
@ -377,6 +406,8 @@ function draw() { |
|
|
|
ptrn = new RandomCirclePattern(); |
|
|
|
ptrn = new RandomCirclePattern(); |
|
|
|
} else if(ptrnrand < 4) { |
|
|
|
} else if(ptrnrand < 4) { |
|
|
|
ptrn = new RandomCirclePattern({radius: 1}); |
|
|
|
ptrn = new RandomCirclePattern({radius: 1}); |
|
|
|
|
|
|
|
} else if(ptrnrand < 5) { |
|
|
|
|
|
|
|
ptrn = new LinePattern({grid: 5 + Math.random() * 3}); |
|
|
|
} |
|
|
|
} |
|
|
|
if(ptrn != null) { |
|
|
|
if(ptrn != null) { |
|
|
|
ptrn.apply(t); |
|
|
|
ptrn.apply(t); |
|
|
|