@rickosborne/hexgrid
Version:
Rick Osborne's collection of hexagonal grid-related code.
83 lines (82 loc) • 4.03 kB
JavaScript
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var cube_exports = {};
__export(cube_exports, {
CUBE_DIAG_FLAT_E: () => CUBE_DIAG_FLAT_E,
CUBE_DIAG_FLAT_NE: () => CUBE_DIAG_FLAT_NE,
CUBE_DIAG_FLAT_SW: () => CUBE_DIAG_FLAT_SW,
CUBE_DIAG_FLAT_W: () => CUBE_DIAG_FLAT_W,
CUBE_DIAG_NW: () => CUBE_DIAG_NW,
CUBE_DIAG_POINTY_N: () => CUBE_DIAG_POINTY_N,
CUBE_DIAG_POINTY_NE: () => CUBE_DIAG_POINTY_NE,
CUBE_DIAG_POINTY_S: () => CUBE_DIAG_POINTY_S,
CUBE_DIAG_POINTY_SW: () => CUBE_DIAG_POINTY_SW,
CUBE_DIAG_SE: () => CUBE_DIAG_SE,
CUBE_EPSILON: () => CUBE_EPSILON,
CUBE_FLAT_N: () => CUBE_FLAT_N,
CUBE_FLAT_NW: () => CUBE_FLAT_NW,
CUBE_FLAT_S: () => CUBE_FLAT_S,
CUBE_FLAT_SE: () => CUBE_FLAT_SE,
CUBE_NE: () => CUBE_NE,
CUBE_ORIGIN: () => CUBE_ORIGIN,
CUBE_POINTY_E: () => CUBE_POINTY_E,
CUBE_POINTY_NW: () => CUBE_POINTY_NW,
CUBE_POINTY_SE: () => CUBE_POINTY_SE,
CUBE_POINTY_W: () => CUBE_POINTY_W,
CUBE_SW: () => CUBE_SW,
HEX_CUBE_DIRECTIONS: () => HEX_CUBE_DIRECTIONS,
cubeFromQR: () => cubeFromQR,
stringifyCube: () => stringifyCube
});
module.exports = __toCommonJS(cube_exports);
var import_hex_system = require("./hex-system.cjs");
const CUBE_FLAT_SE = Object.freeze({ q: 1, r: 0, s: -1, system: import_hex_system.CUBE });
const CUBE_FLAT_N = Object.freeze({ q: 0, r: -1, s: 1, system: import_hex_system.CUBE });
const CUBE_FLAT_NW = Object.freeze({ q: -1, r: 0, s: 1, system: import_hex_system.CUBE });
const CUBE_FLAT_S = Object.freeze({ q: 0, r: 1, s: -1, system: import_hex_system.CUBE });
const CUBE_NE = Object.freeze({ q: 1, r: -1, s: 0, system: import_hex_system.CUBE });
const CUBE_SW = Object.freeze({ q: -1, r: 1, s: 0, system: import_hex_system.CUBE });
const CUBE_POINTY_E = CUBE_FLAT_SE;
const CUBE_POINTY_NW = CUBE_FLAT_N;
const CUBE_POINTY_W = CUBE_FLAT_NW;
const CUBE_POINTY_SE = CUBE_FLAT_S;
const HEX_CUBE_DIRECTIONS = Object.freeze([
CUBE_FLAT_SE,
CUBE_NE,
CUBE_FLAT_N,
CUBE_FLAT_NW,
CUBE_SW,
CUBE_FLAT_S
]);
const stringifyCube = /* @__PURE__ */ __name(({ q, r, s }) => `Cube<${q},${r},${s}>`, "stringifyCube");
const cubeFromQR = /* @__PURE__ */ __name((q, r) => ({ q, r, s: -q - r, system: import_hex_system.CUBE }), "cubeFromQR");
const CUBE_DIAG_FLAT_E = Object.freeze({ q: 2, r: -1, s: 1, system: import_hex_system.CUBE });
const CUBE_DIAG_FLAT_SW = Object.freeze({ q: -1, r: 2, s: -1, system: import_hex_system.CUBE });
const CUBE_DIAG_FLAT_W = Object.freeze({ q: -2, r: 1, s: 1, system: import_hex_system.CUBE });
const CUBE_DIAG_FLAT_NE = Object.freeze({ q: 1, r: -2, s: 1, system: import_hex_system.CUBE });
const CUBE_DIAG_SE = Object.freeze({ q: 1, r: 1, s: -2, system: import_hex_system.CUBE });
const CUBE_DIAG_NW = Object.freeze({ q: -1, r: -1, s: 2, system: import_hex_system.CUBE });
const CUBE_DIAG_POINTY_N = CUBE_DIAG_FLAT_NE;
const CUBE_DIAG_POINTY_NE = CUBE_DIAG_FLAT_E;
const CUBE_DIAG_POINTY_S = CUBE_DIAG_FLAT_SW;
const CUBE_DIAG_POINTY_SW = CUBE_DIAG_FLAT_W;
const CUBE_ORIGIN = Object.freeze({ q: 0, r: 0, s: 0, system: import_hex_system.CUBE });
const CUBE_EPSILON = Object.freeze({ q: 1e-6, r: 1e-6, s: -2e-6, system: import_hex_system.CUBE });
//# sourceMappingURL=cube.cjs.map