Socket
Socket
Sign inDemoInstall

ds-heightmap

Package Overview
Dependencies
0
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2

1

lib/index.d.ts

@@ -7,3 +7,2 @@ interface DSConfig {

randomizer?: (base: number, range: number) => number;
reshaper?: (output: OutputMap) => void;
}

@@ -10,0 +9,0 @@ interface OutputMap {

50

lib/index.js

@@ -15,8 +15,7 @@ "use strict";

};
let debugCount = 0;
const { width, height, rough, randomizer, reshaper } = conf;
const { width, height, rough, randomizer } = conf;
if (width < 2)
throw 'Invalid config: width must be larger than 1.';
throw "Invalid config: width must be larger than 1.";
if (height < 2)
throw 'Invalid config: height must be larger than 1.';
throw "Invalid config: height must be larger than 1.";
let max = Number.MIN_SAFE_INTEGER;

@@ -45,5 +44,2 @@ let min = Number.MAX_SAFE_INTEGER;

const output = { data, max, min };
if (typeof reshaper === 'function') {
reshaper(output);
}
if (data.length !== width) {

@@ -90,3 +86,3 @@ data.splice(width);

function randomize(base, range) {
if (typeof randomizer === 'function')
if (typeof randomizer === "function")
return randomizer(base, range);

@@ -107,27 +103,21 @@ const n = base +

return;
if (sizeW % 2 === 1 && sizeH % 2 === 1) {
const halfW = Math.floor(sizeW / 2);
const halfH = Math.floor(sizeH / 2);
let x = 0;
let y = 0;
for (y = halfH; y < side; y += sizeH - 1) {
for (x = halfW; x < side; x += sizeW - 1) {
if (isCorner(x, y))
continue;
debugCount++;
square(x, y, halfW, halfH);
}
const halfW = Math.floor(sizeW / 2);
const halfH = Math.floor(sizeH / 2);
let x = 0;
let y = 0;
for (y = halfH; y < side; y += sizeH - 1) {
for (x = halfW; x < side; x += sizeW - 1) {
if (isCorner(x, y))
continue;
square(x, y, halfW, halfH);
}
for (y = 0; y < side; y += halfH) {
for (x = (y / halfH) % 2 === 0 ? halfW : 0; x < side; x += sizeW - 1) {
if (isCorner(x, y))
continue;
debugCount++;
diamond(x, y, halfW, halfH);
}
}
for (y = 0; y < side; y += halfH) {
for (x = (y / halfH) % 2 === 0 ? halfW : 0; x < side; x += sizeW - 1) {
if (isCorner(x, y))
continue;
diamond(x, y, halfW, halfH);
}
shape(Math.ceil(sizeW / 2), Math.ceil(sizeH / 2));
}
else if (sizeW % 2 === 0 && sizeH % 2 === 0) {
}
shape(Math.ceil(sizeW / 2), Math.ceil(sizeH / 2));
}

@@ -134,0 +124,0 @@ function square(x, y, halfW, halfH) {

{
"name": "ds-heightmap",
"version": "1.0.1",
"version": "1.0.2",
"description": "Use diamond-square algorithm to generate heightmaps.",

@@ -19,3 +19,3 @@ "main": "lib/index.js",

"lint": "tsc --noEmit --noUnusedLocals true --noUnusedParameters true",
"prepublish": "npm run build",
"prepublishOnly": "npm run build",
"test": "npm run lint"

@@ -40,2 +40,2 @@ },

}
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc