diff options
Diffstat (limited to 'env.js')
| -rw-r--r-- | env.js | 26 |
1 files changed, 11 insertions, 15 deletions
@@ -253,11 +253,11 @@ var environment = (function(){ return scale_f } environment.quantize_index = function(index){ - return mod(index, scale.length)|0 + return mod(index, scale.length-1)|0 } environment.index_to_frequency = function(index){ - var f = scale[ mod(index, scale.length)|0 ] - var pow = Math.floor(norm(index, 0, scale.length)) - 2 + var f = scale[ mod(index, scale.length-1)|0 ] + var pow = Math.floor(norm(index, 0, scale.length-1)) - 2 f *= Math.pow(interval, pow) // console.log(index, scale.length, pow, f) return f @@ -266,9 +266,8 @@ var environment = (function(){ function DotGrid (opt){ this.opt = defaults(opt, { - dot_min: 2, - dot_max: 10, - dot_spacing: 19, + dot_radius: 4, + dot_spacing: 20, mouse_radius: 200, wave_width: 200, fill: "#ffffff", @@ -298,11 +297,9 @@ var environment = (function(){ DotGrid.prototype.load = function(){ var dots = this.dots var dx = dy = this.opt.dot_spacing + var dot_radius = this.opt.dot_radius var x, y, i, j, u, r, a - var dot_min = this.opt.dot_min - var dot_max = this.opt.dot_max - var w = this.w = window.innerWidth var h = this.h = window.innerHeight - $("#controls").height() - dy @@ -310,7 +307,7 @@ var environment = (function(){ a = [] dots.push(a) for (y = dy/2; y < h; y += dy) { - dot = this.group.circle(x, y, 4).attr({ + dot = this.group.circle(x, y, dot_radius).attr({ fill: dot_color, }) a.push(dot) @@ -372,9 +369,8 @@ var environment = (function(){ var p = opt.point var length = this.length = dist(this.head.x, this.head.y, p.x, p.y) var theta = angle(this.head.x, this.head.y, p.x, p.y) * 180 / Math.PI - var index = Math.floor( length / dot_grid.opt.dot_spacing ) - 1 + var index = Math.floor( length / dot_grid.opt.dot_spacing ) if (index < 0) return - console.log(index) var length = this.length = (index * dot_grid.opt.dot_spacing) var q = { x: Math.sin(theta) * length + this.head.x, @@ -391,7 +387,7 @@ var environment = (function(){ transform: tran_str, stroke: color, }) - if (! opt.muted) { + if (! opt.muted && length > 0) { this.play(opt) } return length @@ -425,8 +421,8 @@ var environment = (function(){ Wire.prototype.frequency = function(){ var f if (use_scale) { - f = environment.index_to_frequency( this.length / dot_grid.opt.dot_spacing ) - // f = environment.quantize(f) + f = environment.index_to_frequency( this.length / dot_grid.opt.dot_spacing - 1 ) + // f = environment.quantize_frequency(f) } else { f = this.length / 340.29 * root |
