Slightly better random generation.
Not sure this is right though. Thinking of going the puller route in this. I think a catchy tag line is in order too.
This commit is contained in:
parent
23228f9bde
commit
8f327af3c1
|
@ -147,8 +147,7 @@ Engine = Base.extend({
|
|||
},
|
||||
|
||||
renderTessellation: function(){
|
||||
var scale = this.scale,
|
||||
p, index, rando, halfWidth, halfHeight, shape, shapeTemplate;
|
||||
var scale = this.scale, p, index;
|
||||
|
||||
for (p = 0; p < this.shapes.length; p++) {
|
||||
this.shapes[p].update(this);
|
||||
|
@ -168,12 +167,34 @@ Engine = Base.extend({
|
|||
|
||||
// 1 Per second? Maybe?
|
||||
if (Engine.getRandomFloat(0,100) < 1.6666) {
|
||||
this.generateRandomShape();
|
||||
}
|
||||
},
|
||||
|
||||
generateRandomShape: function(){
|
||||
var p, index, rando, halfWidth, halfHeight, iter,
|
||||
shape, shapeTemplate, columns, rows, modWidth, row, column,
|
||||
xOffset, yOffset;
|
||||
|
||||
iter = 140;
|
||||
|
||||
rows = this.height / iter - 1;
|
||||
modWidth = this.width % iter;
|
||||
columns = (this.width - modWidth) / iter - 1;
|
||||
|
||||
row = Engine.getRandomInt(0, rows);
|
||||
column = Engine.getRandomInt(0, columns);
|
||||
|
||||
halfWidth = this.width / 2;
|
||||
halfHeight = this.height / 2;
|
||||
shapeTemplate = Shapes[Engine.getRandomInt(0, Shapes.length - 1)];
|
||||
|
||||
xOffset = Engine.getRandomInt(-50, 50);
|
||||
yOffset = Engine.getRandomInt(-50, 50);
|
||||
|
||||
shape = new Engine.Shape(
|
||||
Engine.getRandomInt(-halfWidth, halfWidth),
|
||||
Engine.getRandomInt(-halfHeight, halfHeight),
|
||||
(iter / 2) + (column * iter) - (modWidth / 2) - halfWidth + xOffset - 25,
|
||||
(iter / 2) + (row * iter) - halfHeight + yOffset - 25,
|
||||
50,
|
||||
50,
|
||||
shapeTemplate.points,
|
||||
|
@ -181,10 +202,7 @@ Engine = Base.extend({
|
|||
true
|
||||
);
|
||||
shape.selfDestruct(10);
|
||||
// shape.noStroke = true;
|
||||
// shape.noHueShift = true;
|
||||
this.shapes.push(shape);
|
||||
}
|
||||
},
|
||||
|
||||
generateParticles: function(num, fixed){
|
||||
|
|
Loading…
Reference in New Issue