mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-18 02:01:22 +01:00
v1.0.05
This commit is contained in:
parent
ee70be134f
commit
59785125b0
6 changed files with 150 additions and 30 deletions
|
|
@ -24,13 +24,14 @@ function getBoundaryPoints(width, height, spacing) {
|
|||
// get points on a regular square grid and jitter them a bit
|
||||
function getJitteredGrid(width, height, spacing) {
|
||||
const radius = spacing / 2; // square radius
|
||||
const jittering = radius * 0.9; // max deviation
|
||||
const jitter = function() {return Math.random() * 2 * jittering - jittering;};
|
||||
const jittering = radius * .9; // max deviation
|
||||
const jitter = () => Math.random() * 2 * jittering - jittering;
|
||||
|
||||
let points = [];
|
||||
for (let y = radius; y < height; y += spacing) {
|
||||
for (let x = radius; x < width; x += spacing) {
|
||||
let xj = rn(x + jitter(), 2);
|
||||
let yj = rn(y + jitter(), 2);
|
||||
const xj = Math.min(rn(x + jitter(), 2), width);
|
||||
const yj = Math.min(rn(y + jitter(), 2), height);
|
||||
points.push([xj, yj]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue