I came across the following code on http://www.somethinghitme.com/2013/11/11/simple-2d-terrain-with-midpoint-displacement/.
function terrain(width, height, displace, roughness, seed) {
var points = [],
// Gives us a power of 2 based on our width
power = Math.pow(2, Math.ceil(Math.log(width) / (Math.log(2)))),
seed = seed || {
s: height / 2 + (Math.random() * displace * 2) - displace,
e: height / 2 + (Math.random() * displace * 2) - displace
};
// ...
}
I am unfamiliar with this syntax. What exactly does it achieve? What will the points variable contain after this assignment?