diff --git a/dist/block-fractal-2.0.2.js b/dist/block-fractal-2.0.2.js new file mode 100644 index 0000000..50e4782 --- /dev/null +++ b/dist/block-fractal-2.0.2.js @@ -0,0 +1,1907 @@ +var BlockFractal; +/******/ (() => { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ "./node_modules/tiled-geometry/lib/compass/axis.js": +/*!*********************************************************!*\ + !*** ./node_modules/tiled-geometry/lib/compass/axis.js ***! + \*********************************************************/ +/***/ ((__unused_webpack_module, exports) => { + + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.axisAddCardinalTurn = exports.axisFromNorthSouthTurn = exports.axisFromCardinalDirection = exports.axisOrthogonal = exports.axisToString = exports.AXES = exports.Axis = void 0; +var Axis; +(function (Axis) { + Axis[Axis["NORTH_SOUTH"] = 0] = "NORTH_SOUTH"; + Axis[Axis["WEST_EAST"] = 1] = "WEST_EAST"; +})(Axis = exports.Axis || (exports.Axis = {})); +exports.AXES = [ + Axis.NORTH_SOUTH, + Axis.WEST_EAST, +]; +const AXES_STR = [ + 'N-S', + 'W-E', +]; +function axisToString(axis) { + return AXES_STR[axis]; +} +exports.axisToString = axisToString; +function axisOrthogonal(axis) { + return (axis ^ 1); +} +exports.axisOrthogonal = axisOrthogonal; +// conversion +function axisFromCardinalDirection(dir) { + return (dir & 1); +} +exports.axisFromCardinalDirection = axisFromCardinalDirection; +function axisFromNorthSouthTurn(turn) { + return (turn & 1); +} +exports.axisFromNorthSouthTurn = axisFromNorthSouthTurn; +// math +function axisAddCardinalTurn(axis, turn) { + return ((axis + turn) & 1); +} +exports.axisAddCardinalTurn = axisAddCardinalTurn; + + +/***/ }), + +/***/ "./node_modules/tiled-geometry/lib/compass/cardinal-direction-flags.js": +/*!*****************************************************************************!*\ + !*** ./node_modules/tiled-geometry/lib/compass/cardinal-direction-flags.js ***! + \*****************************************************************************/ +/***/ ((__unused_webpack_module, exports) => { + + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.cardinalDirectionFlagsFromCardinalDirection = exports.cardinalDirectionFlagsRemoveCardinalDirection = exports.cardinalDirectionFlagsSetCardinalDirection = exports.cardinalDirectionFlagsHasCardinalDirection = exports.cardinalDirectionFlagsToString = exports.CardinalDirectionFlags = void 0; +var CardinalDirectionFlags; +(function (CardinalDirectionFlags) { + CardinalDirectionFlags[CardinalDirectionFlags["NONE"] = 0] = "NONE"; + CardinalDirectionFlags[CardinalDirectionFlags["NORTH"] = 1] = "NORTH"; + CardinalDirectionFlags[CardinalDirectionFlags["EAST"] = 2] = "EAST"; + CardinalDirectionFlags[CardinalDirectionFlags["SOUTH"] = 4] = "SOUTH"; + CardinalDirectionFlags[CardinalDirectionFlags["WEST"] = 8] = "WEST"; + CardinalDirectionFlags[CardinalDirectionFlags["ALL"] = 15] = "ALL"; +})(CardinalDirectionFlags = exports.CardinalDirectionFlags || (exports.CardinalDirectionFlags = {})); +function cardinalDirectionFlagsToString(flags) { + let ret = '['; + if ((flags & CardinalDirectionFlags.NORTH) !== 0) { + ret += 'N'; + } + if ((flags & CardinalDirectionFlags.EAST) !== 0) { + ret += 'E'; + } + if ((flags & CardinalDirectionFlags.SOUTH) !== 0) { + ret += 'S'; + } + if ((flags & CardinalDirectionFlags.WEST) !== 0) { + ret += 'W'; + } + return ret + ']'; +} +exports.cardinalDirectionFlagsToString = cardinalDirectionFlagsToString; +function cardinalDirectionFlagsHasCardinalDirection(flags, dir) { + return (flags & cardinalDirectionFlagsFromCardinalDirection(dir)) !== 0; +} +exports.cardinalDirectionFlagsHasCardinalDirection = cardinalDirectionFlagsHasCardinalDirection; +function cardinalDirectionFlagsSetCardinalDirection(flags, dir) { + return (flags | cardinalDirectionFlagsFromCardinalDirection(dir)); +} +exports.cardinalDirectionFlagsSetCardinalDirection = cardinalDirectionFlagsSetCardinalDirection; +function cardinalDirectionFlagsRemoveCardinalDirection(flags, dir) { + return (flags & ~cardinalDirectionFlagsFromCardinalDirection(dir)); +} +exports.cardinalDirectionFlagsRemoveCardinalDirection = cardinalDirectionFlagsRemoveCardinalDirection; +// conversion +function cardinalDirectionFlagsFromCardinalDirection(dir) { + return (1 << dir); +} +exports.cardinalDirectionFlagsFromCardinalDirection = cardinalDirectionFlagsFromCardinalDirection; + + +/***/ }), + +/***/ "./node_modules/tiled-geometry/lib/compass/cardinal-direction.js": +/*!***********************************************************************!*\ + !*** ./node_modules/tiled-geometry/lib/compass/cardinal-direction.js ***! + \***********************************************************************/ +/***/ ((__unused_webpack_module, exports) => { + + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.cardinalDirectionAddCardinalTurn = exports.cardinalDirectionFromCardinalOrientation = exports.cardinalDirectionFromNorthTurn = exports.cardinalDirectionFromDirection = exports.cardinalDirectionOpposite = exports.cardinalDirectionToString = exports.CARDINAL_DIRECTIONS = exports.CardinalDirection = void 0; +var CardinalDirection; +(function (CardinalDirection) { + CardinalDirection[CardinalDirection["NORTH"] = 0] = "NORTH"; + CardinalDirection[CardinalDirection["EAST"] = 1] = "EAST"; + CardinalDirection[CardinalDirection["SOUTH"] = 2] = "SOUTH"; + CardinalDirection[CardinalDirection["WEST"] = 3] = "WEST"; +})(CardinalDirection = exports.CardinalDirection || (exports.CardinalDirection = {})); +exports.CARDINAL_DIRECTIONS = [ + CardinalDirection.NORTH, + CardinalDirection.EAST, + CardinalDirection.SOUTH, + CardinalDirection.WEST, +]; +const CARDINAL_DIRECTIONS_STR = [ + 'N', + 'E', + 'S', + 'W', +]; +function cardinalDirectionToString(dir) { + return CARDINAL_DIRECTIONS_STR[dir]; +} +exports.cardinalDirectionToString = cardinalDirectionToString; +function cardinalDirectionOpposite(dir) { + return ((dir + 2) & 3); +} +exports.cardinalDirectionOpposite = cardinalDirectionOpposite; +// conversion +function cardinalDirectionFromDirection(dir) { + return (dir >> 1); +} +exports.cardinalDirectionFromDirection = cardinalDirectionFromDirection; +function cardinalDirectionFromNorthTurn(turn) { + return turn; +} +exports.cardinalDirectionFromNorthTurn = cardinalDirectionFromNorthTurn; +function cardinalDirectionFromCardinalOrientation(orientation) { + return (orientation >>> 1); +} +exports.cardinalDirectionFromCardinalOrientation = cardinalDirectionFromCardinalOrientation; +// math +function cardinalDirectionAddCardinalTurn(dir, turn) { + return ((dir + turn) & 3); +} +exports.cardinalDirectionAddCardinalTurn = cardinalDirectionAddCardinalTurn; + + +/***/ }), + +/***/ "./node_modules/tiled-geometry/lib/compass/cardinal-orientation.js": +/*!*************************************************************************!*\ + !*** ./node_modules/tiled-geometry/lib/compass/cardinal-orientation.js ***! + \*************************************************************************/ +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.cardinalOrientationAddCardinalTurn = exports.cardinalOrientationFromFlipAndCardinalDirection = exports.cardinalOrientationReverse = exports.cardinalOrientationFlip = exports.cardinalOrientationToString = exports.CARDINAL_ORIENTATIONS = exports.CardinalOrientation = void 0; +const axis_1 = __webpack_require__(/*! ./axis */ "./node_modules/tiled-geometry/lib/compass/axis.js"); +const flip_1 = __webpack_require__(/*! ./flip */ "./node_modules/tiled-geometry/lib/compass/flip.js"); +var CardinalOrientation; +(function (CardinalOrientation) { + CardinalOrientation[CardinalOrientation["HEADS_NORTH"] = 0] = "HEADS_NORTH"; + CardinalOrientation[CardinalOrientation["TAILS_NORTH"] = 1] = "TAILS_NORTH"; + CardinalOrientation[CardinalOrientation["HEADS_EAST"] = 2] = "HEADS_EAST"; + CardinalOrientation[CardinalOrientation["TAILS_EAST"] = 3] = "TAILS_EAST"; + CardinalOrientation[CardinalOrientation["HEADS_SOUTH"] = 4] = "HEADS_SOUTH"; + CardinalOrientation[CardinalOrientation["TAILS_SOUTH"] = 5] = "TAILS_SOUTH"; + CardinalOrientation[CardinalOrientation["HEADS_WEST"] = 6] = "HEADS_WEST"; + CardinalOrientation[CardinalOrientation["TAILS_WEST"] = 7] = "TAILS_WEST"; +})(CardinalOrientation = exports.CardinalOrientation || (exports.CardinalOrientation = {})); +exports.CARDINAL_ORIENTATIONS = [ + CardinalOrientation.HEADS_NORTH, + CardinalOrientation.TAILS_NORTH, + CardinalOrientation.HEADS_EAST, + CardinalOrientation.TAILS_EAST, + CardinalOrientation.HEADS_SOUTH, + CardinalOrientation.TAILS_SOUTH, + CardinalOrientation.HEADS_WEST, + CardinalOrientation.TAILS_WEST, +]; +const CARDINAL_ORIENTATIONS_STR = [ + 'HN', + 'TN', + 'HE', + 'TE', + 'HS', + 'TS', + 'HW', + 'TW', +]; +function cardinalOrientationToString(orientation) { + return CARDINAL_ORIENTATIONS_STR[orientation]; +} +exports.cardinalOrientationToString = cardinalOrientationToString; +function cardinalOrientationFlip(orientation, axis) { + if (axis === axis_1.Axis.NORTH_SOUTH) { + return ((9 - orientation) & 7); + } + else { + return ((13 - orientation) & 7); + } +} +exports.cardinalOrientationFlip = cardinalOrientationFlip; +function cardinalOrientationReverse(orientation) { + if (orientation === CardinalOrientation.HEADS_EAST) { + return CardinalOrientation.HEADS_WEST; + } + else if (orientation === CardinalOrientation.HEADS_WEST) { + return CardinalOrientation.HEADS_EAST; + } + else { + return orientation; + } +} +exports.cardinalOrientationReverse = cardinalOrientationReverse; +// conversion +function cardinalOrientationFromFlipAndCardinalDirection(flip, dir) { + return (dir * 2 + (flip !== flip_1.Flip.HEADS ? 1 : 0)); +} +exports.cardinalOrientationFromFlipAndCardinalDirection = cardinalOrientationFromFlipAndCardinalDirection; +// math +function cardinalOrientationAddCardinalTurn(orientation, turn) { + return ((orientation + turn * 2) & 7); +} +exports.cardinalOrientationAddCardinalTurn = cardinalOrientationAddCardinalTurn; + + +/***/ }), + +/***/ "./node_modules/tiled-geometry/lib/compass/cardinal-turn.js": +/*!******************************************************************!*\ + !*** ./node_modules/tiled-geometry/lib/compass/cardinal-turn.js ***! + \******************************************************************/ +/***/ ((__unused_webpack_module, exports) => { + + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.cardinalTurnAddCardinalTurn = exports.cardinalTurnFromTurn = exports.cardinalTurnFromCardinalDirections = exports.cardinalTurnReverse = exports.cardinalTurnToDegrees = exports.cardinalTurnToString = exports.CARDINAL_TURNS = exports.CardinalTurn = void 0; +var CardinalTurn; +(function (CardinalTurn) { + CardinalTurn[CardinalTurn["NONE"] = 0] = "NONE"; + CardinalTurn[CardinalTurn["RIGHT"] = 1] = "RIGHT"; + CardinalTurn[CardinalTurn["AROUND"] = 2] = "AROUND"; + CardinalTurn[CardinalTurn["LEFT"] = 3] = "LEFT"; +})(CardinalTurn = exports.CardinalTurn || (exports.CardinalTurn = {})); +exports.CARDINAL_TURNS = [ + CardinalTurn.NONE, + CardinalTurn.RIGHT, + CardinalTurn.AROUND, + CardinalTurn.LEFT, +]; +const CARDINAL_TURNS_STR = [ + 'T0', + 'T+90', + 'T180', + 'T-90', +]; +function cardinalTurnToString(dir) { + return CARDINAL_TURNS_STR[dir]; +} +exports.cardinalTurnToString = cardinalTurnToString; +function cardinalTurnToDegrees(turn) { + return turn * 90; +} +exports.cardinalTurnToDegrees = cardinalTurnToDegrees; +function cardinalTurnReverse(dir) { + return ((4 - dir) & 3); +} +exports.cardinalTurnReverse = cardinalTurnReverse; +// conversion +function cardinalTurnFromCardinalDirections(from, to) { + return ((to - from) & 3); +} +exports.cardinalTurnFromCardinalDirections = cardinalTurnFromCardinalDirections; +function cardinalTurnFromTurn(turn) { + return (turn >> 1); +} +exports.cardinalTurnFromTurn = cardinalTurnFromTurn; +// math +function cardinalTurnAddCardinalTurn(turn1, turn2) { + return ((turn1 + turn2) & 3); +} +exports.cardinalTurnAddCardinalTurn = cardinalTurnAddCardinalTurn; + + +/***/ }), + +/***/ "./node_modules/tiled-geometry/lib/compass/direction.js": +/*!**************************************************************!*\ + !*** ./node_modules/tiled-geometry/lib/compass/direction.js ***! + \**************************************************************/ +/***/ ((__unused_webpack_module, exports) => { + + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.directionAddCardinalTurn = exports.directionAddTurn = exports.directionFromCardinalDirection = exports.directionOpposite = exports.directionIsCardinal = exports.directionToString = exports.DIRECTIONS = exports.Direction = void 0; +var Direction; +(function (Direction) { + Direction[Direction["NORTH"] = 0] = "NORTH"; + Direction[Direction["NORTHEAST"] = 1] = "NORTHEAST"; + Direction[Direction["EAST"] = 2] = "EAST"; + Direction[Direction["SOUTHEAST"] = 3] = "SOUTHEAST"; + Direction[Direction["SOUTH"] = 4] = "SOUTH"; + Direction[Direction["SOUTHWEST"] = 5] = "SOUTHWEST"; + Direction[Direction["WEST"] = 6] = "WEST"; + Direction[Direction["NORTHWEST"] = 7] = "NORTHWEST"; +})(Direction = exports.Direction || (exports.Direction = {})); +exports.DIRECTIONS = [ + Direction.NORTH, + Direction.NORTHEAST, + Direction.EAST, + Direction.SOUTHEAST, + Direction.SOUTH, + Direction.SOUTHWEST, + Direction.WEST, + Direction.NORTHWEST, +]; +const DIRECTIONS_STR = [ + 'N', + 'NE', + 'E', + 'SE', + 'S', + 'SW', + 'W', + 'NW', +]; +function directionToString(dir) { + return DIRECTIONS_STR[dir]; +} +exports.directionToString = directionToString; +function directionIsCardinal(dir) { + return (dir & 1) === 0; +} +exports.directionIsCardinal = directionIsCardinal; +function directionOpposite(dir) { + return ((dir + 4) & 7); +} +exports.directionOpposite = directionOpposite; +// conversion +function directionFromCardinalDirection(dir) { + return (dir << 1); +} +exports.directionFromCardinalDirection = directionFromCardinalDirection; +// math +function directionAddTurn(dir, turn) { + return ((dir + turn) & 7); +} +exports.directionAddTurn = directionAddTurn; +function directionAddCardinalTurn(dir, turn) { + return ((dir + turn * 2) & 7); +} +exports.directionAddCardinalTurn = directionAddCardinalTurn; + + +/***/ }), + +/***/ "./node_modules/tiled-geometry/lib/compass/flip.js": +/*!*********************************************************!*\ + !*** ./node_modules/tiled-geometry/lib/compass/flip.js ***! + \*********************************************************/ +/***/ ((__unused_webpack_module, exports) => { + + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.flipFromCardinalOrientation = exports.flipFromBoolean = exports.flipOpposite = exports.flipToString = exports.FLIPS = exports.Flip = void 0; +var Flip; +(function (Flip) { + Flip[Flip["HEADS"] = 0] = "HEADS"; + Flip[Flip["TAILS"] = 1] = "TAILS"; +})(Flip = exports.Flip || (exports.Flip = {})); +exports.FLIPS = [ + Flip.HEADS, + Flip.TAILS, +]; +const FLIPS_STR = [ + 'H', + 'T', +]; +function flipToString(flip) { + return FLIPS_STR[flip]; +} +exports.flipToString = flipToString; +function flipOpposite(flip) { + return (flip ^ 1); +} +exports.flipOpposite = flipOpposite; +// conversion +function flipFromBoolean(tails) { + return tails ? Flip.TAILS : Flip.HEADS; +} +exports.flipFromBoolean = flipFromBoolean; +function flipFromCardinalOrientation(orientation) { + return (orientation & 1); +} +exports.flipFromCardinalOrientation = flipFromCardinalOrientation; + + +/***/ }), + +/***/ "./node_modules/tiled-geometry/lib/compass/index.js": +/*!**********************************************************!*\ + !*** ./node_modules/tiled-geometry/lib/compass/index.js ***! + \**********************************************************/ +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +__exportStar(__webpack_require__(/*! ./direction */ "./node_modules/tiled-geometry/lib/compass/direction.js"), exports); +__exportStar(__webpack_require__(/*! ./turn */ "./node_modules/tiled-geometry/lib/compass/turn.js"), exports); +__exportStar(__webpack_require__(/*! ./cardinal-direction */ "./node_modules/tiled-geometry/lib/compass/cardinal-direction.js"), exports); +__exportStar(__webpack_require__(/*! ./cardinal-turn */ "./node_modules/tiled-geometry/lib/compass/cardinal-turn.js"), exports); +__exportStar(__webpack_require__(/*! ./cardinal-direction-flags */ "./node_modules/tiled-geometry/lib/compass/cardinal-direction-flags.js"), exports); +__exportStar(__webpack_require__(/*! ./flip */ "./node_modules/tiled-geometry/lib/compass/flip.js"), exports); +__exportStar(__webpack_require__(/*! ./cardinal-orientation */ "./node_modules/tiled-geometry/lib/compass/cardinal-orientation.js"), exports); +__exportStar(__webpack_require__(/*! ./axis */ "./node_modules/tiled-geometry/lib/compass/axis.js"), exports); + + +/***/ }), + +/***/ "./node_modules/tiled-geometry/lib/compass/turn.js": +/*!*********************************************************!*\ + !*** ./node_modules/tiled-geometry/lib/compass/turn.js ***! + \*********************************************************/ +/***/ ((__unused_webpack_module, exports) => { + + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.turnAddTurn = exports.turnFromDirections = exports.turnFromCardinalTurn = exports.turnFromCardinalDirections = exports.turnReverse = exports.turnIsCardinal = exports.turnToDegrees = exports.turnToString = exports.TURNS = exports.Turn = void 0; +var Turn; +(function (Turn) { + Turn[Turn["NONE"] = 0] = "NONE"; + Turn[Turn["R_45"] = 1] = "R_45"; + Turn[Turn["R_90"] = 2] = "R_90"; + Turn[Turn["R_135"] = 3] = "R_135"; + Turn[Turn["T_180"] = 4] = "T_180"; + Turn[Turn["L_135"] = 5] = "L_135"; + Turn[Turn["L_90"] = 6] = "L_90"; + Turn[Turn["L_45"] = 7] = "L_45"; +})(Turn = exports.Turn || (exports.Turn = {})); +exports.TURNS = [ + Turn.NONE, + Turn.R_45, + Turn.R_90, + Turn.R_135, + Turn.T_180, + Turn.L_135, + Turn.L_90, + Turn.L_45, +]; +const TURNS_STR = [ + 'T0', + 'T+45', + 'T+90', + 'T+135', + 'T180', + 'T-135', + 'T-90', + 'T-45', +]; +function turnToString(turn) { + return TURNS_STR[turn]; +} +exports.turnToString = turnToString; +function turnToDegrees(turn) { + return turn * 45; +} +exports.turnToDegrees = turnToDegrees; +function turnIsCardinal(turn) { + return (turn & 1) === 0; +} +exports.turnIsCardinal = turnIsCardinal; +function turnReverse(turn) { + return ((8 - turn) & 7); +} +exports.turnReverse = turnReverse; +// conversion +function turnFromCardinalDirections(from, to) { + return (((to - from) * 2) & 7); +} +exports.turnFromCardinalDirections = turnFromCardinalDirections; +function turnFromCardinalTurn(turn) { + return (turn << 1); +} +exports.turnFromCardinalTurn = turnFromCardinalTurn; +function turnFromDirections(from, to) { + return ((to - from) & 7); +} +exports.turnFromDirections = turnFromDirections; +// math +function turnAddTurn(turn1, turn2) { + return ((turn1 + turn2) & 7); +} +exports.turnAddTurn = turnAddTurn; + + +/***/ }), + +/***/ "./node_modules/tiled-geometry/lib/grid/cardinal-path.js": +/*!***************************************************************!*\ + !*** ./node_modules/tiled-geometry/lib/grid/cardinal-path.js ***! + \***************************************************************/ +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.CardinalPath = void 0; +const compass_1 = __webpack_require__(/*! ../compass */ "./node_modules/tiled-geometry/lib/compass/index.js"); +const offset_1 = __webpack_require__(/*! ./offset */ "./node_modules/tiled-geometry/lib/grid/offset.js"); +const rectangle_1 = __webpack_require__(/*! ./rectangle */ "./node_modules/tiled-geometry/lib/grid/rectangle.js"); +const raster_mask_1 = __webpack_require__(/*! ./raster-mask */ "./node_modules/tiled-geometry/lib/grid/raster-mask.js"); +const LOCAL_OFF = new offset_1.Offset(); +function sortedInsert(array, value) { + array.push(value); + let i = array.length - 1; + while (i > 0 && value < array[i - 1]) { + array[i] = array[i - 1]; + i--; + } + array[i] = value; +} +class CardinalPath { + constructor(start, segments) { + this._start = new offset_1.Offset(); + this._start.copyFrom(start); + this._segments = segments; + } + // accessors + toString() { + return `${this._start.toString()}:` + + `${this._segments.map((segment) => compass_1.cardinalDirectionToString(segment)).join('')}`; + } + equals(other) { + return this._start.equals(other._start) + && this._segments.length === other._segments.length + && this._segments.every((v, i) => v === other._segments[i]); + } + get length() { + return this._segments.length; + } + // utilities + getIsClosed() { + LOCAL_OFF.copyFrom(this._start); + for (const segment of this._segments) { + LOCAL_OFF.addCardinalDirection(segment); + } + return this._start.equals(LOCAL_OFF); + } + *offsets() { + let { x, y } = this._start; + yield { x, y }; + for (const segment of this._segments) { + LOCAL_OFF.setFromCardinalDirection(segment); + x += LOCAL_OFF.x; + y += LOCAL_OFF.y; + yield { x, y }; + } + } + getBounds() { + let northY = this._start.y; + let southY = northY; + let westX = this._start.x; + let eastX = westX; + LOCAL_OFF.copyFrom(this._start); + for (const segment of this._segments) { + LOCAL_OFF.addCardinalDirection(segment); + switch (segment) { + case compass_1.CardinalDirection.NORTH: + northY = Math.min(northY, LOCAL_OFF.y); + break; + case compass_1.CardinalDirection.EAST: + eastX = Math.max(eastX, LOCAL_OFF.x); + break; + case compass_1.CardinalDirection.SOUTH: + southY = Math.max(southY, LOCAL_OFF.y); + break; + case compass_1.CardinalDirection.WEST: + westX = Math.min(westX, LOCAL_OFF.x); + break; + // istanbul ignore next + default: + throw new Error(`bad direction ${segment} in cardinal path`); + } + } + return new rectangle_1.Rectangle(westX, northY, eastX - westX + 1, southY - northY + 1); + } + getArea() { + let total = 0; + LOCAL_OFF.copyFrom(this._start); + for (const segment of this._segments) { + LOCAL_OFF.addCardinalDirection(segment); + switch (segment) { + case compass_1.CardinalDirection.NORTH: + total -= LOCAL_OFF.x; + break; + case compass_1.CardinalDirection.SOUTH: + total += LOCAL_OFF.x; + break; + } + } + return Math.abs(total); + } + rasterize(bounds) { + const lines = new Array(); + if (typeof bounds === 'undefined') { + bounds = this.getBounds(); + } + // assert(this.getIsClosed()) + LOCAL_OFF.copyFrom(this._start); + const { northY } = bounds; + const southY = northY + bounds.height - 1; + for (let y = northY; y < southY; y++) { + lines.push([]); + } + LOCAL_OFF.copyFrom(this._start); + // assert(LOCAL_OFF.y >= northY && LOCAL_OFF.y <= southY) + for (const segment of this._segments) { + if (segment === compass_1.CardinalDirection.SOUTH) { + sortedInsert(lines[LOCAL_OFF.y - northY], LOCAL_OFF.x); + } + LOCAL_OFF.addCardinalDirection(segment); + // assert(LOCAL_OFF.y >= northY && LOCAL_OFF.y <= southY) + if (segment === compass_1.CardinalDirection.NORTH) { + sortedInsert(lines[LOCAL_OFF.y - northY], LOCAL_OFF.x); + } + } + return new raster_mask_1.RasterMask({ + westX: bounds.westX, + northY: bounds.northY, + width: bounds.width - 1, + height: bounds.height - 1, + }, lines); + } +} +exports.CardinalPath = CardinalPath; + + +/***/ }), + +/***/ "./node_modules/tiled-geometry/lib/grid/index.js": +/*!*******************************************************!*\ + !*** ./node_modules/tiled-geometry/lib/grid/index.js ***! + \*******************************************************/ +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +__exportStar(__webpack_require__(/*! ./offset */ "./node_modules/tiled-geometry/lib/grid/offset.js"), exports); +__exportStar(__webpack_require__(/*! ./size */ "./node_modules/tiled-geometry/lib/grid/size.js"), exports); +__exportStar(__webpack_require__(/*! ./rectangle */ "./node_modules/tiled-geometry/lib/grid/rectangle.js"), exports); +__exportStar(__webpack_require__(/*! ./mask */ "./node_modules/tiled-geometry/lib/grid/mask.js"), exports); +__exportStar(__webpack_require__(/*! ./mask-rectangle */ "./node_modules/tiled-geometry/lib/grid/mask-rectangle.js"), exports); +__exportStar(__webpack_require__(/*! ./raster-mask */ "./node_modules/tiled-geometry/lib/grid/raster-mask.js"), exports); +__exportStar(__webpack_require__(/*! ./cardinal-path */ "./node_modules/tiled-geometry/lib/grid/cardinal-path.js"), exports); +__exportStar(__webpack_require__(/*! ./transform-rectangle */ "./node_modules/tiled-geometry/lib/grid/transform-rectangle.js"), exports); + + +/***/ }), + +/***/ "./node_modules/tiled-geometry/lib/grid/mask-rectangle.js": +/*!****************************************************************!*\ + !*** ./node_modules/tiled-geometry/lib/grid/mask-rectangle.js ***! + \****************************************************************/ +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.MaskRectangle = void 0; +const rectangle_1 = __webpack_require__(/*! ./rectangle */ "./node_modules/tiled-geometry/lib/grid/rectangle.js"); +const mask_1 = __webpack_require__(/*! ./mask */ "./node_modules/tiled-geometry/lib/grid/mask.js"); +class MaskRectangle { + constructor(rect, initialValue = false, outsideValue = false) { + this._rect = new rectangle_1.Rectangle(); + if (typeof rect !== 'undefined') { + this._rect.copyFrom(rect); + } + this._mask = new mask_1.Mask(rect, initialValue); + this._outsideValue = outsideValue; + } + // accessors + toString() { + return `${this._rect.northWest}/${this._outsideValue}\n${this._mask}`; + } + equals(other) { + return this._rect.equals(other._rect) + && this._mask.equals(other._mask) + && this._outsideValue === other._outsideValue; + } + get westX() { + return this._rect.westX; + } + get northY() { + return this._rect.northY; + } + get width() { + return this._rect.width; + } + get height() { + return this._rect.height; + } + get(x, y) { + if (!this._rect.contains(x, y)) { + return this._outsideValue; + } + return this._mask.get(x - this.westX, y - this.northY); + } + getAtIndex(index) { + return this._mask.getAtIndex(index); + } + getAtOffset(off) { + return this.get(off.x, off.y); + } + // mutators + copyFrom(other) { + this._rect.copyFrom(other._rect); + this._mask.copyFrom(other._mask); + this._outsideValue = other._outsideValue; + return this; + } + set(x, y, value) { + this._mask.set(x - this.westX, y - this.northY, value); + return this; + } + setAtOffset(off, value) { + return this.set(off.x, off.y, value); + } + setAtIndex(index, value) { + this._mask.setAtIndex(index, value); + return this; + } + // utilities + index(x, y) { + return this._mask.index(x - this.westX, y - this.northY); + } + *locations() { + for (const loc of this._mask.locations()) { + const x = loc.x + this.westX; + const y = loc.y + this.northY; + const { value } = loc; + yield { x, y, value }; + } + } + *offsetsWithTrue() { + for (const off of this._mask.offsetsWithTrue()) { + const x = off.x + this.westX; + const y = off.y + this.northY; + yield { x, y }; + } + } +} +exports.MaskRectangle = MaskRectangle; + + +/***/ }), + +/***/ "./node_modules/tiled-geometry/lib/grid/mask.js": +/*!******************************************************!*\ + !*** ./node_modules/tiled-geometry/lib/grid/mask.js ***! + \******************************************************/ +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.Mask = void 0; +const size_1 = __webpack_require__(/*! ./size */ "./node_modules/tiled-geometry/lib/grid/size.js"); +class Mask { + constructor(size, initialValue = false) { + this._size = new size_1.Size(); + if (typeof size !== 'undefined') { + this._size.copyFrom(size); + } + this._bits = new Array(Math.ceil(this._size.area / 32)).fill(initialValue ? 0xffffffff : 0); + } + // accessors + toString() { + let ret = ''; + for (let y = 0; y < this.height; y++) { + for (let x = 0; x < this.width; x++) { + ret += this.get(x, y) ? '☑' : '☐'; + } + ret += '\n'; + } + return ret; + } + equals(other) { + return this._size.equals(other._size) + && this._bits.length === other._bits.length + && this._bits.every((v, i) => v === other._bits[i]); + } + get width() { + return this._size.width; + } + get height() { + return this._size.height; + } + get(x, y) { + return this.getAtIndex(this.index(x, y)); + } + getAtOffset(off) { + return this.get(off.x, off.y); + } + getAtIndex(index) { + // assert(index >= 0 && index < this._size.area) + const arrayIndex = index >>> 5; + const bitMask = 1 << (index & 31); + return (this._bits[arrayIndex] & bitMask) !== 0; + } + // mutators + copyFrom(other) { + this._size.copyFrom(other._size); + this._bits = other._bits.slice(); + return this; + } + set(x, y, value) { + return this.setAtIndex(this.index(x, y), value); + } + setAtOffset(off, value) { + return this.set(off.x, off.y, value); + } + setAtIndex(index, value) { + // assert(index >= 0 && index < this._size.area) + const arrayIndex = index >>> 5; + const bitMask = 1 << (index & 31); + if (value) { + this._bits[arrayIndex] |= bitMask; + } + else { + this._bits[arrayIndex] &= ~bitMask; + } + return this; + } + // utilities + index(x, y) { + return this._size.index(x, y); + } + *locations() { + let arrayIndex = 0; + let bitMask = 1; + for (const { x, y } of this._size.offsets()) { + const value = (this._bits[arrayIndex] & bitMask) !== 0; + yield { x, y, value }; + if (bitMask === (1 << 31)) { + bitMask = 1; + arrayIndex++; + } + else { + bitMask <<= 1; + } + } + } + *offsetsWithTrue() { + for (const { x, y, value } of this.locations()) { + if (value) { + yield { x, y }; + } + } + } +} +exports.Mask = Mask; + + +/***/ }), + +/***/ "./node_modules/tiled-geometry/lib/grid/offset.js": +/*!********************************************************!*\ + !*** ./node_modules/tiled-geometry/lib/grid/offset.js ***! + \********************************************************/ +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.Offset = void 0; +const compass_1 = __webpack_require__(/*! ../compass */ "./node_modules/tiled-geometry/lib/compass/index.js"); +const X_FROM_DIRECTION = [0, 1, 1, 1, 0, -1, -1, -1]; +const Y_FROM_DIRECTION = [-1, -1, 0, 1, 1, 1, 0, -1]; +const X_FROM_CARDINAL_DIRECTION = [0, 1, 0, -1]; +const Y_FROM_CARDINAL_DIRECTION = [-1, 0, 1, 0]; +class Offset { + constructor(x, y) { + if (typeof x === 'undefined') { + x = 0; + } + if (typeof y === 'undefined') { + y = 0; + } + this.x = x; + this.y = y; + } + // accessors + toString() { + return `(${this.x},${this.y})`; + } + equals(other) { + return this.x === other.x && this.y === other.y; + } + // mutators + set(x, y) { + this.x = x; + this.y = y; + return this; + } + copyFrom(other) { + return this.set(other.x, other.y); + } + setFromDirection(dir) { + return this.set(X_FROM_DIRECTION[dir], Y_FROM_DIRECTION[dir]); + } + setFromCardinalDirection(dir) { + return this.set(X_FROM_CARDINAL_DIRECTION[dir], Y_FROM_CARDINAL_DIRECTION[dir]); + } + add(x, y) { + this.x += x; + this.y += y; + return this; + } + addSize(size) { + return this.add(size.width, size.height); + } + addOffset(off) { + return this.add(off.x, off.y); + } + addDirection(dir) { + return this.add(X_FROM_DIRECTION[dir], Y_FROM_DIRECTION[dir]); + } + addCardinalDirection(dir) { + return this.add(X_FROM_CARDINAL_DIRECTION[dir], Y_FROM_CARDINAL_DIRECTION[dir]); + } + subtractOffset(off) { + return this.add(-off.x, -off.y); + } + multiply(factor) { + this.x *= factor; + this.y *= factor; + return this; + } + rotate(turn, anchor) { + if (anchor) { + return this.subtractOffset(anchor).rotate(turn).addOffset(anchor); + } + else { + const dir = compass_1.cardinalDirectionFromNorthTurn(turn); + const { x, y } = this; + const dirx = X_FROM_CARDINAL_DIRECTION[dir]; + const diry = Y_FROM_CARDINAL_DIRECTION[dir]; + const nx = -y * dirx - x * diry; + const ny = x * dirx - y * diry; + return this.set(nx, ny); + } + } + // utilities + // chebyshev: can move in any direction (diagonals are ok) + distanceChebyshev(other) { + return Math.max(Math.abs(this.x - other.x), Math.abs(this.y - other.y)); + } + // manhattan: can move only in cardinal directions (no diagonals) + distanceManhattan(other) { + return Math.abs(this.x - other.x) + Math.abs(this.y - other.y); + } + // chebyshev: can move in any direction (diagonals are ok) + *nearbyChebyshevOffsets(cursor, radius) { + if (radius >= 0) { + for (let dy = -radius; dy <= radius; dy++) { + for (let dx = -radius; dx <= radius; dx++) { + yield cursor.set(this.x + dx, this.y + dy); + } + } + } + } +} +exports.Offset = Offset; + + +/***/ }), + +/***/ "./node_modules/tiled-geometry/lib/grid/raster-mask.js": +/*!*************************************************************!*\ + !*** ./node_modules/tiled-geometry/lib/grid/raster-mask.js ***! + \*************************************************************/ +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.RasterMask = void 0; +const rectangle_1 = __webpack_require__(/*! ./rectangle */ "./node_modules/tiled-geometry/lib/grid/rectangle.js"); +class RasterMask { + constructor(bounds, lines) { + this._rect = new rectangle_1.Rectangle(); + if (lines.length !== bounds.height) { + throw new Error(`bad lines array length ${lines.length} for bounds ${bounds}`); + } + this._rect.copyFrom(bounds); + this._lines = lines; + } + // accessors + toString() { + let shape = ''; + const { eastX } = this._rect; + for (let y = 0; y < this.height; y++) { + const line = this._lines[y]; + let x = this.westX; + for (let i = 0; i < line.length; i += 2) { + const start = line[i]; + const end = line[i + 1]; + while (x < start) { + shape += '∙'; + x++; + } + while (x < end) { + shape += '█'; + x++; + } + } + while (x <= eastX) { + shape += '∙'; + x++; + } + shape += '\n'; + } + return `(${this._rect.westX},${this._rect.northY})\n${shape}`; + } + equals(other) { + return this._rect.equals(other._rect) + && this._lines.length === other._lines.length + && this._lines.every((v, i) => (v.length === other._lines[i].length + && v.every((w, j) => w === other._lines[i][j]))); + } + get northY() { + return this._rect.northY; + } + get southY() { + return this._rect.southY; + } + get westX() { + return this._rect.westX; + } + get width() { + return this._rect.width; + } + get height() { + return this._rect.height; + } + get(x, y) { + if (y < this.northY || y > this._rect.southY) { + return false; + } + const line = this._lines[y - this.northY]; + for (let i = 0; i < line.length; i += 2) { + if (x >= line[i] && x < line[i + 1]) { + return true; + } + } + return false; + } + getAtOffset(off) { + return this.get(off.x, off.y); + } + // utilities + *bandsAt(y) { + if (y >= this.northY && y <= this._rect.southY) { + const line = this._lines[y - this.northY]; + for (let i = 0; i < line.length; i += 2) { + yield { + westX: line[i], + eastX: line[i + 1] - 1, + }; + } + } + } +} +exports.RasterMask = RasterMask; + + +/***/ }), + +/***/ "./node_modules/tiled-geometry/lib/grid/rectangle.js": +/*!***********************************************************!*\ + !*** ./node_modules/tiled-geometry/lib/grid/rectangle.js ***! + \***********************************************************/ +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.Rectangle = void 0; +const size_1 = __webpack_require__(/*! ./size */ "./node_modules/tiled-geometry/lib/grid/size.js"); +const offset_1 = __webpack_require__(/*! ./offset */ "./node_modules/tiled-geometry/lib/grid/offset.js"); +const ROTATE_CORNER_X = [0, 0, 1, 1]; +const ROTATE_CORNER_Y = [0, 1, 1, 0]; +class Rectangle { + constructor(westX, northY, width, height) { + if (typeof westX === 'undefined') { + westX = 0; + } + if (typeof northY === 'undefined') { + northY = 0; + } + if (typeof width === 'undefined') { + width = 0; + } + if (typeof height === 'undefined') { + height = 0; + } + this.northWest = new offset_1.Offset(westX, northY); + this.size = new size_1.Size(width, height); + } + // accessors + toString() { + return `(${this.westX},${this.northY} ${this.width}x${this.height})`; + } + equals(other) { + return this.westX === other.westX && this.northY === other.northY && this.size.equals(other); + } + get northY() { + return this.northWest.y; + } + get southY() { + return this.northWest.y + this.size.height - 1; + } + get westX() { + return this.northWest.x; + } + get eastX() { + return this.northWest.x + this.size.width - 1; + } + get width() { + return this.size.width; + } + get height() { + return this.size.height; + } + get empty() { + return this.size.empty; + } + get area() { + return this.size.area; + } + // mutators + set(westX, northY, width, height) { + this.northWest.set(westX, northY); + this.size.set(width, height); + return this; + } + setFromCorners(off1, off2) { + const westX = Math.min(off1.x, off2.x); + const eastX = Math.max(off1.x, off2.x); + const northY = Math.min(off1.y, off2.y); + const southY = Math.max(off1.y, off2.y); + return this.set(westX, northY, eastX - westX + 1, southY - northY + 1); + } + copyFrom(other) { + return this.set(other.westX, other.northY, other.width, other.height); + } + addOffset(off) { + this.northWest.addOffset(off); + return this; + } + scale(factor) { + this.northWest.multiply(factor); + this.size.multiply(factor); + return this; + } + rotate(turn, anchor) { + const cx = ROTATE_CORNER_X[turn]; + const cy = ROTATE_CORNER_Y[turn]; + this.northWest.add(cx * (this.width - 1), cy * (this.height - 1)).rotate(turn, anchor); + this.size.rotate(turn); + return this; + } + extendToInclude(off) { + const dx = off.x - this.westX; + if (dx < 0) { + this.size.width -= dx; + this.northWest.x = off.x; + } + else if (dx >= this.size.width) { + this.size.width = dx + 1; + } + const dy = off.y - this.northWest.y; + if (dy < 0) { + this.size.height -= dy; + this.northWest.y = off.y; + } + else if (dy >= this.size.height) { + this.size.height = dy + 1; + } + return this; + } + // utilities + contains(x, y) { + return this.size.contains(x - this.westX, y - this.northY); + } + index(x, y) { + return this.size.index(x - this.westX, y - this.northY); + } + containsOffset(off) { + return this.contains(off.x, off.y); + } + containsRectangle(other) { + if (other.width === 0 && other.height === 0) { + return false; + } + const x = other.westX - this.westX; + const y = other.northY - this.northY; + if (!this.size.contains(x, y)) { + return false; + } + return this.size.contains(x + other.width - 1, y + other.height - 1); + } + overlapsRectangle(other) { + return this.northY <= other.northY + other.height - 1 + && this.southY >= other.northY + && this.westX <= other.westX + other.width - 1 + && this.eastX >= other.westX + && !this.empty + && other.width !== 0 && other.height !== 0; + } + *offsets() { + const { eastX, southY } = this; + for (let y = this.northY; y <= southY; y++) { + for (let x = this.westX; x <= eastX; x++) { + yield { x, y }; + } + } + } + anyOf(predicate) { + for (const { x, y } of this.offsets()) { + if (predicate(x, y)) { + return true; + } + } + return false; + } +} +exports.Rectangle = Rectangle; + + +/***/ }), + +/***/ "./node_modules/tiled-geometry/lib/grid/size.js": +/*!******************************************************!*\ + !*** ./node_modules/tiled-geometry/lib/grid/size.js ***! + \******************************************************/ +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.Size = void 0; +const compass_1 = __webpack_require__(/*! ../compass */ "./node_modules/tiled-geometry/lib/compass/index.js"); +class Size { + constructor(width, height) { + if (typeof width === 'undefined') { + width = 0; + } + if (typeof height === 'undefined') { + height = 0; + } + if (width < 0 || height < 0) { + throw new Error(`bad size (${width}x${height})`); + } + this.width = width; + this.height = height; + } + // accessors + toString() { + return `(${this.width}x${this.height})`; + } + equals(other) { + return this.width === other.width && this.height === other.height; + } + get empty() { + return this.width === 0 || this.height === 0; + } + get area() { + return this.width * this.height; + } + // mutators + set(width, height) { + if (width < 0 || height < 0) { + throw new Error(`bad size (${width}x${height})`); + } + this.width = width; + this.height = height; + return this; + } + copyFrom(other) { + return this.set(other.width, other.height); + } + add(width, height) { + this.width += width; + this.height += height; + return this; + } + multiply(factor) { + this.width *= factor; + this.height *= factor; + return this; + } + rotate(turn) { + if (compass_1.axisFromNorthSouthTurn(turn) === compass_1.Axis.WEST_EAST) { + this.set(this.height, this.width); + } + return this; + } + // utilities + contains(x, y) { + return x >= 0 && y >= 0 && x < this.width && y < this.height; + } + containsOffset(off) { + return this.contains(off.x, off.y); + } + index(x, y) { + return y * this.width + x; + } + *offsets() { + for (let y = 0; y < this.height; y++) { + for (let x = 0; x < this.width; x++) { + yield { x, y }; + } + } + } + anyOf(predicate) { + for (const { x, y } of this.offsets()) { + if (predicate(x, y)) { + return true; + } + } + return false; + } +} +exports.Size = Size; + + +/***/ }), + +/***/ "./node_modules/tiled-geometry/lib/grid/transform-rectangle.js": +/*!*********************************************************************!*\ + !*** ./node_modules/tiled-geometry/lib/grid/transform-rectangle.js ***! + \*********************************************************************/ +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.TransformRectangle = void 0; +const rectangle_1 = __webpack_require__(/*! ./rectangle */ "./node_modules/tiled-geometry/lib/grid/rectangle.js"); +const compass_1 = __webpack_require__(/*! ../compass */ "./node_modules/tiled-geometry/lib/compass/index.js"); +const offset_1 = __webpack_require__(/*! ./offset */ "./node_modules/tiled-geometry/lib/grid/offset.js"); +const size_1 = __webpack_require__(/*! ./size */ "./node_modules/tiled-geometry/lib/grid/size.js"); +const LOCAL_OFF = new offset_1.Offset(); +const LOCAL_OFF2 = new offset_1.Offset(); +const LOCAL_SIZE = new size_1.Size(); +class TransformRectangle { + constructor(width, height) { + this._size = new size_1.Size(); + this._flip = compass_1.Flip.HEADS; + this._rotate = compass_1.CardinalTurn.NONE; + this._translate = new offset_1.Offset(); + this._matrix = [1, 0, 0, 0, 1, 0]; + this._targetRect = new rectangle_1.Rectangle(); + if (typeof width === 'undefined') { + // nothing + } + else if (typeof width === 'number') { + this._size.set(width, height); + } + else { + this._size.copyFrom(width); + } + this._update(); + } + // accessors + toString() { + return `[${this._size}` + + ` -> ${compass_1.flipToString(this._flip)} ${compass_1.cardinalTurnToString(this._rotate)} ${this._translate}` + + ` -> ${this._targetRect}]`; + } + equals(other) { + return this._size.equals(other._size) + && this._flip === other._flip + && this._rotate === other._rotate + && this._translate.equals(other._translate); + } + get flip() { + return this._flip; + } + get rotate() { + return this._rotate; + } + get northY() { + return this._translate.y; + } + get southY() { + return this._translate.y + this._targetRect.height - 1; + } + get westX() { + return this._translate.x; + } + get eastX() { + return this._translate.x + this._targetRect.width - 1; + } + get width() { + return this._targetRect.width; + } + get height() { + return this._targetRect.height; + } + // internal + // 0 + // 0 -1 + // +90 + // 1 0 + // 180 + // 0 1 + // -90 + // -1 0 + // + // heads: + // 0 + // 1 0 x + // 0 1 y + // +90 + // 0 -1 x + h - 1 + // 1 0 y + // 180 + // -1 0 x + w - 1 + // 0 -1 y + h - 1 + // -90 + // 0 1 x + // -1 0 y + w - 1 + // + // tails: + // 0 + // -1 0 x + w - 1 + // 0 1 y + // +90 + // 0 -1 x + h - 1 + // -1 0 y + w - 1 + // 180 + // 1 0 x + // 0 -1 y + h - 1 + // -90 + // 0 1 x + // 1 0 y + _update() { + LOCAL_OFF.setFromCardinalDirection(compass_1.cardinalDirectionFromNorthTurn(this._rotate)); + const flipSign = this._flip === compass_1.Flip.TAILS ? -1 : 1; + this._matrix[0] = -LOCAL_OFF.y * flipSign; + this._matrix[1] = -LOCAL_OFF.x; + this._matrix[2] = this._translate.x; + this._matrix[3] = LOCAL_OFF.x * flipSign; + this._matrix[4] = -LOCAL_OFF.y; + this._matrix[5] = this._translate.y; + switch (this._rotate) { + case compass_1.CardinalTurn.NONE: + if (this._flip === compass_1.Flip.TAILS) { + this._matrix[2] += this._size.width - 1; + } + break; + case compass_1.CardinalTurn.RIGHT: + this._matrix[2] += this._size.height - 1; + if (this._flip === compass_1.Flip.TAILS) { + this._matrix[5] += this._size.width - 1; + } + break; + case compass_1.CardinalTurn.AROUND: + this._matrix[5] += this._size.height - 1; + if (this._flip === compass_1.Flip.HEADS) { + this._matrix[2] += this._size.width - 1; + } + break; + case compass_1.CardinalTurn.LEFT: + if (this._flip === compass_1.Flip.HEADS) { + this._matrix[5] += this._size.width - 1; + } + break; + } + LOCAL_SIZE.copyFrom(this._size).rotate(this._rotate); + this._targetRect.set(this._translate.x, this._translate.y, LOCAL_SIZE.width, LOCAL_SIZE.height); + return this; + } + // mutators + copyFrom(other) { + this._size.copyFrom(other._size); + this._flip = other._flip; + this._rotate = other._rotate; + this._translate.copyFrom(other._translate); + other._matrix.forEach((v, i) => this._matrix[i] = v); + this._targetRect.copyFrom(other._targetRect); + return this; + } + reset() { + this._flip = compass_1.Flip.HEADS; + this._rotate = compass_1.CardinalTurn.NONE; + this._translate.set(0, 0); + return this._update(); + } + invert() { + const nrotate = compass_1.cardinalTurnFromCardinalDirections(compass_1.CardinalDirection.NORTH, compass_1.cardinalDirectionFromCardinalOrientation(compass_1.cardinalOrientationReverse(compass_1.cardinalOrientationFromFlipAndCardinalDirection(this._flip, compass_1.cardinalDirectionFromNorthTurn(this._rotate))))); + this._rotate = nrotate; + this._size.rotate(nrotate); + this._translate.multiply(-1); + return this._update(); + } + setTransform(flip, rotate, translate) { + this._flip = flip; + this._rotate = rotate; + this._translate.copyFrom(translate); + return this._update(); + } + setFlip(flip) { + this._flip = flip; + return this._update(); + } + setRotate(rotate) { + this._rotate = rotate; + return this._update(); + } + setTranslate(x, y) { + this._translate.set(x, y); + return this._update(); + } + setTranslateOffset(translate) { + this._translate.copyFrom(translate); + return this._update(); + } + // utility + applyToCardinalOrientation(orientation) { + if (this._flip === compass_1.Flip.TAILS) { + orientation = compass_1.cardinalOrientationFlip(orientation, compass_1.Axis.NORTH_SOUTH); + } + return compass_1.cardinalOrientationAddCardinalTurn(orientation, this._rotate); + } + unapplyFromCardinalOrientation(orientation) { + orientation = compass_1.cardinalOrientationAddCardinalTurn(orientation, compass_1.cardinalTurnReverse(this._rotate)); + if (this._flip === compass_1.Flip.TAILS) { + orientation = compass_1.cardinalOrientationFlip(orientation, compass_1.Axis.NORTH_SOUTH); + } + return orientation; + } + applyToCardinalDirection(orientation) { + return compass_1.cardinalDirectionFromCardinalOrientation(this.applyToCardinalOrientation(compass_1.cardinalOrientationFromFlipAndCardinalDirection(compass_1.Flip.HEADS, orientation))); + } + unapplyFromCardinalDirection(orientation) { + return compass_1.cardinalDirectionFromCardinalOrientation(this.unapplyFromCardinalOrientation(compass_1.cardinalOrientationFromFlipAndCardinalDirection(compass_1.Flip.HEADS, orientation))); + } + applyTo(offOut, x, y) { + const nx = x * this._matrix[0] + y * this._matrix[1] + this._matrix[2]; + const ny = x * this._matrix[3] + y * this._matrix[4] + this._matrix[5]; + return offOut.set(nx, ny); + } + unapplyFrom(offOut, x, y) { + const tx = x - this._matrix[2]; + const ty = y - this._matrix[5]; + const nx = tx * this._matrix[0] + ty * this._matrix[3]; + const ny = tx * this._matrix[1] + ty * this._matrix[4]; + return offOut.set(nx, ny); + } + applyToOffset(offOut, off) { + if (typeof off === 'undefined') { + off = offOut; + } + return this.applyTo(offOut, off.x, off.y); + } + unapplyFromOffset(offOut, off) { + if (typeof off === 'undefined') { + off = offOut; + } + return this.unapplyFrom(offOut, off.x, off.y); + } + applyToRectangle(rectOut, rect) { + if (typeof rect !== 'undefined') { + rectOut.copyFrom(rect); + } + LOCAL_OFF.set(rectOut.westX, rectOut.northY); + LOCAL_OFF2.set(rectOut.eastX, rectOut.southY); + this.applyToOffset(LOCAL_OFF); + this.applyToOffset(LOCAL_OFF2); + return rectOut.setFromCorners(LOCAL_OFF, LOCAL_OFF2); + } + unapplyFromRectangle(rectOut, rect) { + if (typeof rect !== 'undefined') { + rectOut.copyFrom(rect); + } + LOCAL_OFF.set(rectOut.westX, rectOut.northY); + LOCAL_OFF2.set(rectOut.eastX, rectOut.southY); + this.unapplyFromOffset(LOCAL_OFF); + this.unapplyFromOffset(LOCAL_OFF2); + return rectOut.setFromCorners(LOCAL_OFF, LOCAL_OFF2); + } +} +exports.TransformRectangle = TransformRectangle; + + +/***/ }), + +/***/ "./node_modules/tiled-geometry/lib/index.js": +/*!**************************************************!*\ + !*** ./node_modules/tiled-geometry/lib/index.js ***! + \**************************************************/ +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +__exportStar(__webpack_require__(/*! ./compass */ "./node_modules/tiled-geometry/lib/compass/index.js"), exports); +__exportStar(__webpack_require__(/*! ./grid */ "./node_modules/tiled-geometry/lib/grid/index.js"), exports); + + +/***/ }), + +/***/ "./src/block-fractal.ts": +/*!******************************!*\ + !*** ./src/block-fractal.ts ***! + \******************************/ +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.makeBlockFractal = void 0; +const geom = __importStar(__webpack_require__(/*! tiled-geometry */ "./node_modules/tiled-geometry/lib/index.js")); +function nextToLastMatch(points, next) { + return points.length > 1 && points[points.length - 2].equals(next); +} +function addPoint(points, mask, next) { + if (nextToLastMatch(points, next)) { + mask.setAtOffset(points.splice(points.length - 1, 1)[0], false); + } + else { + points.push(next); + mask.setAtOffset(next, true); + } +} +function verticalHelper(points, random, variation, newPoints, mask, i, p1, p2) { + const x = 2 * p1.x; + const yDir = p2.y - p1.y; + for (let y = 2 * p1.y; y !== 2 * p2.y; y += yDir) { + const np3 = new geom.Offset(x, y + yDir); + // console.info(`- ${np3}`); + if (nextToLastMatch(newPoints, np3)) { + // This can happen around a corner, when just before the corner + // we dip into the corner + // console.info(` remove ${newPoints[newPoints.length - 1]}`); + mask.setAtOffset(newPoints.splice(newPoints.length - 1, 1)[0], false); + continue; + } + if (i === points.length - 2 && mask.getAtOffset(np3)) { + // This can happen if the first point was on a corner and the + // first move was to dip into the corner + const index = newPoints.findIndex((point) => point.equals(np3)); + // console.info(`remove ${index} from beginning`); + for (const point of newPoints.splice(0, index)) { + mask.setAtOffset(point, false); + } + addPoint(newPoints, mask, np3); + break; + } + if (random() < variation) { + const v = Math.floor(random() * 2) * 2 - 1; + const np1 = new geom.Offset(x + v, y); + const np2 = new geom.Offset(x + v, y + yDir); + if (!mask.getAtOffset(np2)) { + if (!mask.getAtOffset(np1) || nextToLastMatch(newPoints, np1)) { + addPoint(newPoints, mask, np1); + addPoint(newPoints, mask, np2); + } + } + } + addPoint(newPoints, mask, np3); + } +} +function horizontalHelper(points, random, variation, newPoints, mask, i, p1, p2) { + const y = 2 * p1.y; + const xDir = p2.x - p1.x; + for (let x = 2 * p1.x; x !== 2 * p2.x; x += xDir) { + const np3 = new geom.Offset(x + xDir, y); + // console.info(`- ${np3}`); + if (nextToLastMatch(newPoints, np3)) { + // This can happen around a corner, when just before the corner + // we dip in the direction of the corner + // console.info(` remove ${newPoints[newPoints.length - 1]}`); + mask.setAtOffset(newPoints.splice(newPoints.length - 1, 1)[0], false); + continue; + } + if (i === points.length - 2 && mask.getAtOffset(np3)) { + // This can happen if the first point was on a corner and the + // first move was to dip into the corner + const index = newPoints.findIndex((point) => point.equals(np3)); + // console.info(`remove ${index} from beginning`); + for (const point of newPoints.splice(0, index)) { + mask.setAtOffset(point, false); + } + addPoint(newPoints, mask, np3); + break; + } + if (random() < variation) { + const v = Math.floor(random() * 2) * 2 - 1; + const np1 = new geom.Offset(x, y + v); + const np2 = new geom.Offset(x + xDir, y + v); + if (!mask.getAtOffset(np2)) { + if (!mask.getAtOffset(np1) || nextToLastMatch(newPoints, np1)) { + addPoint(newPoints, mask, np1); + addPoint(newPoints, mask, np2); + } + } + } + addPoint(newPoints, mask, np3); + } +} +function blockFractalIteration(random, points, bounds, variation) { + const newPoints = new Array(); + const newBounds = new geom.Rectangle(bounds.westX * 2 - 1, bounds.northY * 2 - 1, bounds.width * 2 + 2, bounds.height * 2 + 2); + // console.info(` bounds ${newBounds}`); + const mask = new geom.MaskRectangle(newBounds); + for (let i = 0; i < points.length - 1; i++) { + const p1 = points[i]; + const p2 = points[i + 1]; + if (i === 0) { + addPoint(newPoints, mask, new geom.Offset(p1.x * 2, p1.y * 2)); + } + if (p1.x === p2.x) { + verticalHelper(points, random, variation, newPoints, mask, i, p1, p2); + } + else { + horizontalHelper(points, random, variation, newPoints, mask, i, p1, p2); + } + } + return { + points: newPoints, + bounds: newBounds, + }; +} +function makeBlockFractal(param) { + let { random, shape, variation } = param; + if (typeof random === 'undefined') { + random = Math.random; + } + if (typeof shape === 'undefined') { + shape = new geom.CardinalPath({ x: -1, y: -1 }, [ + geom.CardinalDirection.EAST, + geom.CardinalDirection.EAST, + geom.CardinalDirection.SOUTH, + geom.CardinalDirection.SOUTH, + geom.CardinalDirection.WEST, + geom.CardinalDirection.WEST, + geom.CardinalDirection.NORTH, + geom.CardinalDirection.NORTH, + ]); + } + if (typeof variation === 'undefined') { + variation = 0.4; + } + let points = new Array(); + let bounds = shape.getBounds(); + for (const off of shape.offsets()) { + points.push(new geom.Offset(off.x, off.y)); + } + for (let iter = 0; iter < param.iterations; iter++) { + // console.info(`iteration ${iter + 1}`); + ({ points, bounds } = blockFractalIteration(random, points, bounds, variation)); + } + const segments = new Array(); + for (let i = 0; i < points.length - 1; i++) { + const curPoint = points[i]; + const nextPoint = points[i + 1]; + if (nextPoint.y === curPoint.y - 1) { + segments.push(geom.CardinalDirection.NORTH); + } + else if (nextPoint.x === curPoint.x + 1) { + segments.push(geom.CardinalDirection.EAST); + } + else if (nextPoint.y === curPoint.y + 1) { + segments.push(geom.CardinalDirection.SOUTH); + } + else if (nextPoint.x === curPoint.x - 1) { + segments.push(geom.CardinalDirection.WEST); + } + } + return new geom.CardinalPath(points[0], segments); +} +exports.makeBlockFractal = makeBlockFractal; + + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. +(() => { +var exports = __webpack_exports__; +/*!**********************!*\ + !*** ./src/index.ts ***! + \**********************/ + +/* + * BlockFractal + * github.com/sbj42/block-fractal + * James Clark + * Licensed under the MIT license. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.RasterMask = exports.CardinalPath = exports.Offset = exports.CardinalDirectionFlags = exports.CardinalDirection = exports.makeBlockFractal = void 0; +var block_fractal_1 = __webpack_require__(/*! ./block-fractal */ "./src/block-fractal.ts"); +Object.defineProperty(exports, "makeBlockFractal", ({ enumerable: true, get: function () { return block_fractal_1.makeBlockFractal; } })); +var tiled_geometry_1 = __webpack_require__(/*! tiled-geometry */ "./node_modules/tiled-geometry/lib/index.js"); +Object.defineProperty(exports, "CardinalDirection", ({ enumerable: true, get: function () { return tiled_geometry_1.CardinalDirection; } })); +Object.defineProperty(exports, "CardinalDirectionFlags", ({ enumerable: true, get: function () { return tiled_geometry_1.CardinalDirectionFlags; } })); +Object.defineProperty(exports, "Offset", ({ enumerable: true, get: function () { return tiled_geometry_1.Offset; } })); +Object.defineProperty(exports, "CardinalPath", ({ enumerable: true, get: function () { return tiled_geometry_1.CardinalPath; } })); +Object.defineProperty(exports, "RasterMask", ({ enumerable: true, get: function () { return tiled_geometry_1.RasterMask; } })); + +})(); + +BlockFractal = __webpack_exports__; +/******/ })() +; +//# sourceMappingURL=block-fractal-2.0.2.js.map \ No newline at end of file diff --git a/dist/block-fractal-2.0.2.js.map b/dist/block-fractal-2.0.2.js.map new file mode 100644 index 0000000..edd7819 --- /dev/null +++ b/dist/block-fractal-2.0.2.js.map @@ -0,0 +1 @@ +{"version":3,"file":"block-fractal-2.0.2.js","mappings":";;;;;;;;;;;AAAa;AACb,8CAA6C,EAAE,aAAa,EAAC;AAC7D,2BAA2B,GAAG,8BAA8B,GAAG,iCAAiC,GAAG,sBAAsB,GAAG,oBAAoB,GAAG,YAAY,GAAG,YAAY;AAC9K;AACA;AACA;AACA;AACA,CAAC,0BAA0B,YAAY,KAAK;AAC5C,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA,iCAAiC;AACjC;AACA;AACA;AACA,8BAA8B;AAC9B;AACA;AACA;AACA;AACA,2BAA2B;;;;;;;;;;;ACrCd;AACb,8CAA6C,EAAE,aAAa,EAAC;AAC7D,mDAAmD,GAAG,qDAAqD,GAAG,kDAAkD,GAAG,kDAAkD,GAAG,sCAAsC,GAAG,8BAA8B;AAC/R;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,8DAA8D,8BAA8B,KAAK;AAClG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC;AACtC;AACA;AACA;AACA,kDAAkD;AAClD;AACA;AACA;AACA,kDAAkD;AAClD;AACA;AACA;AACA,qDAAqD;AACrD;AACA;AACA;AACA;AACA,mDAAmD;;;;;;;;;;;AC7CtC;AACb,8CAA6C,EAAE,aAAa,EAAC;AAC7D,wCAAwC,GAAG,gDAAgD,GAAG,sCAAsC,GAAG,sCAAsC,GAAG,iCAAiC,GAAG,iCAAiC,GAAG,2BAA2B,GAAG,yBAAyB;AAC/S;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,oDAAoD,yBAAyB,KAAK;AACnF,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iCAAiC;AACjC;AACA;AACA;AACA,iCAAiC;AACjC;AACA;AACA;AACA;AACA,sCAAsC;AACtC;AACA;AACA;AACA,sCAAsC;AACtC;AACA;AACA;AACA,gDAAgD;AAChD;AACA;AACA;AACA;AACA,wCAAwC;;;;;;;;;;;AC/C3B;AACb,8CAA6C,EAAE,aAAa,EAAC;AAC7D,0CAA0C,GAAG,uDAAuD,GAAG,kCAAkC,GAAG,+BAA+B,GAAG,mCAAmC,GAAG,6BAA6B,GAAG,2BAA2B;AAC/Q,eAAe,mBAAO,CAAC,iEAAQ;AAC/B,eAAe,mBAAO,CAAC,iEAAQ;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,wDAAwD,2BAA2B,KAAK;AACzF,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC;AAClC;AACA;AACA;AACA;AACA,uDAAuD;AACvD;AACA;AACA;AACA;AACA,0CAA0C;;;;;;;;;;;ACtE7B;AACb,8CAA6C,EAAE,aAAa,EAAC;AAC7D,mCAAmC,GAAG,4BAA4B,GAAG,0CAA0C,GAAG,2BAA2B,GAAG,6BAA6B,GAAG,4BAA4B,GAAG,sBAAsB,GAAG,oBAAoB;AAC5P;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,0CAA0C,oBAAoB,KAAK;AACpE,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B;AAC5B;AACA;AACA;AACA,6BAA6B;AAC7B;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA,0CAA0C;AAC1C;AACA;AACA;AACA,4BAA4B;AAC5B;AACA;AACA;AACA;AACA,mCAAmC;;;;;;;;;;;AC/CtB;AACb,8CAA6C,EAAE,aAAa,EAAC;AAC7D,gCAAgC,GAAG,wBAAwB,GAAG,sCAAsC,GAAG,yBAAyB,GAAG,2BAA2B,GAAG,yBAAyB,GAAG,kBAAkB,GAAG,iBAAiB;AACnO;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,oCAAoC,iBAAiB,KAAK;AAC3D,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA,yBAAyB;AACzB;AACA;AACA;AACA;AACA,sCAAsC;AACtC;AACA;AACA;AACA;AACA,wBAAwB;AACxB;AACA;AACA;AACA,gCAAgC;;;;;;;;;;;AC3DnB;AACb,8CAA6C,EAAE,aAA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A;AACA,kCAAkC;AAClC;AACA;AACA;AACA,4BAA4B;AAC5B;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA,mBAAmB;;;;;;;;;;;ACnEN;AACb,8CAA6C,EAAE,aAAa,EAAC;AAC7D,oBAAoB;AACpB,kBAAkB,mBAAO,CAAC,sEAAY;AACtC,iBAAiB,mBAAO,CAAC,kEAAU;AACnC,oBAAoB,mBAAO,CAAC,wEAAa;AACzC,sBAAsB,mBAAO,CAAC,4EAAe;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,uBAAuB;AACzC,iBAAiB,uFAAuF;AACxG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc,OAAO;AACrB,gBAAgB;AAChB;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qDAAqD,SAAS;AAC9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,SAAS;AACzB;AACA,6BAA6B,YAAY;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,oBAAoB;;;;;;;;;;;AClIP;AACb;AACA;AACA,mCAAmC,oCAAoC,gBAAgB;AACvF,CAAC;AACD;AACA;AACA,CAAC;AACD;AACA;AACA;AACA,8CAA6C,EAAE,aAAa,EAAC;AAC7D,aAAa,mBAAO,CAAC,kEAAU;AAC/B,aAAa,mBAAO,CAAC,8DAAQ;AAC7B,aAAa,mBAAO,CAAC,wEAAa;AAClC,aAAa,mBAAO,CAAC,8DAAQ;AAC7B,aAAa,mBAAO,CAAC,kFAAkB;AACvC,aAAa,mBAAO,CAAC,4EAAe;AACpC,aAAa,mBAAO,CAAC,gFAAiB;AACtC,aAAa,mBAAO,CAAC,4FAAuB;;;;;;;;;;;ACnB/B;AACb,8CAA6C,EAAE,aAAa,EAAC;AAC7D,qBAAqB;AACrB,oBAAoB,mBAAO,CAAC,wEAAa;AACzC,eAAe,mBAAO,CAAC,8DAAQ;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,qBAAqB,GAAG,mBAAmB,IAAI,WAAW;AAC5E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,QAAQ;AAC5B,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA,qBAAqB;;;;;;;;;;;ACrFR;AACb,8CAA6C,EAAE,aAAa,EAAC;AAC7D,YAAY;AACZ,eAAe,mBAAO,CAAC,8DAAQ;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,iBAAiB;AACzC,4BAA4B,gBAAgB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,OAAO;AAC5B;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,cAAc;AACnC;AACA,wBAAwB;AACxB;AACA;AACA;AACA;AACA,YAAY;;;;;;;;;;;ACjGC;AACb,8CAA6C,EAAE,aAAa,EAAC;AAC7D,cAAc;AACd,kBAAkB,mBAAO,CAAC,sEAAY;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,OAAO,GAAG,OAAO;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,OAAO;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC,cAAc;AACjD,uCAAuC,cAAc;AACrD;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;;;;;;;;;;;ACpGD;AACb,8CAA6C,EAAE,aAAa,EAAC;AAC7D,kBAAkB;AAClB,oBAAoB,mBAAO,CAAC,wEAAa;AACzC;AACA;AACA;AACA;AACA,sDAAsD,cAAc,aAAa,OAAO;AACxF;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,QAAQ;AACxB,wBAAwB,iBAAiB;AACzC;AACA;AACA,4BAA4B,iBAAiB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,iBAAiB,GAAG,kBAAkB,KAAK,MAAM;AACpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,iBAAiB;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B,iBAAiB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;;;;;;;;;;;ACzFL;AACb,8CAA6C,EAAE,aAAa,EAAC;AAC7D,iBAAiB;AACjB,eAAe,mBAAO,CAAC,8DAAQ;AAC/B,iBAAiB,mBAAO,CAAC,kEAAU;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,WAAW,GAAG,aAAa,EAAE,WAAW,GAAG,YAAY;AAC1E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,gBAAgB;AAChC,kCAAkC,aAAa;AAC/C,qCAAqC,YAAY;AACjD,wBAAwB;AACxB;AACA;AACA;AACA;AACA,qBAAqB,OAAO;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;;;;;;;;;;;ACxJJ;AACb,8CAA6C,EAAE,aAAa,EAAC;AAC7D,YAAY;AACZ,kBAAkB,mBAAO,CAAC,sEAAY;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yCAAyC,MAAM,GAAG,OAAO;AACzD;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,WAAW,GAAG,YAAY;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yCAAyC,MAAM,GAAG,OAAO;AACzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,iBAAiB;AACzC,4BAA4B,gBAAgB;AAC5C,wBAAwB;AACxB;AACA;AACA;AACA;AACA,qBAAqB,OAAO;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY;;;;;;;;;;;ACrFC;AACb,8CAA6C,EAAE,aAAa,EAAC;AAC7D,0BAA0B;AAC1B,oBAAoB,mBAAO,CAAC,wEAAa;AACzC,kBAAkB,mBAAO,CAAC,sEAAY;AACtC,iBAAiB,mBAAO,CAAC,kEAAU;AACnC,eAAe,mBAAO,CAAC,8DAAQ;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,WAAW;AAC9B,qBAAqB,oCAAoC,EAAE,8CAA8C,EAAE,gBAAgB;AAC3H,qBAAqB,iBAAiB;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;;;;;;;;;;;ACzPb;AACb;AACA;AACA,mCAAmC,oCAAoC,gBAAgB;AACvF,CAAC;AACD;AACA;AACA,CAAC;AACD;AACA;AACA;AACA,8CAA6C,EAAE,aAAa,EAAC;AAC7D,aAAa,mBAAO,CAAC,qEAAW;AAChC,aAAa,mBAAO,CAAC,+DAAQ;;;;;;;;;;;ACbhB;AACb;AACA;AACA,mCAAmC,oCAAoC,gBAAgB;AACvF,CAAC;AACD;AACA;AACA,CAAC;AACD;AACA,0CAA0C,4BAA4B;AACtE,CAAC;AACD;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA6C,EAAE,aAAa,EAAC;AAC7D,wBAAwB;AACxB,0BAA0B,mBAAO,CAAC,kEAAgB;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,gBAAgB;AAC3C;AACA,6BAA6B,IAAI;AACjC;AACA;AACA;AACA,uCAAuC,gCAAgC;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,OAAO;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,gBAAgB;AAC3C;AACA,6BAA6B,IAAI;AACjC;AACA;AACA;AACA,uCAAuC,gCAAgC;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,OAAO;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B,UAAU;AACzC;AACA,oBAAoB,uBAAuB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU,2BAA2B;AACrC;AACA;AACA;AACA;AACA,wCAAwC,cAAc;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,yBAAyB;AAChD,qCAAqC,SAAS;AAC9C,WAAW,iBAAiB;AAC5B;AACA;AACA,oBAAoB,uBAAuB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB;;;;;;;UCtLxB;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;;;;;;ACtBa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,8CAA6C,EAAE,aAAa,EAAC;AAC7D,kBAAkB,GAAG,oBAAoB,GAAG,cAAc,GAAG,8BAA8B,GAAG,yBAAyB,GAAG,wBAAwB;AAClJ,sBAAsB,mBAAO,CAAC,+CAAiB;AAC/C,oDAAmD,EAAE,qCAAqC,4CAA4C,EAAC;AACvI,uBAAuB,mBAAO,CAAC,kEAAgB;AAC/C,qDAAoD,EAAE,qCAAqC,8CAA8C,EAAC;AAC1I,0DAAyD,EAAE,qCAAqC,mDAAmD,EAAC;AACpJ,0CAAyC,EAAE,qCAAqC,mCAAmC,EAAC;AACpH,gDAA+C,EAAE,qCAAqC,yCAAyC,EAAC;AAChI,8CAA6C,EAAE,qCAAqC,uCAAuC,EAAC","sources":["webpack://BlockFractal/./node_modules/tiled-geometry/lib/compass/axis.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/compass/cardinal-direction-flags.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/compass/cardinal-direction.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/compass/cardinal-orientation.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/compass/cardinal-turn.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/compass/direction.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/compass/flip.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/compass/index.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/compass/turn.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/grid/cardinal-path.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/grid/index.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/grid/mask-rectangle.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/grid/mask.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/grid/offset.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/grid/raster-mask.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/grid/rectangle.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/grid/size.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/grid/transform-rectangle.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/index.js","webpack://BlockFractal/./src/block-fractal.ts","webpack://BlockFractal/webpack/bootstrap","webpack://BlockFractal/./src/index.ts"],"sourcesContent":["\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.axisAddCardinalTurn = exports.axisFromNorthSouthTurn = exports.axisFromCardinalDirection = exports.axisOrthogonal = exports.axisToString = exports.AXES = exports.Axis = void 0;\r\nvar Axis;\r\n(function (Axis) {\r\n Axis[Axis[\"NORTH_SOUTH\"] = 0] = \"NORTH_SOUTH\";\r\n Axis[Axis[\"WEST_EAST\"] = 1] = \"WEST_EAST\";\r\n})(Axis = exports.Axis || (exports.Axis = {}));\r\nexports.AXES = [\r\n Axis.NORTH_SOUTH,\r\n Axis.WEST_EAST,\r\n];\r\nconst AXES_STR = [\r\n 'N-S',\r\n 'W-E',\r\n];\r\nfunction axisToString(axis) {\r\n return AXES_STR[axis];\r\n}\r\nexports.axisToString = axisToString;\r\nfunction axisOrthogonal(axis) {\r\n return (axis ^ 1);\r\n}\r\nexports.axisOrthogonal = axisOrthogonal;\r\n// conversion\r\nfunction axisFromCardinalDirection(dir) {\r\n return (dir & 1);\r\n}\r\nexports.axisFromCardinalDirection = axisFromCardinalDirection;\r\nfunction axisFromNorthSouthTurn(turn) {\r\n return (turn & 1);\r\n}\r\nexports.axisFromNorthSouthTurn = axisFromNorthSouthTurn;\r\n// math\r\nfunction axisAddCardinalTurn(axis, turn) {\r\n return ((axis + turn) & 1);\r\n}\r\nexports.axisAddCardinalTurn = axisAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cardinalDirectionFlagsFromCardinalDirection = exports.cardinalDirectionFlagsRemoveCardinalDirection = exports.cardinalDirectionFlagsSetCardinalDirection = exports.cardinalDirectionFlagsHasCardinalDirection = exports.cardinalDirectionFlagsToString = exports.CardinalDirectionFlags = void 0;\r\nvar CardinalDirectionFlags;\r\n(function (CardinalDirectionFlags) {\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"NONE\"] = 0] = \"NONE\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"NORTH\"] = 1] = \"NORTH\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"EAST\"] = 2] = \"EAST\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"SOUTH\"] = 4] = \"SOUTH\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"WEST\"] = 8] = \"WEST\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"ALL\"] = 15] = \"ALL\";\r\n})(CardinalDirectionFlags = exports.CardinalDirectionFlags || (exports.CardinalDirectionFlags = {}));\r\nfunction cardinalDirectionFlagsToString(flags) {\r\n let ret = '[';\r\n if ((flags & CardinalDirectionFlags.NORTH) !== 0) {\r\n ret += 'N';\r\n }\r\n if ((flags & CardinalDirectionFlags.EAST) !== 0) {\r\n ret += 'E';\r\n }\r\n if ((flags & CardinalDirectionFlags.SOUTH) !== 0) {\r\n ret += 'S';\r\n }\r\n if ((flags & CardinalDirectionFlags.WEST) !== 0) {\r\n ret += 'W';\r\n }\r\n return ret + ']';\r\n}\r\nexports.cardinalDirectionFlagsToString = cardinalDirectionFlagsToString;\r\nfunction cardinalDirectionFlagsHasCardinalDirection(flags, dir) {\r\n return (flags & cardinalDirectionFlagsFromCardinalDirection(dir)) !== 0;\r\n}\r\nexports.cardinalDirectionFlagsHasCardinalDirection = cardinalDirectionFlagsHasCardinalDirection;\r\nfunction cardinalDirectionFlagsSetCardinalDirection(flags, dir) {\r\n return (flags | cardinalDirectionFlagsFromCardinalDirection(dir));\r\n}\r\nexports.cardinalDirectionFlagsSetCardinalDirection = cardinalDirectionFlagsSetCardinalDirection;\r\nfunction cardinalDirectionFlagsRemoveCardinalDirection(flags, dir) {\r\n return (flags & ~cardinalDirectionFlagsFromCardinalDirection(dir));\r\n}\r\nexports.cardinalDirectionFlagsRemoveCardinalDirection = cardinalDirectionFlagsRemoveCardinalDirection;\r\n// conversion\r\nfunction cardinalDirectionFlagsFromCardinalDirection(dir) {\r\n return (1 << dir);\r\n}\r\nexports.cardinalDirectionFlagsFromCardinalDirection = cardinalDirectionFlagsFromCardinalDirection;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cardinalDirectionAddCardinalTurn = exports.cardinalDirectionFromCardinalOrientation = exports.cardinalDirectionFromNorthTurn = exports.cardinalDirectionFromDirection = exports.cardinalDirectionOpposite = exports.cardinalDirectionToString = exports.CARDINAL_DIRECTIONS = exports.CardinalDirection = void 0;\r\nvar CardinalDirection;\r\n(function (CardinalDirection) {\r\n CardinalDirection[CardinalDirection[\"NORTH\"] = 0] = \"NORTH\";\r\n CardinalDirection[CardinalDirection[\"EAST\"] = 1] = \"EAST\";\r\n CardinalDirection[CardinalDirection[\"SOUTH\"] = 2] = \"SOUTH\";\r\n CardinalDirection[CardinalDirection[\"WEST\"] = 3] = \"WEST\";\r\n})(CardinalDirection = exports.CardinalDirection || (exports.CardinalDirection = {}));\r\nexports.CARDINAL_DIRECTIONS = [\r\n CardinalDirection.NORTH,\r\n CardinalDirection.EAST,\r\n CardinalDirection.SOUTH,\r\n CardinalDirection.WEST,\r\n];\r\nconst CARDINAL_DIRECTIONS_STR = [\r\n 'N',\r\n 'E',\r\n 'S',\r\n 'W',\r\n];\r\nfunction cardinalDirectionToString(dir) {\r\n return CARDINAL_DIRECTIONS_STR[dir];\r\n}\r\nexports.cardinalDirectionToString = cardinalDirectionToString;\r\nfunction cardinalDirectionOpposite(dir) {\r\n return ((dir + 2) & 3);\r\n}\r\nexports.cardinalDirectionOpposite = cardinalDirectionOpposite;\r\n// conversion\r\nfunction cardinalDirectionFromDirection(dir) {\r\n return (dir >> 1);\r\n}\r\nexports.cardinalDirectionFromDirection = cardinalDirectionFromDirection;\r\nfunction cardinalDirectionFromNorthTurn(turn) {\r\n return turn;\r\n}\r\nexports.cardinalDirectionFromNorthTurn = cardinalDirectionFromNorthTurn;\r\nfunction cardinalDirectionFromCardinalOrientation(orientation) {\r\n return (orientation >>> 1);\r\n}\r\nexports.cardinalDirectionFromCardinalOrientation = cardinalDirectionFromCardinalOrientation;\r\n// math\r\nfunction cardinalDirectionAddCardinalTurn(dir, turn) {\r\n return ((dir + turn) & 3);\r\n}\r\nexports.cardinalDirectionAddCardinalTurn = cardinalDirectionAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cardinalOrientationAddCardinalTurn = exports.cardinalOrientationFromFlipAndCardinalDirection = exports.cardinalOrientationReverse = exports.cardinalOrientationFlip = exports.cardinalOrientationToString = exports.CARDINAL_ORIENTATIONS = exports.CardinalOrientation = void 0;\r\nconst axis_1 = require(\"./axis\");\r\nconst flip_1 = require(\"./flip\");\r\nvar CardinalOrientation;\r\n(function (CardinalOrientation) {\r\n CardinalOrientation[CardinalOrientation[\"HEADS_NORTH\"] = 0] = \"HEADS_NORTH\";\r\n CardinalOrientation[CardinalOrientation[\"TAILS_NORTH\"] = 1] = \"TAILS_NORTH\";\r\n CardinalOrientation[CardinalOrientation[\"HEADS_EAST\"] = 2] = \"HEADS_EAST\";\r\n CardinalOrientation[CardinalOrientation[\"TAILS_EAST\"] = 3] = \"TAILS_EAST\";\r\n CardinalOrientation[CardinalOrientation[\"HEADS_SOUTH\"] = 4] = \"HEADS_SOUTH\";\r\n CardinalOrientation[CardinalOrientation[\"TAILS_SOUTH\"] = 5] = \"TAILS_SOUTH\";\r\n CardinalOrientation[CardinalOrientation[\"HEADS_WEST\"] = 6] = \"HEADS_WEST\";\r\n CardinalOrientation[CardinalOrientation[\"TAILS_WEST\"] = 7] = \"TAILS_WEST\";\r\n})(CardinalOrientation = exports.CardinalOrientation || (exports.CardinalOrientation = {}));\r\nexports.CARDINAL_ORIENTATIONS = [\r\n CardinalOrientation.HEADS_NORTH,\r\n CardinalOrientation.TAILS_NORTH,\r\n CardinalOrientation.HEADS_EAST,\r\n CardinalOrientation.TAILS_EAST,\r\n CardinalOrientation.HEADS_SOUTH,\r\n CardinalOrientation.TAILS_SOUTH,\r\n CardinalOrientation.HEADS_WEST,\r\n CardinalOrientation.TAILS_WEST,\r\n];\r\nconst CARDINAL_ORIENTATIONS_STR = [\r\n 'HN',\r\n 'TN',\r\n 'HE',\r\n 'TE',\r\n 'HS',\r\n 'TS',\r\n 'HW',\r\n 'TW',\r\n];\r\nfunction cardinalOrientationToString(orientation) {\r\n return CARDINAL_ORIENTATIONS_STR[orientation];\r\n}\r\nexports.cardinalOrientationToString = cardinalOrientationToString;\r\nfunction cardinalOrientationFlip(orientation, axis) {\r\n if (axis === axis_1.Axis.NORTH_SOUTH) {\r\n return ((9 - orientation) & 7);\r\n }\r\n else {\r\n return ((13 - orientation) & 7);\r\n }\r\n}\r\nexports.cardinalOrientationFlip = cardinalOrientationFlip;\r\nfunction cardinalOrientationReverse(orientation) {\r\n if (orientation === CardinalOrientation.HEADS_EAST) {\r\n return CardinalOrientation.HEADS_WEST;\r\n }\r\n else if (orientation === CardinalOrientation.HEADS_WEST) {\r\n return CardinalOrientation.HEADS_EAST;\r\n }\r\n else {\r\n return orientation;\r\n }\r\n}\r\nexports.cardinalOrientationReverse = cardinalOrientationReverse;\r\n// conversion\r\nfunction cardinalOrientationFromFlipAndCardinalDirection(flip, dir) {\r\n return (dir * 2 + (flip !== flip_1.Flip.HEADS ? 1 : 0));\r\n}\r\nexports.cardinalOrientationFromFlipAndCardinalDirection = cardinalOrientationFromFlipAndCardinalDirection;\r\n// math\r\nfunction cardinalOrientationAddCardinalTurn(orientation, turn) {\r\n return ((orientation + turn * 2) & 7);\r\n}\r\nexports.cardinalOrientationAddCardinalTurn = cardinalOrientationAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cardinalTurnAddCardinalTurn = exports.cardinalTurnFromTurn = exports.cardinalTurnFromCardinalDirections = exports.cardinalTurnReverse = exports.cardinalTurnToDegrees = exports.cardinalTurnToString = exports.CARDINAL_TURNS = exports.CardinalTurn = void 0;\r\nvar CardinalTurn;\r\n(function (CardinalTurn) {\r\n CardinalTurn[CardinalTurn[\"NONE\"] = 0] = \"NONE\";\r\n CardinalTurn[CardinalTurn[\"RIGHT\"] = 1] = \"RIGHT\";\r\n CardinalTurn[CardinalTurn[\"AROUND\"] = 2] = \"AROUND\";\r\n CardinalTurn[CardinalTurn[\"LEFT\"] = 3] = \"LEFT\";\r\n})(CardinalTurn = exports.CardinalTurn || (exports.CardinalTurn = {}));\r\nexports.CARDINAL_TURNS = [\r\n CardinalTurn.NONE,\r\n CardinalTurn.RIGHT,\r\n CardinalTurn.AROUND,\r\n CardinalTurn.LEFT,\r\n];\r\nconst CARDINAL_TURNS_STR = [\r\n 'T0',\r\n 'T+90',\r\n 'T180',\r\n 'T-90',\r\n];\r\nfunction cardinalTurnToString(dir) {\r\n return CARDINAL_TURNS_STR[dir];\r\n}\r\nexports.cardinalTurnToString = cardinalTurnToString;\r\nfunction cardinalTurnToDegrees(turn) {\r\n return turn * 90;\r\n}\r\nexports.cardinalTurnToDegrees = cardinalTurnToDegrees;\r\nfunction cardinalTurnReverse(dir) {\r\n return ((4 - dir) & 3);\r\n}\r\nexports.cardinalTurnReverse = cardinalTurnReverse;\r\n// conversion\r\nfunction cardinalTurnFromCardinalDirections(from, to) {\r\n return ((to - from) & 3);\r\n}\r\nexports.cardinalTurnFromCardinalDirections = cardinalTurnFromCardinalDirections;\r\nfunction cardinalTurnFromTurn(turn) {\r\n return (turn >> 1);\r\n}\r\nexports.cardinalTurnFromTurn = cardinalTurnFromTurn;\r\n// math\r\nfunction cardinalTurnAddCardinalTurn(turn1, turn2) {\r\n return ((turn1 + turn2) & 3);\r\n}\r\nexports.cardinalTurnAddCardinalTurn = cardinalTurnAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.directionAddCardinalTurn = exports.directionAddTurn = exports.directionFromCardinalDirection = exports.directionOpposite = exports.directionIsCardinal = exports.directionToString = exports.DIRECTIONS = exports.Direction = void 0;\r\nvar Direction;\r\n(function (Direction) {\r\n Direction[Direction[\"NORTH\"] = 0] = \"NORTH\";\r\n Direction[Direction[\"NORTHEAST\"] = 1] = \"NORTHEAST\";\r\n Direction[Direction[\"EAST\"] = 2] = \"EAST\";\r\n Direction[Direction[\"SOUTHEAST\"] = 3] = \"SOUTHEAST\";\r\n Direction[Direction[\"SOUTH\"] = 4] = \"SOUTH\";\r\n Direction[Direction[\"SOUTHWEST\"] = 5] = \"SOUTHWEST\";\r\n Direction[Direction[\"WEST\"] = 6] = \"WEST\";\r\n Direction[Direction[\"NORTHWEST\"] = 7] = \"NORTHWEST\";\r\n})(Direction = exports.Direction || (exports.Direction = {}));\r\nexports.DIRECTIONS = [\r\n Direction.NORTH,\r\n Direction.NORTHEAST,\r\n Direction.EAST,\r\n Direction.SOUTHEAST,\r\n Direction.SOUTH,\r\n Direction.SOUTHWEST,\r\n Direction.WEST,\r\n Direction.NORTHWEST,\r\n];\r\nconst DIRECTIONS_STR = [\r\n 'N',\r\n 'NE',\r\n 'E',\r\n 'SE',\r\n 'S',\r\n 'SW',\r\n 'W',\r\n 'NW',\r\n];\r\nfunction directionToString(dir) {\r\n return DIRECTIONS_STR[dir];\r\n}\r\nexports.directionToString = directionToString;\r\nfunction directionIsCardinal(dir) {\r\n return (dir & 1) === 0;\r\n}\r\nexports.directionIsCardinal = directionIsCardinal;\r\nfunction directionOpposite(dir) {\r\n return ((dir + 4) & 7);\r\n}\r\nexports.directionOpposite = directionOpposite;\r\n// conversion\r\nfunction directionFromCardinalDirection(dir) {\r\n return (dir << 1);\r\n}\r\nexports.directionFromCardinalDirection = directionFromCardinalDirection;\r\n// math\r\nfunction directionAddTurn(dir, turn) {\r\n return ((dir + turn) & 7);\r\n}\r\nexports.directionAddTurn = directionAddTurn;\r\nfunction directionAddCardinalTurn(dir, turn) {\r\n return ((dir + turn * 2) & 7);\r\n}\r\nexports.directionAddCardinalTurn = directionAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.flipFromCardinalOrientation = exports.flipFromBoolean = exports.flipOpposite = exports.flipToString = exports.FLIPS = exports.Flip = void 0;\r\nvar Flip;\r\n(function (Flip) {\r\n Flip[Flip[\"HEADS\"] = 0] = \"HEADS\";\r\n Flip[Flip[\"TAILS\"] = 1] = \"TAILS\";\r\n})(Flip = exports.Flip || (exports.Flip = {}));\r\nexports.FLIPS = [\r\n Flip.HEADS,\r\n Flip.TAILS,\r\n];\r\nconst FLIPS_STR = [\r\n 'H',\r\n 'T',\r\n];\r\nfunction flipToString(flip) {\r\n return FLIPS_STR[flip];\r\n}\r\nexports.flipToString = flipToString;\r\nfunction flipOpposite(flip) {\r\n return (flip ^ 1);\r\n}\r\nexports.flipOpposite = flipOpposite;\r\n// conversion\r\nfunction flipFromBoolean(tails) {\r\n return tails ? Flip.TAILS : Flip.HEADS;\r\n}\r\nexports.flipFromBoolean = flipFromBoolean;\r\nfunction flipFromCardinalOrientation(orientation) {\r\n return (orientation & 1);\r\n}\r\nexports.flipFromCardinalOrientation = flipFromCardinalOrientation;\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\n__exportStar(require(\"./direction\"), exports);\r\n__exportStar(require(\"./turn\"), exports);\r\n__exportStar(require(\"./cardinal-direction\"), exports);\r\n__exportStar(require(\"./cardinal-turn\"), exports);\r\n__exportStar(require(\"./cardinal-direction-flags\"), exports);\r\n__exportStar(require(\"./flip\"), exports);\r\n__exportStar(require(\"./cardinal-orientation\"), exports);\r\n__exportStar(require(\"./axis\"), exports);\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.turnAddTurn = exports.turnFromDirections = exports.turnFromCardinalTurn = exports.turnFromCardinalDirections = exports.turnReverse = exports.turnIsCardinal = exports.turnToDegrees = exports.turnToString = exports.TURNS = exports.Turn = void 0;\r\nvar Turn;\r\n(function (Turn) {\r\n Turn[Turn[\"NONE\"] = 0] = \"NONE\";\r\n Turn[Turn[\"R_45\"] = 1] = \"R_45\";\r\n Turn[Turn[\"R_90\"] = 2] = \"R_90\";\r\n Turn[Turn[\"R_135\"] = 3] = \"R_135\";\r\n Turn[Turn[\"T_180\"] = 4] = \"T_180\";\r\n Turn[Turn[\"L_135\"] = 5] = \"L_135\";\r\n Turn[Turn[\"L_90\"] = 6] = \"L_90\";\r\n Turn[Turn[\"L_45\"] = 7] = \"L_45\";\r\n})(Turn = exports.Turn || (exports.Turn = {}));\r\nexports.TURNS = [\r\n Turn.NONE,\r\n Turn.R_45,\r\n Turn.R_90,\r\n Turn.R_135,\r\n Turn.T_180,\r\n Turn.L_135,\r\n Turn.L_90,\r\n Turn.L_45,\r\n];\r\nconst TURNS_STR = [\r\n 'T0',\r\n 'T+45',\r\n 'T+90',\r\n 'T+135',\r\n 'T180',\r\n 'T-135',\r\n 'T-90',\r\n 'T-45',\r\n];\r\nfunction turnToString(turn) {\r\n return TURNS_STR[turn];\r\n}\r\nexports.turnToString = turnToString;\r\nfunction turnToDegrees(turn) {\r\n return turn * 45;\r\n}\r\nexports.turnToDegrees = turnToDegrees;\r\nfunction turnIsCardinal(turn) {\r\n return (turn & 1) === 0;\r\n}\r\nexports.turnIsCardinal = turnIsCardinal;\r\nfunction turnReverse(turn) {\r\n return ((8 - turn) & 7);\r\n}\r\nexports.turnReverse = turnReverse;\r\n// conversion\r\nfunction turnFromCardinalDirections(from, to) {\r\n return (((to - from) * 2) & 7);\r\n}\r\nexports.turnFromCardinalDirections = turnFromCardinalDirections;\r\nfunction turnFromCardinalTurn(turn) {\r\n return (turn << 1);\r\n}\r\nexports.turnFromCardinalTurn = turnFromCardinalTurn;\r\nfunction turnFromDirections(from, to) {\r\n return ((to - from) & 7);\r\n}\r\nexports.turnFromDirections = turnFromDirections;\r\n// math\r\nfunction turnAddTurn(turn1, turn2) {\r\n return ((turn1 + turn2) & 7);\r\n}\r\nexports.turnAddTurn = turnAddTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.CardinalPath = void 0;\r\nconst compass_1 = require(\"../compass\");\r\nconst offset_1 = require(\"./offset\");\r\nconst rectangle_1 = require(\"./rectangle\");\r\nconst raster_mask_1 = require(\"./raster-mask\");\r\nconst LOCAL_OFF = new offset_1.Offset();\r\nfunction sortedInsert(array, value) {\r\n array.push(value);\r\n let i = array.length - 1;\r\n while (i > 0 && value < array[i - 1]) {\r\n array[i] = array[i - 1];\r\n i--;\r\n }\r\n array[i] = value;\r\n}\r\nclass CardinalPath {\r\n constructor(start, segments) {\r\n this._start = new offset_1.Offset();\r\n this._start.copyFrom(start);\r\n this._segments = segments;\r\n }\r\n // accessors\r\n toString() {\r\n return `${this._start.toString()}:`\r\n + `${this._segments.map((segment) => compass_1.cardinalDirectionToString(segment)).join('')}`;\r\n }\r\n equals(other) {\r\n return this._start.equals(other._start)\r\n && this._segments.length === other._segments.length\r\n && this._segments.every((v, i) => v === other._segments[i]);\r\n }\r\n get length() {\r\n return this._segments.length;\r\n }\r\n // utilities\r\n getIsClosed() {\r\n LOCAL_OFF.copyFrom(this._start);\r\n for (const segment of this._segments) {\r\n LOCAL_OFF.addCardinalDirection(segment);\r\n }\r\n return this._start.equals(LOCAL_OFF);\r\n }\r\n *offsets() {\r\n let { x, y } = this._start;\r\n yield { x, y };\r\n for (const segment of this._segments) {\r\n LOCAL_OFF.setFromCardinalDirection(segment);\r\n x += LOCAL_OFF.x;\r\n y += LOCAL_OFF.y;\r\n yield { x, y };\r\n }\r\n }\r\n getBounds() {\r\n let northY = this._start.y;\r\n let southY = northY;\r\n let westX = this._start.x;\r\n let eastX = westX;\r\n LOCAL_OFF.copyFrom(this._start);\r\n for (const segment of this._segments) {\r\n LOCAL_OFF.addCardinalDirection(segment);\r\n switch (segment) {\r\n case compass_1.CardinalDirection.NORTH:\r\n northY = Math.min(northY, LOCAL_OFF.y);\r\n break;\r\n case compass_1.CardinalDirection.EAST:\r\n eastX = Math.max(eastX, LOCAL_OFF.x);\r\n break;\r\n case compass_1.CardinalDirection.SOUTH:\r\n southY = Math.max(southY, LOCAL_OFF.y);\r\n break;\r\n case compass_1.CardinalDirection.WEST:\r\n westX = Math.min(westX, LOCAL_OFF.x);\r\n break;\r\n // istanbul ignore next\r\n default:\r\n throw new Error(`bad direction ${segment} in cardinal path`);\r\n }\r\n }\r\n return new rectangle_1.Rectangle(westX, northY, eastX - westX + 1, southY - northY + 1);\r\n }\r\n getArea() {\r\n let total = 0;\r\n LOCAL_OFF.copyFrom(this._start);\r\n for (const segment of this._segments) {\r\n LOCAL_OFF.addCardinalDirection(segment);\r\n switch (segment) {\r\n case compass_1.CardinalDirection.NORTH:\r\n total -= LOCAL_OFF.x;\r\n break;\r\n case compass_1.CardinalDirection.SOUTH:\r\n total += LOCAL_OFF.x;\r\n break;\r\n }\r\n }\r\n return Math.abs(total);\r\n }\r\n rasterize(bounds) {\r\n const lines = new Array();\r\n if (typeof bounds === 'undefined') {\r\n bounds = this.getBounds();\r\n }\r\n // assert(this.getIsClosed())\r\n LOCAL_OFF.copyFrom(this._start);\r\n const { northY } = bounds;\r\n const southY = northY + bounds.height - 1;\r\n for (let y = northY; y < southY; y++) {\r\n lines.push([]);\r\n }\r\n LOCAL_OFF.copyFrom(this._start);\r\n // assert(LOCAL_OFF.y >= northY && LOCAL_OFF.y <= southY)\r\n for (const segment of this._segments) {\r\n if (segment === compass_1.CardinalDirection.SOUTH) {\r\n sortedInsert(lines[LOCAL_OFF.y - northY], LOCAL_OFF.x);\r\n }\r\n LOCAL_OFF.addCardinalDirection(segment);\r\n // assert(LOCAL_OFF.y >= northY && LOCAL_OFF.y <= southY)\r\n if (segment === compass_1.CardinalDirection.NORTH) {\r\n sortedInsert(lines[LOCAL_OFF.y - northY], LOCAL_OFF.x);\r\n }\r\n }\r\n return new raster_mask_1.RasterMask({\r\n westX: bounds.westX,\r\n northY: bounds.northY,\r\n width: bounds.width - 1,\r\n height: bounds.height - 1,\r\n }, lines);\r\n }\r\n}\r\nexports.CardinalPath = CardinalPath;\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\n__exportStar(require(\"./offset\"), exports);\r\n__exportStar(require(\"./size\"), exports);\r\n__exportStar(require(\"./rectangle\"), exports);\r\n__exportStar(require(\"./mask\"), exports);\r\n__exportStar(require(\"./mask-rectangle\"), exports);\r\n__exportStar(require(\"./raster-mask\"), exports);\r\n__exportStar(require(\"./cardinal-path\"), exports);\r\n__exportStar(require(\"./transform-rectangle\"), exports);\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.MaskRectangle = void 0;\r\nconst rectangle_1 = require(\"./rectangle\");\r\nconst mask_1 = require(\"./mask\");\r\nclass MaskRectangle {\r\n constructor(rect, initialValue = false, outsideValue = false) {\r\n this._rect = new rectangle_1.Rectangle();\r\n if (typeof rect !== 'undefined') {\r\n this._rect.copyFrom(rect);\r\n }\r\n this._mask = new mask_1.Mask(rect, initialValue);\r\n this._outsideValue = outsideValue;\r\n }\r\n // accessors\r\n toString() {\r\n return `${this._rect.northWest}/${this._outsideValue}\\n${this._mask}`;\r\n }\r\n equals(other) {\r\n return this._rect.equals(other._rect)\r\n && this._mask.equals(other._mask)\r\n && this._outsideValue === other._outsideValue;\r\n }\r\n get westX() {\r\n return this._rect.westX;\r\n }\r\n get northY() {\r\n return this._rect.northY;\r\n }\r\n get width() {\r\n return this._rect.width;\r\n }\r\n get height() {\r\n return this._rect.height;\r\n }\r\n get(x, y) {\r\n if (!this._rect.contains(x, y)) {\r\n return this._outsideValue;\r\n }\r\n return this._mask.get(x - this.westX, y - this.northY);\r\n }\r\n getAtIndex(index) {\r\n return this._mask.getAtIndex(index);\r\n }\r\n getAtOffset(off) {\r\n return this.get(off.x, off.y);\r\n }\r\n // mutators\r\n copyFrom(other) {\r\n this._rect.copyFrom(other._rect);\r\n this._mask.copyFrom(other._mask);\r\n this._outsideValue = other._outsideValue;\r\n return this;\r\n }\r\n set(x, y, value) {\r\n this._mask.set(x - this.westX, y - this.northY, value);\r\n return this;\r\n }\r\n setAtOffset(off, value) {\r\n return this.set(off.x, off.y, value);\r\n }\r\n setAtIndex(index, value) {\r\n this._mask.setAtIndex(index, value);\r\n return this;\r\n }\r\n // utilities\r\n index(x, y) {\r\n return this._mask.index(x - this.westX, y - this.northY);\r\n }\r\n *locations() {\r\n for (const loc of this._mask.locations()) {\r\n const x = loc.x + this.westX;\r\n const y = loc.y + this.northY;\r\n const { value } = loc;\r\n yield { x, y, value };\r\n }\r\n }\r\n *offsetsWithTrue() {\r\n for (const off of this._mask.offsetsWithTrue()) {\r\n const x = off.x + this.westX;\r\n const y = off.y + this.northY;\r\n yield { x, y };\r\n }\r\n }\r\n}\r\nexports.MaskRectangle = MaskRectangle;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.Mask = void 0;\r\nconst size_1 = require(\"./size\");\r\nclass Mask {\r\n constructor(size, initialValue = false) {\r\n this._size = new size_1.Size();\r\n if (typeof size !== 'undefined') {\r\n this._size.copyFrom(size);\r\n }\r\n this._bits = new Array(Math.ceil(this._size.area / 32)).fill(initialValue ? 0xffffffff : 0);\r\n }\r\n // accessors\r\n toString() {\r\n let ret = '';\r\n for (let y = 0; y < this.height; y++) {\r\n for (let x = 0; x < this.width; x++) {\r\n ret += this.get(x, y) ? '☑' : '☐';\r\n }\r\n ret += '\\n';\r\n }\r\n return ret;\r\n }\r\n equals(other) {\r\n return this._size.equals(other._size)\r\n && this._bits.length === other._bits.length\r\n && this._bits.every((v, i) => v === other._bits[i]);\r\n }\r\n get width() {\r\n return this._size.width;\r\n }\r\n get height() {\r\n return this._size.height;\r\n }\r\n get(x, y) {\r\n return this.getAtIndex(this.index(x, y));\r\n }\r\n getAtOffset(off) {\r\n return this.get(off.x, off.y);\r\n }\r\n getAtIndex(index) {\r\n // assert(index >= 0 && index < this._size.area)\r\n const arrayIndex = index >>> 5;\r\n const bitMask = 1 << (index & 31);\r\n return (this._bits[arrayIndex] & bitMask) !== 0;\r\n }\r\n // mutators\r\n copyFrom(other) {\r\n this._size.copyFrom(other._size);\r\n this._bits = other._bits.slice();\r\n return this;\r\n }\r\n set(x, y, value) {\r\n return this.setAtIndex(this.index(x, y), value);\r\n }\r\n setAtOffset(off, value) {\r\n return this.set(off.x, off.y, value);\r\n }\r\n setAtIndex(index, value) {\r\n // assert(index >= 0 && index < this._size.area)\r\n const arrayIndex = index >>> 5;\r\n const bitMask = 1 << (index & 31);\r\n if (value) {\r\n this._bits[arrayIndex] |= bitMask;\r\n }\r\n else {\r\n this._bits[arrayIndex] &= ~bitMask;\r\n }\r\n return this;\r\n }\r\n // utilities\r\n index(x, y) {\r\n return this._size.index(x, y);\r\n }\r\n *locations() {\r\n let arrayIndex = 0;\r\n let bitMask = 1;\r\n for (const { x, y } of this._size.offsets()) {\r\n const value = (this._bits[arrayIndex] & bitMask) !== 0;\r\n yield { x, y, value };\r\n if (bitMask === (1 << 31)) {\r\n bitMask = 1;\r\n arrayIndex++;\r\n }\r\n else {\r\n bitMask <<= 1;\r\n }\r\n }\r\n }\r\n *offsetsWithTrue() {\r\n for (const { x, y, value } of this.locations()) {\r\n if (value) {\r\n yield { x, y };\r\n }\r\n }\r\n }\r\n}\r\nexports.Mask = Mask;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.Offset = void 0;\r\nconst compass_1 = require(\"../compass\");\r\nconst X_FROM_DIRECTION = [0, 1, 1, 1, 0, -1, -1, -1];\r\nconst Y_FROM_DIRECTION = [-1, -1, 0, 1, 1, 1, 0, -1];\r\nconst X_FROM_CARDINAL_DIRECTION = [0, 1, 0, -1];\r\nconst Y_FROM_CARDINAL_DIRECTION = [-1, 0, 1, 0];\r\nclass Offset {\r\n constructor(x, y) {\r\n if (typeof x === 'undefined') {\r\n x = 0;\r\n }\r\n if (typeof y === 'undefined') {\r\n y = 0;\r\n }\r\n this.x = x;\r\n this.y = y;\r\n }\r\n // accessors\r\n toString() {\r\n return `(${this.x},${this.y})`;\r\n }\r\n equals(other) {\r\n return this.x === other.x && this.y === other.y;\r\n }\r\n // mutators\r\n set(x, y) {\r\n this.x = x;\r\n this.y = y;\r\n return this;\r\n }\r\n copyFrom(other) {\r\n return this.set(other.x, other.y);\r\n }\r\n setFromDirection(dir) {\r\n return this.set(X_FROM_DIRECTION[dir], Y_FROM_DIRECTION[dir]);\r\n }\r\n setFromCardinalDirection(dir) {\r\n return this.set(X_FROM_CARDINAL_DIRECTION[dir], Y_FROM_CARDINAL_DIRECTION[dir]);\r\n }\r\n add(x, y) {\r\n this.x += x;\r\n this.y += y;\r\n return this;\r\n }\r\n addSize(size) {\r\n return this.add(size.width, size.height);\r\n }\r\n addOffset(off) {\r\n return this.add(off.x, off.y);\r\n }\r\n addDirection(dir) {\r\n return this.add(X_FROM_DIRECTION[dir], Y_FROM_DIRECTION[dir]);\r\n }\r\n addCardinalDirection(dir) {\r\n return this.add(X_FROM_CARDINAL_DIRECTION[dir], Y_FROM_CARDINAL_DIRECTION[dir]);\r\n }\r\n subtractOffset(off) {\r\n return this.add(-off.x, -off.y);\r\n }\r\n multiply(factor) {\r\n this.x *= factor;\r\n this.y *= factor;\r\n return this;\r\n }\r\n rotate(turn, anchor) {\r\n if (anchor) {\r\n return this.subtractOffset(anchor).rotate(turn).addOffset(anchor);\r\n }\r\n else {\r\n const dir = compass_1.cardinalDirectionFromNorthTurn(turn);\r\n const { x, y } = this;\r\n const dirx = X_FROM_CARDINAL_DIRECTION[dir];\r\n const diry = Y_FROM_CARDINAL_DIRECTION[dir];\r\n const nx = -y * dirx - x * diry;\r\n const ny = x * dirx - y * diry;\r\n return this.set(nx, ny);\r\n }\r\n }\r\n // utilities\r\n // chebyshev: can move in any direction (diagonals are ok)\r\n distanceChebyshev(other) {\r\n return Math.max(Math.abs(this.x - other.x), Math.abs(this.y - other.y));\r\n }\r\n // manhattan: can move only in cardinal directions (no diagonals)\r\n distanceManhattan(other) {\r\n return Math.abs(this.x - other.x) + Math.abs(this.y - other.y);\r\n }\r\n // chebyshev: can move in any direction (diagonals are ok)\r\n *nearbyChebyshevOffsets(cursor, radius) {\r\n if (radius >= 0) {\r\n for (let dy = -radius; dy <= radius; dy++) {\r\n for (let dx = -radius; dx <= radius; dx++) {\r\n yield cursor.set(this.x + dx, this.y + dy);\r\n }\r\n }\r\n }\r\n }\r\n}\r\nexports.Offset = Offset;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.RasterMask = void 0;\r\nconst rectangle_1 = require(\"./rectangle\");\r\nclass RasterMask {\r\n constructor(bounds, lines) {\r\n this._rect = new rectangle_1.Rectangle();\r\n if (lines.length !== bounds.height) {\r\n throw new Error(`bad lines array length ${lines.length} for bounds ${bounds}`);\r\n }\r\n this._rect.copyFrom(bounds);\r\n this._lines = lines;\r\n }\r\n // accessors\r\n toString() {\r\n let shape = '';\r\n const { eastX } = this._rect;\r\n for (let y = 0; y < this.height; y++) {\r\n const line = this._lines[y];\r\n let x = this.westX;\r\n for (let i = 0; i < line.length; i += 2) {\r\n const start = line[i];\r\n const end = line[i + 1];\r\n while (x < start) {\r\n shape += '∙';\r\n x++;\r\n }\r\n while (x < end) {\r\n shape += '█';\r\n x++;\r\n }\r\n }\r\n while (x <= eastX) {\r\n shape += '∙';\r\n x++;\r\n }\r\n shape += '\\n';\r\n }\r\n return `(${this._rect.westX},${this._rect.northY})\\n${shape}`;\r\n }\r\n equals(other) {\r\n return this._rect.equals(other._rect)\r\n && this._lines.length === other._lines.length\r\n && this._lines.every((v, i) => (v.length === other._lines[i].length\r\n && v.every((w, j) => w === other._lines[i][j])));\r\n }\r\n get northY() {\r\n return this._rect.northY;\r\n }\r\n get southY() {\r\n return this._rect.southY;\r\n }\r\n get westX() {\r\n return this._rect.westX;\r\n }\r\n get width() {\r\n return this._rect.width;\r\n }\r\n get height() {\r\n return this._rect.height;\r\n }\r\n get(x, y) {\r\n if (y < this.northY || y > this._rect.southY) {\r\n return false;\r\n }\r\n const line = this._lines[y - this.northY];\r\n for (let i = 0; i < line.length; i += 2) {\r\n if (x >= line[i] && x < line[i + 1]) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n getAtOffset(off) {\r\n return this.get(off.x, off.y);\r\n }\r\n // utilities\r\n *bandsAt(y) {\r\n if (y >= this.northY && y <= this._rect.southY) {\r\n const line = this._lines[y - this.northY];\r\n for (let i = 0; i < line.length; i += 2) {\r\n yield {\r\n westX: line[i],\r\n eastX: line[i + 1] - 1,\r\n };\r\n }\r\n }\r\n }\r\n}\r\nexports.RasterMask = RasterMask;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.Rectangle = void 0;\r\nconst size_1 = require(\"./size\");\r\nconst offset_1 = require(\"./offset\");\r\nconst ROTATE_CORNER_X = [0, 0, 1, 1];\r\nconst ROTATE_CORNER_Y = [0, 1, 1, 0];\r\nclass Rectangle {\r\n constructor(westX, northY, width, height) {\r\n if (typeof westX === 'undefined') {\r\n westX = 0;\r\n }\r\n if (typeof northY === 'undefined') {\r\n northY = 0;\r\n }\r\n if (typeof width === 'undefined') {\r\n width = 0;\r\n }\r\n if (typeof height === 'undefined') {\r\n height = 0;\r\n }\r\n this.northWest = new offset_1.Offset(westX, northY);\r\n this.size = new size_1.Size(width, height);\r\n }\r\n // accessors\r\n toString() {\r\n return `(${this.westX},${this.northY} ${this.width}x${this.height})`;\r\n }\r\n equals(other) {\r\n return this.westX === other.westX && this.northY === other.northY && this.size.equals(other);\r\n }\r\n get northY() {\r\n return this.northWest.y;\r\n }\r\n get southY() {\r\n return this.northWest.y + this.size.height - 1;\r\n }\r\n get westX() {\r\n return this.northWest.x;\r\n }\r\n get eastX() {\r\n return this.northWest.x + this.size.width - 1;\r\n }\r\n get width() {\r\n return this.size.width;\r\n }\r\n get height() {\r\n return this.size.height;\r\n }\r\n get empty() {\r\n return this.size.empty;\r\n }\r\n get area() {\r\n return this.size.area;\r\n }\r\n // mutators\r\n set(westX, northY, width, height) {\r\n this.northWest.set(westX, northY);\r\n this.size.set(width, height);\r\n return this;\r\n }\r\n setFromCorners(off1, off2) {\r\n const westX = Math.min(off1.x, off2.x);\r\n const eastX = Math.max(off1.x, off2.x);\r\n const northY = Math.min(off1.y, off2.y);\r\n const southY = Math.max(off1.y, off2.y);\r\n return this.set(westX, northY, eastX - westX + 1, southY - northY + 1);\r\n }\r\n copyFrom(other) {\r\n return this.set(other.westX, other.northY, other.width, other.height);\r\n }\r\n addOffset(off) {\r\n this.northWest.addOffset(off);\r\n return this;\r\n }\r\n scale(factor) {\r\n this.northWest.multiply(factor);\r\n this.size.multiply(factor);\r\n return this;\r\n }\r\n rotate(turn, anchor) {\r\n const cx = ROTATE_CORNER_X[turn];\r\n const cy = ROTATE_CORNER_Y[turn];\r\n this.northWest.add(cx * (this.width - 1), cy * (this.height - 1)).rotate(turn, anchor);\r\n this.size.rotate(turn);\r\n return this;\r\n }\r\n extendToInclude(off) {\r\n const dx = off.x - this.westX;\r\n if (dx < 0) {\r\n this.size.width -= dx;\r\n this.northWest.x = off.x;\r\n }\r\n else if (dx >= this.size.width) {\r\n this.size.width = dx + 1;\r\n }\r\n const dy = off.y - this.northWest.y;\r\n if (dy < 0) {\r\n this.size.height -= dy;\r\n this.northWest.y = off.y;\r\n }\r\n else if (dy >= this.size.height) {\r\n this.size.height = dy + 1;\r\n }\r\n return this;\r\n }\r\n // utilities\r\n contains(x, y) {\r\n return this.size.contains(x - this.westX, y - this.northY);\r\n }\r\n index(x, y) {\r\n return this.size.index(x - this.westX, y - this.northY);\r\n }\r\n containsOffset(off) {\r\n return this.contains(off.x, off.y);\r\n }\r\n containsRectangle(other) {\r\n if (other.width === 0 && other.height === 0) {\r\n return false;\r\n }\r\n const x = other.westX - this.westX;\r\n const y = other.northY - this.northY;\r\n if (!this.size.contains(x, y)) {\r\n return false;\r\n }\r\n return this.size.contains(x + other.width - 1, y + other.height - 1);\r\n }\r\n overlapsRectangle(other) {\r\n return this.northY <= other.northY + other.height - 1\r\n && this.southY >= other.northY\r\n && this.westX <= other.westX + other.width - 1\r\n && this.eastX >= other.westX\r\n && !this.empty\r\n && other.width !== 0 && other.height !== 0;\r\n }\r\n *offsets() {\r\n const { eastX, southY } = this;\r\n for (let y = this.northY; y <= southY; y++) {\r\n for (let x = this.westX; x <= eastX; x++) {\r\n yield { x, y };\r\n }\r\n }\r\n }\r\n anyOf(predicate) {\r\n for (const { x, y } of this.offsets()) {\r\n if (predicate(x, y)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n}\r\nexports.Rectangle = Rectangle;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.Size = void 0;\r\nconst compass_1 = require(\"../compass\");\r\nclass Size {\r\n constructor(width, height) {\r\n if (typeof width === 'undefined') {\r\n width = 0;\r\n }\r\n if (typeof height === 'undefined') {\r\n height = 0;\r\n }\r\n if (width < 0 || height < 0) {\r\n throw new Error(`bad size (${width}x${height})`);\r\n }\r\n this.width = width;\r\n this.height = height;\r\n }\r\n // accessors\r\n toString() {\r\n return `(${this.width}x${this.height})`;\r\n }\r\n equals(other) {\r\n return this.width === other.width && this.height === other.height;\r\n }\r\n get empty() {\r\n return this.width === 0 || this.height === 0;\r\n }\r\n get area() {\r\n return this.width * this.height;\r\n }\r\n // mutators\r\n set(width, height) {\r\n if (width < 0 || height < 0) {\r\n throw new Error(`bad size (${width}x${height})`);\r\n }\r\n this.width = width;\r\n this.height = height;\r\n return this;\r\n }\r\n copyFrom(other) {\r\n return this.set(other.width, other.height);\r\n }\r\n add(width, height) {\r\n this.width += width;\r\n this.height += height;\r\n return this;\r\n }\r\n multiply(factor) {\r\n this.width *= factor;\r\n this.height *= factor;\r\n return this;\r\n }\r\n rotate(turn) {\r\n if (compass_1.axisFromNorthSouthTurn(turn) === compass_1.Axis.WEST_EAST) {\r\n this.set(this.height, this.width);\r\n }\r\n return this;\r\n }\r\n // utilities\r\n contains(x, y) {\r\n return x >= 0 && y >= 0 && x < this.width && y < this.height;\r\n }\r\n containsOffset(off) {\r\n return this.contains(off.x, off.y);\r\n }\r\n index(x, y) {\r\n return y * this.width + x;\r\n }\r\n *offsets() {\r\n for (let y = 0; y < this.height; y++) {\r\n for (let x = 0; x < this.width; x++) {\r\n yield { x, y };\r\n }\r\n }\r\n }\r\n anyOf(predicate) {\r\n for (const { x, y } of this.offsets()) {\r\n if (predicate(x, y)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n}\r\nexports.Size = Size;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.TransformRectangle = void 0;\r\nconst rectangle_1 = require(\"./rectangle\");\r\nconst compass_1 = require(\"../compass\");\r\nconst offset_1 = require(\"./offset\");\r\nconst size_1 = require(\"./size\");\r\nconst LOCAL_OFF = new offset_1.Offset();\r\nconst LOCAL_OFF2 = new offset_1.Offset();\r\nconst LOCAL_SIZE = new size_1.Size();\r\nclass TransformRectangle {\r\n constructor(width, height) {\r\n this._size = new size_1.Size();\r\n this._flip = compass_1.Flip.HEADS;\r\n this._rotate = compass_1.CardinalTurn.NONE;\r\n this._translate = new offset_1.Offset();\r\n this._matrix = [1, 0, 0, 0, 1, 0];\r\n this._targetRect = new rectangle_1.Rectangle();\r\n if (typeof width === 'undefined') {\r\n // nothing\r\n }\r\n else if (typeof width === 'number') {\r\n this._size.set(width, height);\r\n }\r\n else {\r\n this._size.copyFrom(width);\r\n }\r\n this._update();\r\n }\r\n // accessors\r\n toString() {\r\n return `[${this._size}`\r\n + ` -> ${compass_1.flipToString(this._flip)} ${compass_1.cardinalTurnToString(this._rotate)} ${this._translate}`\r\n + ` -> ${this._targetRect}]`;\r\n }\r\n equals(other) {\r\n return this._size.equals(other._size)\r\n && this._flip === other._flip\r\n && this._rotate === other._rotate\r\n && this._translate.equals(other._translate);\r\n }\r\n get flip() {\r\n return this._flip;\r\n }\r\n get rotate() {\r\n return this._rotate;\r\n }\r\n get northY() {\r\n return this._translate.y;\r\n }\r\n get southY() {\r\n return this._translate.y + this._targetRect.height - 1;\r\n }\r\n get westX() {\r\n return this._translate.x;\r\n }\r\n get eastX() {\r\n return this._translate.x + this._targetRect.width - 1;\r\n }\r\n get width() {\r\n return this._targetRect.width;\r\n }\r\n get height() {\r\n return this._targetRect.height;\r\n }\r\n // internal\r\n // 0\r\n // 0 -1\r\n // +90\r\n // 1 0\r\n // 180\r\n // 0 1\r\n // -90\r\n // -1 0\r\n //\r\n // heads:\r\n // 0\r\n // 1 0 x\r\n // 0 1 y\r\n // +90\r\n // 0 -1 x + h - 1\r\n // 1 0 y\r\n // 180\r\n // -1 0 x + w - 1\r\n // 0 -1 y + h - 1\r\n // -90\r\n // 0 1 x\r\n // -1 0 y + w - 1\r\n //\r\n // tails:\r\n // 0\r\n // -1 0 x + w - 1\r\n // 0 1 y\r\n // +90\r\n // 0 -1 x + h - 1\r\n // -1 0 y + w - 1\r\n // 180\r\n // 1 0 x\r\n // 0 -1 y + h - 1\r\n // -90\r\n // 0 1 x\r\n // 1 0 y\r\n _update() {\r\n LOCAL_OFF.setFromCardinalDirection(compass_1.cardinalDirectionFromNorthTurn(this._rotate));\r\n const flipSign = this._flip === compass_1.Flip.TAILS ? -1 : 1;\r\n this._matrix[0] = -LOCAL_OFF.y * flipSign;\r\n this._matrix[1] = -LOCAL_OFF.x;\r\n this._matrix[2] = this._translate.x;\r\n this._matrix[3] = LOCAL_OFF.x * flipSign;\r\n this._matrix[4] = -LOCAL_OFF.y;\r\n this._matrix[5] = this._translate.y;\r\n switch (this._rotate) {\r\n case compass_1.CardinalTurn.NONE:\r\n if (this._flip === compass_1.Flip.TAILS) {\r\n this._matrix[2] += this._size.width - 1;\r\n }\r\n break;\r\n case compass_1.CardinalTurn.RIGHT:\r\n this._matrix[2] += this._size.height - 1;\r\n if (this._flip === compass_1.Flip.TAILS) {\r\n this._matrix[5] += this._size.width - 1;\r\n }\r\n break;\r\n case compass_1.CardinalTurn.AROUND:\r\n this._matrix[5] += this._size.height - 1;\r\n if (this._flip === compass_1.Flip.HEADS) {\r\n this._matrix[2] += this._size.width - 1;\r\n }\r\n break;\r\n case compass_1.CardinalTurn.LEFT:\r\n if (this._flip === compass_1.Flip.HEADS) {\r\n this._matrix[5] += this._size.width - 1;\r\n }\r\n break;\r\n }\r\n LOCAL_SIZE.copyFrom(this._size).rotate(this._rotate);\r\n this._targetRect.set(this._translate.x, this._translate.y, LOCAL_SIZE.width, LOCAL_SIZE.height);\r\n return this;\r\n }\r\n // mutators\r\n copyFrom(other) {\r\n this._size.copyFrom(other._size);\r\n this._flip = other._flip;\r\n this._rotate = other._rotate;\r\n this._translate.copyFrom(other._translate);\r\n other._matrix.forEach((v, i) => this._matrix[i] = v);\r\n this._targetRect.copyFrom(other._targetRect);\r\n return this;\r\n }\r\n reset() {\r\n this._flip = compass_1.Flip.HEADS;\r\n this._rotate = compass_1.CardinalTurn.NONE;\r\n this._translate.set(0, 0);\r\n return this._update();\r\n }\r\n invert() {\r\n const nrotate = compass_1.cardinalTurnFromCardinalDirections(compass_1.CardinalDirection.NORTH, compass_1.cardinalDirectionFromCardinalOrientation(compass_1.cardinalOrientationReverse(compass_1.cardinalOrientationFromFlipAndCardinalDirection(this._flip, compass_1.cardinalDirectionFromNorthTurn(this._rotate)))));\r\n this._rotate = nrotate;\r\n this._size.rotate(nrotate);\r\n this._translate.multiply(-1);\r\n return this._update();\r\n }\r\n setTransform(flip, rotate, translate) {\r\n this._flip = flip;\r\n this._rotate = rotate;\r\n this._translate.copyFrom(translate);\r\n return this._update();\r\n }\r\n setFlip(flip) {\r\n this._flip = flip;\r\n return this._update();\r\n }\r\n setRotate(rotate) {\r\n this._rotate = rotate;\r\n return this._update();\r\n }\r\n setTranslate(x, y) {\r\n this._translate.set(x, y);\r\n return this._update();\r\n }\r\n setTranslateOffset(translate) {\r\n this._translate.copyFrom(translate);\r\n return this._update();\r\n }\r\n // utility\r\n applyToCardinalOrientation(orientation) {\r\n if (this._flip === compass_1.Flip.TAILS) {\r\n orientation = compass_1.cardinalOrientationFlip(orientation, compass_1.Axis.NORTH_SOUTH);\r\n }\r\n return compass_1.cardinalOrientationAddCardinalTurn(orientation, this._rotate);\r\n }\r\n unapplyFromCardinalOrientation(orientation) {\r\n orientation = compass_1.cardinalOrientationAddCardinalTurn(orientation, compass_1.cardinalTurnReverse(this._rotate));\r\n if (this._flip === compass_1.Flip.TAILS) {\r\n orientation = compass_1.cardinalOrientationFlip(orientation, compass_1.Axis.NORTH_SOUTH);\r\n }\r\n return orientation;\r\n }\r\n applyToCardinalDirection(orientation) {\r\n return compass_1.cardinalDirectionFromCardinalOrientation(this.applyToCardinalOrientation(compass_1.cardinalOrientationFromFlipAndCardinalDirection(compass_1.Flip.HEADS, orientation)));\r\n }\r\n unapplyFromCardinalDirection(orientation) {\r\n return compass_1.cardinalDirectionFromCardinalOrientation(this.unapplyFromCardinalOrientation(compass_1.cardinalOrientationFromFlipAndCardinalDirection(compass_1.Flip.HEADS, orientation)));\r\n }\r\n applyTo(offOut, x, y) {\r\n const nx = x * this._matrix[0] + y * this._matrix[1] + this._matrix[2];\r\n const ny = x * this._matrix[3] + y * this._matrix[4] + this._matrix[5];\r\n return offOut.set(nx, ny);\r\n }\r\n unapplyFrom(offOut, x, y) {\r\n const tx = x - this._matrix[2];\r\n const ty = y - this._matrix[5];\r\n const nx = tx * this._matrix[0] + ty * this._matrix[3];\r\n const ny = tx * this._matrix[1] + ty * this._matrix[4];\r\n return offOut.set(nx, ny);\r\n }\r\n applyToOffset(offOut, off) {\r\n if (typeof off === 'undefined') {\r\n off = offOut;\r\n }\r\n return this.applyTo(offOut, off.x, off.y);\r\n }\r\n unapplyFromOffset(offOut, off) {\r\n if (typeof off === 'undefined') {\r\n off = offOut;\r\n }\r\n return this.unapplyFrom(offOut, off.x, off.y);\r\n }\r\n applyToRectangle(rectOut, rect) {\r\n if (typeof rect !== 'undefined') {\r\n rectOut.copyFrom(rect);\r\n }\r\n LOCAL_OFF.set(rectOut.westX, rectOut.northY);\r\n LOCAL_OFF2.set(rectOut.eastX, rectOut.southY);\r\n this.applyToOffset(LOCAL_OFF);\r\n this.applyToOffset(LOCAL_OFF2);\r\n return rectOut.setFromCorners(LOCAL_OFF, LOCAL_OFF2);\r\n }\r\n unapplyFromRectangle(rectOut, rect) {\r\n if (typeof rect !== 'undefined') {\r\n rectOut.copyFrom(rect);\r\n }\r\n LOCAL_OFF.set(rectOut.westX, rectOut.northY);\r\n LOCAL_OFF2.set(rectOut.eastX, rectOut.southY);\r\n this.unapplyFromOffset(LOCAL_OFF);\r\n this.unapplyFromOffset(LOCAL_OFF2);\r\n return rectOut.setFromCorners(LOCAL_OFF, LOCAL_OFF2);\r\n }\r\n}\r\nexports.TransformRectangle = TransformRectangle;\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\n__exportStar(require(\"./compass\"), exports);\r\n__exportStar(require(\"./grid\"), exports);\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n});\r\nvar __importStar = (this && this.__importStar) || function (mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.makeBlockFractal = void 0;\r\nconst geom = __importStar(require(\"tiled-geometry\"));\r\nfunction nextToLastMatch(points, next) {\r\n return points.length > 1 && points[points.length - 2].equals(next);\r\n}\r\nfunction addPoint(points, mask, next) {\r\n if (nextToLastMatch(points, next)) {\r\n mask.setAtOffset(points.splice(points.length - 1, 1)[0], false);\r\n }\r\n else {\r\n points.push(next);\r\n mask.setAtOffset(next, true);\r\n }\r\n}\r\nfunction verticalHelper(points, random, variation, newPoints, mask, i, p1, p2) {\r\n const x = 2 * p1.x;\r\n const yDir = p2.y - p1.y;\r\n for (let y = 2 * p1.y; y !== 2 * p2.y; y += yDir) {\r\n const np3 = new geom.Offset(x, y + yDir);\r\n // console.info(`- ${np3}`);\r\n if (nextToLastMatch(newPoints, np3)) {\r\n // This can happen around a corner, when just before the corner\r\n // we dip into the corner\r\n // console.info(` remove ${newPoints[newPoints.length - 1]}`);\r\n mask.setAtOffset(newPoints.splice(newPoints.length - 1, 1)[0], false);\r\n continue;\r\n }\r\n if (i === points.length - 2 && mask.getAtOffset(np3)) {\r\n // This can happen if the first point was on a corner and the\r\n // first move was to dip into the corner\r\n const index = newPoints.findIndex((point) => point.equals(np3));\r\n // console.info(`remove ${index} from beginning`);\r\n for (const point of newPoints.splice(0, index)) {\r\n mask.setAtOffset(point, false);\r\n }\r\n addPoint(newPoints, mask, np3);\r\n break;\r\n }\r\n if (random() < variation) {\r\n const v = Math.floor(random() * 2) * 2 - 1;\r\n const np1 = new geom.Offset(x + v, y);\r\n const np2 = new geom.Offset(x + v, y + yDir);\r\n if (!mask.getAtOffset(np2)) {\r\n if (!mask.getAtOffset(np1) || nextToLastMatch(newPoints, np1)) {\r\n addPoint(newPoints, mask, np1);\r\n addPoint(newPoints, mask, np2);\r\n }\r\n }\r\n }\r\n addPoint(newPoints, mask, np3);\r\n }\r\n}\r\nfunction horizontalHelper(points, random, variation, newPoints, mask, i, p1, p2) {\r\n const y = 2 * p1.y;\r\n const xDir = p2.x - p1.x;\r\n for (let x = 2 * p1.x; x !== 2 * p2.x; x += xDir) {\r\n const np3 = new geom.Offset(x + xDir, y);\r\n // console.info(`- ${np3}`);\r\n if (nextToLastMatch(newPoints, np3)) {\r\n // This can happen around a corner, when just before the corner\r\n // we dip in the direction of the corner\r\n // console.info(` remove ${newPoints[newPoints.length - 1]}`);\r\n mask.setAtOffset(newPoints.splice(newPoints.length - 1, 1)[0], false);\r\n continue;\r\n }\r\n if (i === points.length - 2 && mask.getAtOffset(np3)) {\r\n // This can happen if the first point was on a corner and the\r\n // first move was to dip into the corner\r\n const index = newPoints.findIndex((point) => point.equals(np3));\r\n // console.info(`remove ${index} from beginning`);\r\n for (const point of newPoints.splice(0, index)) {\r\n mask.setAtOffset(point, false);\r\n }\r\n addPoint(newPoints, mask, np3);\r\n break;\r\n }\r\n if (random() < variation) {\r\n const v = Math.floor(random() * 2) * 2 - 1;\r\n const np1 = new geom.Offset(x, y + v);\r\n const np2 = new geom.Offset(x + xDir, y + v);\r\n if (!mask.getAtOffset(np2)) {\r\n if (!mask.getAtOffset(np1) || nextToLastMatch(newPoints, np1)) {\r\n addPoint(newPoints, mask, np1);\r\n addPoint(newPoints, mask, np2);\r\n }\r\n }\r\n }\r\n addPoint(newPoints, mask, np3);\r\n }\r\n}\r\nfunction blockFractalIteration(random, points, bounds, variation) {\r\n const newPoints = new Array();\r\n const newBounds = new geom.Rectangle(bounds.westX * 2 - 1, bounds.northY * 2 - 1, bounds.width * 2 + 2, bounds.height * 2 + 2);\r\n // console.info(` bounds ${newBounds}`);\r\n const mask = new geom.MaskRectangle(newBounds);\r\n for (let i = 0; i < points.length - 1; i++) {\r\n const p1 = points[i];\r\n const p2 = points[i + 1];\r\n if (i === 0) {\r\n addPoint(newPoints, mask, new geom.Offset(p1.x * 2, p1.y * 2));\r\n }\r\n if (p1.x === p2.x) {\r\n verticalHelper(points, random, variation, newPoints, mask, i, p1, p2);\r\n }\r\n else {\r\n horizontalHelper(points, random, variation, newPoints, mask, i, p1, p2);\r\n }\r\n }\r\n return {\r\n points: newPoints,\r\n bounds: newBounds,\r\n };\r\n}\r\nfunction makeBlockFractal(param) {\r\n let { random, shape, variation } = param;\r\n if (typeof random === 'undefined') {\r\n random = Math.random;\r\n }\r\n if (typeof shape === 'undefined') {\r\n shape = new geom.CardinalPath({ x: -1, y: -1 }, [\r\n geom.CardinalDirection.EAST,\r\n geom.CardinalDirection.EAST,\r\n geom.CardinalDirection.SOUTH,\r\n geom.CardinalDirection.SOUTH,\r\n geom.CardinalDirection.WEST,\r\n geom.CardinalDirection.WEST,\r\n geom.CardinalDirection.NORTH,\r\n geom.CardinalDirection.NORTH,\r\n ]);\r\n }\r\n if (typeof variation === 'undefined') {\r\n variation = 0.4;\r\n }\r\n let points = new Array();\r\n let bounds = shape.getBounds();\r\n for (const off of shape.offsets()) {\r\n points.push(new geom.Offset(off.x, off.y));\r\n }\r\n for (let iter = 0; iter < param.iterations; iter++) {\r\n // console.info(`iteration ${iter + 1}`);\r\n ({ points, bounds } = blockFractalIteration(random, points, bounds, variation));\r\n }\r\n const segments = new Array();\r\n for (let i = 0; i < points.length - 1; i++) {\r\n const curPoint = points[i];\r\n const nextPoint = points[i + 1];\r\n if (nextPoint.y === curPoint.y - 1) {\r\n segments.push(geom.CardinalDirection.NORTH);\r\n }\r\n else if (nextPoint.x === curPoint.x + 1) {\r\n segments.push(geom.CardinalDirection.EAST);\r\n }\r\n else if (nextPoint.y === curPoint.y + 1) {\r\n segments.push(geom.CardinalDirection.SOUTH);\r\n }\r\n else if (nextPoint.x === curPoint.x - 1) {\r\n segments.push(geom.CardinalDirection.WEST);\r\n }\r\n }\r\n return new geom.CardinalPath(points[0], segments);\r\n}\r\nexports.makeBlockFractal = makeBlockFractal;\r\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","\"use strict\";\r\n/*\r\n * BlockFractal\r\n * github.com/sbj42/block-fractal\r\n * James Clark\r\n * Licensed under the MIT license.\r\n */\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.RasterMask = exports.CardinalPath = exports.Offset = exports.CardinalDirectionFlags = exports.CardinalDirection = exports.makeBlockFractal = void 0;\r\nvar block_fractal_1 = require(\"./block-fractal\");\r\nObject.defineProperty(exports, \"makeBlockFractal\", { enumerable: true, get: function () { return block_fractal_1.makeBlockFractal; } });\r\nvar tiled_geometry_1 = require(\"tiled-geometry\");\r\nObject.defineProperty(exports, \"CardinalDirection\", { enumerable: true, get: function () { return tiled_geometry_1.CardinalDirection; } });\r\nObject.defineProperty(exports, \"CardinalDirectionFlags\", { enumerable: true, get: function () { return tiled_geometry_1.CardinalDirectionFlags; } });\r\nObject.defineProperty(exports, \"Offset\", { enumerable: true, get: function () { return tiled_geometry_1.Offset; } });\r\nObject.defineProperty(exports, \"CardinalPath\", { enumerable: true, get: function () { return tiled_geometry_1.CardinalPath; } });\r\nObject.defineProperty(exports, \"RasterMask\", { enumerable: true, get: function () { return tiled_geometry_1.RasterMask; } });\r\n"],"names":[],"sourceRoot":""} \ No newline at end of file diff --git a/dist/block-fractal-2.0.2.min.js b/dist/block-fractal-2.0.2.min.js new file mode 100644 index 0000000..4801e21 --- /dev/null +++ b/dist/block-fractal-2.0.2.min.js @@ -0,0 +1,2 @@ +var BlockFractal;(()=>{"use strict";var t={677:(t,i)=>{var e;Object.defineProperty(i,"__esModule",{value:!0}),i.axisAddCardinalTurn=i.axisFromNorthSouthTurn=i.axisFromCardinalDirection=i.axisOrthogonal=i.axisToString=i.AXES=i.Axis=void 0,function(t){t[t.NORTH_SOUTH=0]="NORTH_SOUTH",t[t.WEST_EAST=1]="WEST_EAST"}(e=i.Axis||(i.Axis={})),i.AXES=[e.NORTH_SOUTH,e.WEST_EAST];const r=["N-S","W-E"];i.axisToString=function(t){return r[t]},i.axisOrthogonal=function(t){return 1^t},i.axisFromCardinalDirection=function(t){return 1&t},i.axisFromNorthSouthTurn=function(t){return 1&t},i.axisAddCardinalTurn=function(t,i){return t+i&1}},340:(t,i)=>{var e;function r(t){return 1<{var e;Object.defineProperty(i,"__esModule",{value:!0}),i.cardinalDirectionAddCardinalTurn=i.cardinalDirectionFromCardinalOrientation=i.cardinalDirectionFromNorthTurn=i.cardinalDirectionFromDirection=i.cardinalDirectionOpposite=i.cardinalDirectionToString=i.CARDINAL_DIRECTIONS=i.CardinalDirection=void 0,function(t){t[t.NORTH=0]="NORTH",t[t.EAST=1]="EAST",t[t.SOUTH=2]="SOUTH",t[t.WEST=3]="WEST"}(e=i.CardinalDirection||(i.CardinalDirection={})),i.CARDINAL_DIRECTIONS=[e.NORTH,e.EAST,e.SOUTH,e.WEST];const r=["N","E","S","W"];i.cardinalDirectionToString=function(t){return r[t]},i.cardinalDirectionOpposite=function(t){return t+2&3},i.cardinalDirectionFromDirection=function(t){return t>>1},i.cardinalDirectionFromNorthTurn=function(t){return t},i.cardinalDirectionFromCardinalOrientation=function(t){return t>>>1},i.cardinalDirectionAddCardinalTurn=function(t,i){return t+i&3}},852:(t,i,e)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.cardinalOrientationAddCardinalTurn=i.cardinalOrientationFromFlipAndCardinalDirection=i.cardinalOrientationReverse=i.cardinalOrientationFlip=i.cardinalOrientationToString=i.CARDINAL_ORIENTATIONS=i.CardinalOrientation=void 0;const r=e(677),n=e(254);var s;!function(t){t[t.HEADS_NORTH=0]="HEADS_NORTH",t[t.TAILS_NORTH=1]="TAILS_NORTH",t[t.HEADS_EAST=2]="HEADS_EAST",t[t.TAILS_EAST=3]="TAILS_EAST",t[t.HEADS_SOUTH=4]="HEADS_SOUTH",t[t.TAILS_SOUTH=5]="TAILS_SOUTH",t[t.HEADS_WEST=6]="HEADS_WEST",t[t.TAILS_WEST=7]="TAILS_WEST"}(s=i.CardinalOrientation||(i.CardinalOrientation={})),i.CARDINAL_ORIENTATIONS=[s.HEADS_NORTH,s.TAILS_NORTH,s.HEADS_EAST,s.TAILS_EAST,s.HEADS_SOUTH,s.TAILS_SOUTH,s.HEADS_WEST,s.TAILS_WEST];const a=["HN","TN","HE","TE","HS","TS","HW","TW"];i.cardinalOrientationToString=function(t){return a[t]},i.cardinalOrientationFlip=function(t,i){return i===r.Axis.NORTH_SOUTH?9-t&7:13-t&7},i.cardinalOrientationReverse=function(t){return t===s.HEADS_EAST?s.HEADS_WEST:t===s.HEADS_WEST?s.HEADS_EAST:t},i.cardinalOrientationFromFlipAndCardinalDirection=function(t,i){return 2*i+(t!==n.Flip.HEADS?1:0)},i.cardinalOrientationAddCardinalTurn=function(t,i){return t+2*i&7}},974:(t,i)=>{var e;Object.defineProperty(i,"__esModule",{value:!0}),i.cardinalTurnAddCardinalTurn=i.cardinalTurnFromTurn=i.cardinalTurnFromCardinalDirections=i.cardinalTurnReverse=i.cardinalTurnToDegrees=i.cardinalTurnToString=i.CARDINAL_TURNS=i.CardinalTurn=void 0,function(t){t[t.NONE=0]="NONE",t[t.RIGHT=1]="RIGHT",t[t.AROUND=2]="AROUND",t[t.LEFT=3]="LEFT"}(e=i.CardinalTurn||(i.CardinalTurn={})),i.CARDINAL_TURNS=[e.NONE,e.RIGHT,e.AROUND,e.LEFT];const r=["T0","T+90","T180","T-90"];i.cardinalTurnToString=function(t){return r[t]},i.cardinalTurnToDegrees=function(t){return 90*t},i.cardinalTurnReverse=function(t){return 4-t&3},i.cardinalTurnFromCardinalDirections=function(t,i){return i-t&3},i.cardinalTurnFromTurn=function(t){return t>>1},i.cardinalTurnAddCardinalTurn=function(t,i){return t+i&3}},588:(t,i)=>{var e;Object.defineProperty(i,"__esModule",{value:!0}),i.directionAddCardinalTurn=i.directionAddTurn=i.directionFromCardinalDirection=i.directionOpposite=i.directionIsCardinal=i.directionToString=i.DIRECTIONS=i.Direction=void 0,function(t){t[t.NORTH=0]="NORTH",t[t.NORTHEAST=1]="NORTHEAST",t[t.EAST=2]="EAST",t[t.SOUTHEAST=3]="SOUTHEAST",t[t.SOUTH=4]="SOUTH",t[t.SOUTHWEST=5]="SOUTHWEST",t[t.WEST=6]="WEST",t[t.NORTHWEST=7]="NORTHWEST"}(e=i.Direction||(i.Direction={})),i.DIRECTIONS=[e.NORTH,e.NORTHEAST,e.EAST,e.SOUTHEAST,e.SOUTH,e.SOUTHWEST,e.WEST,e.NORTHWEST];const r=["N","NE","E","SE","S","SW","W","NW"];i.directionToString=function(t){return r[t]},i.directionIsCardinal=function(t){return 0==(1&t)},i.directionOpposite=function(t){return t+4&7},i.directionFromCardinalDirection=function(t){return t<<1},i.directionAddTurn=function(t,i){return t+i&7},i.directionAddCardinalTurn=function(t,i){return t+2*i&7}},254:(t,i)=>{var e;Object.defineProperty(i,"__esModule",{value:!0}),i.flipFromCardinalOrientation=i.flipFromBoolean=i.flipOpposite=i.flipToString=i.FLIPS=i.Flip=void 0,function(t){t[t.HEADS=0]="HEADS",t[t.TAILS=1]="TAILS"}(e=i.Flip||(i.Flip={})),i.FLIPS=[e.HEADS,e.TAILS];const r=["H","T"];i.flipToString=function(t){return r[t]},i.flipOpposite=function(t){return 1^t},i.flipFromBoolean=function(t){return t?e.TAILS:e.HEADS},i.flipFromCardinalOrientation=function(t){return 1&t}},778:function(t,i,e){var r=this&&this.__createBinding||(Object.create?function(t,i,e,r){void 0===r&&(r=e),Object.defineProperty(t,r,{enumerable:!0,get:function(){return i[e]}})}:function(t,i,e,r){void 0===r&&(r=e),t[r]=i[e]}),n=this&&this.__exportStar||function(t,i){for(var e in t)"default"===e||Object.prototype.hasOwnProperty.call(i,e)||r(i,t,e)};Object.defineProperty(i,"__esModule",{value:!0}),n(e(588),i),n(e(854),i),n(e(343),i),n(e(974),i),n(e(340),i),n(e(254),i),n(e(852),i),n(e(677),i)},854:(t,i)=>{var e;Object.defineProperty(i,"__esModule",{value:!0}),i.turnAddTurn=i.turnFromDirections=i.turnFromCardinalTurn=i.turnFromCardinalDirections=i.turnReverse=i.turnIsCardinal=i.turnToDegrees=i.turnToString=i.TURNS=i.Turn=void 0,function(t){t[t.NONE=0]="NONE",t[t.R_45=1]="R_45",t[t.R_90=2]="R_90",t[t.R_135=3]="R_135",t[t.T_180=4]="T_180",t[t.L_135=5]="L_135",t[t.L_90=6]="L_90",t[t.L_45=7]="L_45"}(e=i.Turn||(i.Turn={})),i.TURNS=[e.NONE,e.R_45,e.R_90,e.R_135,e.T_180,e.L_135,e.L_90,e.L_45];const r=["T0","T+45","T+90","T+135","T180","T-135","T-90","T-45"];i.turnToString=function(t){return r[t]},i.turnToDegrees=function(t){return 45*t},i.turnIsCardinal=function(t){return 0==(1&t)},i.turnReverse=function(t){return 8-t&7},i.turnFromCardinalDirections=function(t,i){return 2*(i-t)&7},i.turnFromCardinalTurn=function(t){return t<<1},i.turnFromDirections=function(t,i){return i-t&7},i.turnAddTurn=function(t,i){return t+i&7}},913:(t,i,e)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CardinalPath=void 0;const r=e(778),n=e(894),s=e(84),a=e(37),o=new n.Offset;function h(t,i){t.push(i);let e=t.length-1;for(;e>0&&ir.cardinalDirectionToString(t))).join("")}`}equals(t){return this._start.equals(t._start)&&this._segments.length===t._segments.length&&this._segments.every(((i,e)=>i===t._segments[e]))}get length(){return this._segments.length}getIsClosed(){o.copyFrom(this._start);for(const t of this._segments)o.addCardinalDirection(t);return this._start.equals(o)}*offsets(){let{x:t,y:i}=this._start;yield{x:t,y:i};for(const e of this._segments)o.setFromCardinalDirection(e),t+=o.x,i+=o.y,yield{x:t,y:i}}getBounds(){let t=this._start.y,i=t,e=this._start.x,n=e;o.copyFrom(this._start);for(const s of this._segments)switch(o.addCardinalDirection(s),s){case r.CardinalDirection.NORTH:t=Math.min(t,o.y);break;case r.CardinalDirection.EAST:n=Math.max(n,o.x);break;case r.CardinalDirection.SOUTH:i=Math.max(i,o.y);break;case r.CardinalDirection.WEST:e=Math.min(e,o.x);break;default:throw new Error(`bad direction ${s} in cardinal path`)}return new s.Rectangle(e,t,n-e+1,i-t+1)}getArea(){let t=0;o.copyFrom(this._start);for(const i of this._segments)switch(o.addCardinalDirection(i),i){case r.CardinalDirection.NORTH:t-=o.x;break;case r.CardinalDirection.SOUTH:t+=o.x}return Math.abs(t)}rasterize(t){const i=new Array;void 0===t&&(t=this.getBounds()),o.copyFrom(this._start);const{northY:e}=t,n=e+t.height-1;for(let t=e;t{Object.defineProperty(i,"__esModule",{value:!0}),i.MaskRectangle=void 0;const r=e(84),n=e(475);i.MaskRectangle=class{constructor(t,i=!1,e=!1){this._rect=new r.Rectangle,void 0!==t&&this._rect.copyFrom(t),this._mask=new n.Mask(t,i),this._outsideValue=e}toString(){return`${this._rect.northWest}/${this._outsideValue}\n${this._mask}`}equals(t){return this._rect.equals(t._rect)&&this._mask.equals(t._mask)&&this._outsideValue===t._outsideValue}get westX(){return this._rect.westX}get northY(){return this._rect.northY}get width(){return this._rect.width}get height(){return this._rect.height}get(t,i){return this._rect.contains(t,i)?this._mask.get(t-this.westX,i-this.northY):this._outsideValue}getAtIndex(t){return this._mask.getAtIndex(t)}getAtOffset(t){return this.get(t.x,t.y)}copyFrom(t){return this._rect.copyFrom(t._rect),this._mask.copyFrom(t._mask),this._outsideValue=t._outsideValue,this}set(t,i,e){return this._mask.set(t-this.westX,i-this.northY,e),this}setAtOffset(t,i){return this.set(t.x,t.y,i)}setAtIndex(t,i){return this._mask.setAtIndex(t,i),this}index(t,i){return this._mask.index(t-this.westX,i-this.northY)}*locations(){for(const t of this._mask.locations()){const i=t.x+this.westX,e=t.y+this.northY,{value:r}=t;yield{x:i,y:e,value:r}}}*offsetsWithTrue(){for(const t of this._mask.offsetsWithTrue()){const i=t.x+this.westX,e=t.y+this.northY;yield{x:i,y:e}}}}},475:(t,i,e)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Mask=void 0;const r=e(925);i.Mask=class{constructor(t,i=!1){this._size=new r.Size,void 0!==t&&this._size.copyFrom(t),this._bits=new Array(Math.ceil(this._size.area/32)).fill(i?4294967295:0)}toString(){let t="";for(let i=0;ii===t._bits[e]))}get width(){return this._size.width}get height(){return this._size.height}get(t,i){return this.getAtIndex(this.index(t,i))}getAtOffset(t){return this.get(t.x,t.y)}getAtIndex(t){const i=t>>>5,e=1<<(31&t);return 0!=(this._bits[i]&e)}copyFrom(t){return this._size.copyFrom(t._size),this._bits=t._bits.slice(),this}set(t,i,e){return this.setAtIndex(this.index(t,i),e)}setAtOffset(t,i){return this.set(t.x,t.y,i)}setAtIndex(t,i){const e=t>>>5,r=1<<(31&t);return i?this._bits[e]|=r:this._bits[e]&=~r,this}index(t,i){return this._size.index(t,i)}*locations(){let t=0,i=1;for(const{x:e,y:r}of this._size.offsets()){const n=0!=(this._bits[t]&i);yield{x:e,y:r,value:n},i===1<<31?(i=1,t++):i<<=1}}*offsetsWithTrue(){for(const{x:t,y:i,value:e}of this.locations())e&&(yield{x:t,y:i})}}},894:(t,i,e)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Offset=void 0;const r=e(778),n=[0,1,1,1,0,-1,-1,-1],s=[-1,-1,0,1,1,1,0,-1],a=[0,1,0,-1],o=[-1,0,1,0];i.Offset=class{constructor(t,i){void 0===t&&(t=0),void 0===i&&(i=0),this.x=t,this.y=i}toString(){return`(${this.x},${this.y})`}equals(t){return this.x===t.x&&this.y===t.y}set(t,i){return this.x=t,this.y=i,this}copyFrom(t){return this.set(t.x,t.y)}setFromDirection(t){return this.set(n[t],s[t])}setFromCardinalDirection(t){return this.set(a[t],o[t])}add(t,i){return this.x+=t,this.y+=i,this}addSize(t){return this.add(t.width,t.height)}addOffset(t){return this.add(t.x,t.y)}addDirection(t){return this.add(n[t],s[t])}addCardinalDirection(t){return this.add(a[t],o[t])}subtractOffset(t){return this.add(-t.x,-t.y)}multiply(t){return this.x*=t,this.y*=t,this}rotate(t,i){if(i)return this.subtractOffset(i).rotate(t).addOffset(i);{const i=r.cardinalDirectionFromNorthTurn(t),{x:e,y:n}=this,s=a[i],h=o[i],c=-n*s-e*h,l=e*s-n*h;return this.set(c,l)}}distanceChebyshev(t){return Math.max(Math.abs(this.x-t.x),Math.abs(this.y-t.y))}distanceManhattan(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}*nearbyChebyshevOffsets(t,i){if(i>=0)for(let e=-i;e<=i;e++)for(let r=-i;r<=i;r++)yield t.set(this.x+r,this.y+e)}}},37:(t,i,e)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.RasterMask=void 0;const r=e(84);i.RasterMask=class{constructor(t,i){if(this._rect=new r.Rectangle,i.length!==t.height)throw new Error(`bad lines array length ${i.length} for bounds ${t}`);this._rect.copyFrom(t),this._lines=i}toString(){let t="";const{eastX:i}=this._rect;for(let e=0;ei.length===t._lines[e].length&&i.every(((i,r)=>i===t._lines[e][r]))))}get northY(){return this._rect.northY}get southY(){return this._rect.southY}get westX(){return this._rect.westX}get width(){return this._rect.width}get height(){return this._rect.height}get(t,i){if(ithis._rect.southY)return!1;const e=this._lines[i-this.northY];for(let i=0;i=e[i]&&t=this.northY&&t<=this._rect.southY){const i=this._lines[t-this.northY];for(let t=0;t{Object.defineProperty(i,"__esModule",{value:!0}),i.Rectangle=void 0;const r=e(925),n=e(894),s=[0,0,1,1],a=[0,1,1,0];i.Rectangle=class{constructor(t,i,e,s){void 0===t&&(t=0),void 0===i&&(i=0),void 0===e&&(e=0),void 0===s&&(s=0),this.northWest=new n.Offset(t,i),this.size=new r.Size(e,s)}toString(){return`(${this.westX},${this.northY} ${this.width}x${this.height})`}equals(t){return this.westX===t.westX&&this.northY===t.northY&&this.size.equals(t)}get northY(){return this.northWest.y}get southY(){return this.northWest.y+this.size.height-1}get westX(){return this.northWest.x}get eastX(){return this.northWest.x+this.size.width-1}get width(){return this.size.width}get height(){return this.size.height}get empty(){return this.size.empty}get area(){return this.size.area}set(t,i,e,r){return this.northWest.set(t,i),this.size.set(e,r),this}setFromCorners(t,i){const e=Math.min(t.x,i.x),r=Math.max(t.x,i.x),n=Math.min(t.y,i.y),s=Math.max(t.y,i.y);return this.set(e,n,r-e+1,s-n+1)}copyFrom(t){return this.set(t.westX,t.northY,t.width,t.height)}addOffset(t){return this.northWest.addOffset(t),this}scale(t){return this.northWest.multiply(t),this.size.multiply(t),this}rotate(t,i){const e=s[t],r=a[t];return this.northWest.add(e*(this.width-1),r*(this.height-1)).rotate(t,i),this.size.rotate(t),this}extendToInclude(t){const i=t.x-this.westX;i<0?(this.size.width-=i,this.northWest.x=t.x):i>=this.size.width&&(this.size.width=i+1);const e=t.y-this.northWest.y;return e<0?(this.size.height-=e,this.northWest.y=t.y):e>=this.size.height&&(this.size.height=e+1),this}contains(t,i){return this.size.contains(t-this.westX,i-this.northY)}index(t,i){return this.size.index(t-this.westX,i-this.northY)}containsOffset(t){return this.contains(t.x,t.y)}containsRectangle(t){if(0===t.width&&0===t.height)return!1;const i=t.westX-this.westX,e=t.northY-this.northY;return!!this.size.contains(i,e)&&this.size.contains(i+t.width-1,e+t.height-1)}overlapsRectangle(t){return this.northY<=t.northY+t.height-1&&this.southY>=t.northY&&this.westX<=t.westX+t.width-1&&this.eastX>=t.westX&&!this.empty&&0!==t.width&&0!==t.height}*offsets(){const{eastX:t,southY:i}=this;for(let e=this.northY;e<=i;e++)for(let i=this.westX;i<=t;i++)yield{x:i,y:e}}anyOf(t){for(const{x:i,y:e}of this.offsets())if(t(i,e))return!0;return!1}}},925:(t,i,e)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Size=void 0;const r=e(778);i.Size=class{constructor(t,i){if(void 0===t&&(t=0),void 0===i&&(i=0),t<0||i<0)throw new Error(`bad size (${t}x${i})`);this.width=t,this.height=i}toString(){return`(${this.width}x${this.height})`}equals(t){return this.width===t.width&&this.height===t.height}get empty(){return 0===this.width||0===this.height}get area(){return this.width*this.height}set(t,i){if(t<0||i<0)throw new Error(`bad size (${t}x${i})`);return this.width=t,this.height=i,this}copyFrom(t){return this.set(t.width,t.height)}add(t,i){return this.width+=t,this.height+=i,this}multiply(t){return this.width*=t,this.height*=t,this}rotate(t){return r.axisFromNorthSouthTurn(t)===r.Axis.WEST_EAST&&this.set(this.height,this.width),this}contains(t,i){return t>=0&&i>=0&&t{Object.defineProperty(i,"__esModule",{value:!0}),i.TransformRectangle=void 0;const r=e(84),n=e(778),s=e(894),a=e(925),o=new s.Offset,h=new s.Offset,c=new a.Size;i.TransformRectangle=class{constructor(t,i){this._size=new a.Size,this._flip=n.Flip.HEADS,this._rotate=n.CardinalTurn.NONE,this._translate=new s.Offset,this._matrix=[1,0,0,0,1,0],this._targetRect=new r.Rectangle,void 0===t||("number"==typeof t?this._size.set(t,i):this._size.copyFrom(t)),this._update()}toString(){return`[${this._size} -> ${n.flipToString(this._flip)} ${n.cardinalTurnToString(this._rotate)} ${this._translate} -> ${this._targetRect}]`}equals(t){return this._size.equals(t._size)&&this._flip===t._flip&&this._rotate===t._rotate&&this._translate.equals(t._translate)}get flip(){return this._flip}get rotate(){return this._rotate}get northY(){return this._translate.y}get southY(){return this._translate.y+this._targetRect.height-1}get westX(){return this._translate.x}get eastX(){return this._translate.x+this._targetRect.width-1}get width(){return this._targetRect.width}get height(){return this._targetRect.height}_update(){o.setFromCardinalDirection(n.cardinalDirectionFromNorthTurn(this._rotate));const t=this._flip===n.Flip.TAILS?-1:1;switch(this._matrix[0]=-o.y*t,this._matrix[1]=-o.x,this._matrix[2]=this._translate.x,this._matrix[3]=o.x*t,this._matrix[4]=-o.y,this._matrix[5]=this._translate.y,this._rotate){case n.CardinalTurn.NONE:this._flip===n.Flip.TAILS&&(this._matrix[2]+=this._size.width-1);break;case n.CardinalTurn.RIGHT:this._matrix[2]+=this._size.height-1,this._flip===n.Flip.TAILS&&(this._matrix[5]+=this._size.width-1);break;case n.CardinalTurn.AROUND:this._matrix[5]+=this._size.height-1,this._flip===n.Flip.HEADS&&(this._matrix[2]+=this._size.width-1);break;case n.CardinalTurn.LEFT:this._flip===n.Flip.HEADS&&(this._matrix[5]+=this._size.width-1)}return c.copyFrom(this._size).rotate(this._rotate),this._targetRect.set(this._translate.x,this._translate.y,c.width,c.height),this}copyFrom(t){return this._size.copyFrom(t._size),this._flip=t._flip,this._rotate=t._rotate,this._translate.copyFrom(t._translate),t._matrix.forEach(((t,i)=>this._matrix[i]=t)),this._targetRect.copyFrom(t._targetRect),this}reset(){return this._flip=n.Flip.HEADS,this._rotate=n.CardinalTurn.NONE,this._translate.set(0,0),this._update()}invert(){const t=n.cardinalTurnFromCardinalDirections(n.CardinalDirection.NORTH,n.cardinalDirectionFromCardinalOrientation(n.cardinalOrientationReverse(n.cardinalOrientationFromFlipAndCardinalDirection(this._flip,n.cardinalDirectionFromNorthTurn(this._rotate)))));return this._rotate=t,this._size.rotate(t),this._translate.multiply(-1),this._update()}setTransform(t,i,e){return this._flip=t,this._rotate=i,this._translate.copyFrom(e),this._update()}setFlip(t){return this._flip=t,this._update()}setRotate(t){return this._rotate=t,this._update()}setTranslate(t,i){return this._translate.set(t,i),this._update()}setTranslateOffset(t){return this._translate.copyFrom(t),this._update()}applyToCardinalOrientation(t){return this._flip===n.Flip.TAILS&&(t=n.cardinalOrientationFlip(t,n.Axis.NORTH_SOUTH)),n.cardinalOrientationAddCardinalTurn(t,this._rotate)}unapplyFromCardinalOrientation(t){return t=n.cardinalOrientationAddCardinalTurn(t,n.cardinalTurnReverse(this._rotate)),this._flip===n.Flip.TAILS&&(t=n.cardinalOrientationFlip(t,n.Axis.NORTH_SOUTH)),t}applyToCardinalDirection(t){return n.cardinalDirectionFromCardinalOrientation(this.applyToCardinalOrientation(n.cardinalOrientationFromFlipAndCardinalDirection(n.Flip.HEADS,t)))}unapplyFromCardinalDirection(t){return n.cardinalDirectionFromCardinalOrientation(this.unapplyFromCardinalOrientation(n.cardinalOrientationFromFlipAndCardinalDirection(n.Flip.HEADS,t)))}applyTo(t,i,e){const r=i*this._matrix[0]+e*this._matrix[1]+this._matrix[2],n=i*this._matrix[3]+e*this._matrix[4]+this._matrix[5];return t.set(r,n)}unapplyFrom(t,i,e){const r=i-this._matrix[2],n=e-this._matrix[5],s=r*this._matrix[0]+n*this._matrix[3],a=r*this._matrix[1]+n*this._matrix[4];return t.set(s,a)}applyToOffset(t,i){return void 0===i&&(i=t),this.applyTo(t,i.x,i.y)}unapplyFromOffset(t,i){return void 0===i&&(i=t),this.unapplyFrom(t,i.x,i.y)}applyToRectangle(t,i){return void 0!==i&&t.copyFrom(i),o.set(t.westX,t.northY),h.set(t.eastX,t.southY),this.applyToOffset(o),this.applyToOffset(h),t.setFromCorners(o,h)}unapplyFromRectangle(t,i){return void 0!==i&&t.copyFrom(i),o.set(t.westX,t.northY),h.set(t.eastX,t.southY),this.unapplyFromOffset(o),this.unapplyFromOffset(h),t.setFromCorners(o,h)}}},841:function(t,i,e){var r=this&&this.__createBinding||(Object.create?function(t,i,e,r){void 0===r&&(r=e),Object.defineProperty(t,r,{enumerable:!0,get:function(){return i[e]}})}:function(t,i,e,r){void 0===r&&(r=e),t[r]=i[e]}),n=this&&this.__exportStar||function(t,i){for(var e in t)"default"===e||Object.prototype.hasOwnProperty.call(i,e)||r(i,t,e)};Object.defineProperty(i,"__esModule",{value:!0}),n(e(778),i),n(e(551),i)},102:function(t,i,e){var r=this&&this.__createBinding||(Object.create?function(t,i,e,r){void 0===r&&(r=e),Object.defineProperty(t,r,{enumerable:!0,get:function(){return i[e]}})}:function(t,i,e,r){void 0===r&&(r=e),t[r]=i[e]}),n=this&&this.__setModuleDefault||(Object.create?function(t,i){Object.defineProperty(t,"default",{enumerable:!0,value:i})}:function(t,i){t.default=i}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var i={};if(null!=t)for(var e in t)"default"!==e&&Object.prototype.hasOwnProperty.call(t,e)&&r(i,t,e);return n(i,t),i};Object.defineProperty(i,"__esModule",{value:!0}),i.makeBlockFractal=void 0;const a=s(e(841));function o(t,i){return t.length>1&&t[t.length-2].equals(i)}function h(t,i,e){o(t,e)?i.setAtOffset(t.splice(t.length-1,1)[0],!1):(t.push(e),i.setAtOffset(e,!0))}function c(t,i,e,r,n,s,c,l){const u=2*c.x,d=l.y-c.y;for(let f=2*c.y;f!==2*l.y;f+=d){const c=new a.Offset(u,f+d);if(o(r,c))n.setAtOffset(r.splice(r.length-1,1)[0],!1);else{if(s===t.length-2&&n.getAtOffset(c)){const t=r.findIndex((t=>t.equals(c)));for(const i of r.splice(0,t))n.setAtOffset(i,!1);h(r,n,c);break}if(i()t.equals(c)));for(const i of r.splice(0,t))n.setAtOffset(i,!1);h(r,n,c);break}if(i(){var t=r;Object.defineProperty(t,"__esModule",{value:!0}),t.RasterMask=t.CardinalPath=t.Offset=t.CardinalDirectionFlags=t.CardinalDirection=t.makeBlockFractal=void 0;var i=e(102);Object.defineProperty(t,"makeBlockFractal",{enumerable:!0,get:function(){return i.makeBlockFractal}});var n=e(841);Object.defineProperty(t,"CardinalDirection",{enumerable:!0,get:function(){return n.CardinalDirection}}),Object.defineProperty(t,"CardinalDirectionFlags",{enumerable:!0,get:function(){return n.CardinalDirectionFlags}}),Object.defineProperty(t,"Offset",{enumerable:!0,get:function(){return n.Offset}}),Object.defineProperty(t,"CardinalPath",{enumerable:!0,get:function(){return n.CardinalPath}}),Object.defineProperty(t,"RasterMask",{enumerable:!0,get:function(){return n.RasterMask}})})(),BlockFractal=r})(); +//# sourceMappingURL=block-fractal-2.0.2.min.js.map \ No newline at end of file diff --git a/dist/block-fractal-2.0.2.min.js.map b/dist/block-fractal-2.0.2.min.js.map new file mode 100644 index 0000000..15ee8c6 --- /dev/null +++ b/dist/block-fractal-2.0.2.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"block-fractal-2.0.2.min.js","mappings":"uDAGA,IAAIA,EAFJC,OAAOC,eAAeC,EAAS,aAAc,C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7M,gBAC9GlI,OAAOC,eAAeC,EAAS,aAAc,CAAEuG,YAAY,EAAMC,IAAK,WAAc,OAAOqO,EAAiB5J,e","sources":["webpack://BlockFractal/./node_modules/tiled-geometry/lib/compass/axis.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/compass/cardinal-direction-flags.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/compass/cardinal-direction.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/compass/cardinal-orientation.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/compass/cardinal-turn.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/compass/direction.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/compass/flip.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/compass/index.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/compass/turn.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/grid/cardinal-path.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/grid/index.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/grid/mask-rectangle.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/grid/mask.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/grid/offset.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/grid/raster-mask.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/grid/rectangle.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/grid/size.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/grid/transform-rectangle.js","webpack://BlockFractal/./node_modules/tiled-geometry/lib/index.js","webpack://BlockFractal/./src/block-fractal.ts","webpack://BlockFractal/webpack/bootstrap","webpack://BlockFractal/./src/index.ts"],"sourcesContent":["\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.axisAddCardinalTurn = exports.axisFromNorthSouthTurn = exports.axisFromCardinalDirection = exports.axisOrthogonal = exports.axisToString = exports.AXES = exports.Axis = void 0;\r\nvar Axis;\r\n(function (Axis) {\r\n Axis[Axis[\"NORTH_SOUTH\"] = 0] = \"NORTH_SOUTH\";\r\n Axis[Axis[\"WEST_EAST\"] = 1] = \"WEST_EAST\";\r\n})(Axis = exports.Axis || (exports.Axis = {}));\r\nexports.AXES = [\r\n Axis.NORTH_SOUTH,\r\n Axis.WEST_EAST,\r\n];\r\nconst AXES_STR = [\r\n 'N-S',\r\n 'W-E',\r\n];\r\nfunction axisToString(axis) {\r\n return AXES_STR[axis];\r\n}\r\nexports.axisToString = axisToString;\r\nfunction axisOrthogonal(axis) {\r\n return (axis ^ 1);\r\n}\r\nexports.axisOrthogonal = axisOrthogonal;\r\n// conversion\r\nfunction axisFromCardinalDirection(dir) {\r\n return (dir & 1);\r\n}\r\nexports.axisFromCardinalDirection = axisFromCardinalDirection;\r\nfunction axisFromNorthSouthTurn(turn) {\r\n return (turn & 1);\r\n}\r\nexports.axisFromNorthSouthTurn = axisFromNorthSouthTurn;\r\n// math\r\nfunction axisAddCardinalTurn(axis, turn) {\r\n return ((axis + turn) & 1);\r\n}\r\nexports.axisAddCardinalTurn = axisAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cardinalDirectionFlagsFromCardinalDirection = exports.cardinalDirectionFlagsRemoveCardinalDirection = exports.cardinalDirectionFlagsSetCardinalDirection = exports.cardinalDirectionFlagsHasCardinalDirection = exports.cardinalDirectionFlagsToString = exports.CardinalDirectionFlags = void 0;\r\nvar CardinalDirectionFlags;\r\n(function (CardinalDirectionFlags) {\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"NONE\"] = 0] = \"NONE\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"NORTH\"] = 1] = \"NORTH\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"EAST\"] = 2] = \"EAST\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"SOUTH\"] = 4] = \"SOUTH\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"WEST\"] = 8] = \"WEST\";\r\n CardinalDirectionFlags[CardinalDirectionFlags[\"ALL\"] = 15] = \"ALL\";\r\n})(CardinalDirectionFlags = exports.CardinalDirectionFlags || (exports.CardinalDirectionFlags = {}));\r\nfunction cardinalDirectionFlagsToString(flags) {\r\n let ret = '[';\r\n if ((flags & CardinalDirectionFlags.NORTH) !== 0) {\r\n ret += 'N';\r\n }\r\n if ((flags & CardinalDirectionFlags.EAST) !== 0) {\r\n ret += 'E';\r\n }\r\n if ((flags & CardinalDirectionFlags.SOUTH) !== 0) {\r\n ret += 'S';\r\n }\r\n if ((flags & CardinalDirectionFlags.WEST) !== 0) {\r\n ret += 'W';\r\n }\r\n return ret + ']';\r\n}\r\nexports.cardinalDirectionFlagsToString = cardinalDirectionFlagsToString;\r\nfunction cardinalDirectionFlagsHasCardinalDirection(flags, dir) {\r\n return (flags & cardinalDirectionFlagsFromCardinalDirection(dir)) !== 0;\r\n}\r\nexports.cardinalDirectionFlagsHasCardinalDirection = cardinalDirectionFlagsHasCardinalDirection;\r\nfunction cardinalDirectionFlagsSetCardinalDirection(flags, dir) {\r\n return (flags | cardinalDirectionFlagsFromCardinalDirection(dir));\r\n}\r\nexports.cardinalDirectionFlagsSetCardinalDirection = cardinalDirectionFlagsSetCardinalDirection;\r\nfunction cardinalDirectionFlagsRemoveCardinalDirection(flags, dir) {\r\n return (flags & ~cardinalDirectionFlagsFromCardinalDirection(dir));\r\n}\r\nexports.cardinalDirectionFlagsRemoveCardinalDirection = cardinalDirectionFlagsRemoveCardinalDirection;\r\n// conversion\r\nfunction cardinalDirectionFlagsFromCardinalDirection(dir) {\r\n return (1 << dir);\r\n}\r\nexports.cardinalDirectionFlagsFromCardinalDirection = cardinalDirectionFlagsFromCardinalDirection;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cardinalDirectionAddCardinalTurn = exports.cardinalDirectionFromCardinalOrientation = exports.cardinalDirectionFromNorthTurn = exports.cardinalDirectionFromDirection = exports.cardinalDirectionOpposite = exports.cardinalDirectionToString = exports.CARDINAL_DIRECTIONS = exports.CardinalDirection = void 0;\r\nvar CardinalDirection;\r\n(function (CardinalDirection) {\r\n CardinalDirection[CardinalDirection[\"NORTH\"] = 0] = \"NORTH\";\r\n CardinalDirection[CardinalDirection[\"EAST\"] = 1] = \"EAST\";\r\n CardinalDirection[CardinalDirection[\"SOUTH\"] = 2] = \"SOUTH\";\r\n CardinalDirection[CardinalDirection[\"WEST\"] = 3] = \"WEST\";\r\n})(CardinalDirection = exports.CardinalDirection || (exports.CardinalDirection = {}));\r\nexports.CARDINAL_DIRECTIONS = [\r\n CardinalDirection.NORTH,\r\n CardinalDirection.EAST,\r\n CardinalDirection.SOUTH,\r\n CardinalDirection.WEST,\r\n];\r\nconst CARDINAL_DIRECTIONS_STR = [\r\n 'N',\r\n 'E',\r\n 'S',\r\n 'W',\r\n];\r\nfunction cardinalDirectionToString(dir) {\r\n return CARDINAL_DIRECTIONS_STR[dir];\r\n}\r\nexports.cardinalDirectionToString = cardinalDirectionToString;\r\nfunction cardinalDirectionOpposite(dir) {\r\n return ((dir + 2) & 3);\r\n}\r\nexports.cardinalDirectionOpposite = cardinalDirectionOpposite;\r\n// conversion\r\nfunction cardinalDirectionFromDirection(dir) {\r\n return (dir >> 1);\r\n}\r\nexports.cardinalDirectionFromDirection = cardinalDirectionFromDirection;\r\nfunction cardinalDirectionFromNorthTurn(turn) {\r\n return turn;\r\n}\r\nexports.cardinalDirectionFromNorthTurn = cardinalDirectionFromNorthTurn;\r\nfunction cardinalDirectionFromCardinalOrientation(orientation) {\r\n return (orientation >>> 1);\r\n}\r\nexports.cardinalDirectionFromCardinalOrientation = cardinalDirectionFromCardinalOrientation;\r\n// math\r\nfunction cardinalDirectionAddCardinalTurn(dir, turn) {\r\n return ((dir + turn) & 3);\r\n}\r\nexports.cardinalDirectionAddCardinalTurn = cardinalDirectionAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cardinalOrientationAddCardinalTurn = exports.cardinalOrientationFromFlipAndCardinalDirection = exports.cardinalOrientationReverse = exports.cardinalOrientationFlip = exports.cardinalOrientationToString = exports.CARDINAL_ORIENTATIONS = exports.CardinalOrientation = void 0;\r\nconst axis_1 = require(\"./axis\");\r\nconst flip_1 = require(\"./flip\");\r\nvar CardinalOrientation;\r\n(function (CardinalOrientation) {\r\n CardinalOrientation[CardinalOrientation[\"HEADS_NORTH\"] = 0] = \"HEADS_NORTH\";\r\n CardinalOrientation[CardinalOrientation[\"TAILS_NORTH\"] = 1] = \"TAILS_NORTH\";\r\n CardinalOrientation[CardinalOrientation[\"HEADS_EAST\"] = 2] = \"HEADS_EAST\";\r\n CardinalOrientation[CardinalOrientation[\"TAILS_EAST\"] = 3] = \"TAILS_EAST\";\r\n CardinalOrientation[CardinalOrientation[\"HEADS_SOUTH\"] = 4] = \"HEADS_SOUTH\";\r\n CardinalOrientation[CardinalOrientation[\"TAILS_SOUTH\"] = 5] = \"TAILS_SOUTH\";\r\n CardinalOrientation[CardinalOrientation[\"HEADS_WEST\"] = 6] = \"HEADS_WEST\";\r\n CardinalOrientation[CardinalOrientation[\"TAILS_WEST\"] = 7] = \"TAILS_WEST\";\r\n})(CardinalOrientation = exports.CardinalOrientation || (exports.CardinalOrientation = {}));\r\nexports.CARDINAL_ORIENTATIONS = [\r\n CardinalOrientation.HEADS_NORTH,\r\n CardinalOrientation.TAILS_NORTH,\r\n CardinalOrientation.HEADS_EAST,\r\n CardinalOrientation.TAILS_EAST,\r\n CardinalOrientation.HEADS_SOUTH,\r\n CardinalOrientation.TAILS_SOUTH,\r\n CardinalOrientation.HEADS_WEST,\r\n CardinalOrientation.TAILS_WEST,\r\n];\r\nconst CARDINAL_ORIENTATIONS_STR = [\r\n 'HN',\r\n 'TN',\r\n 'HE',\r\n 'TE',\r\n 'HS',\r\n 'TS',\r\n 'HW',\r\n 'TW',\r\n];\r\nfunction cardinalOrientationToString(orientation) {\r\n return CARDINAL_ORIENTATIONS_STR[orientation];\r\n}\r\nexports.cardinalOrientationToString = cardinalOrientationToString;\r\nfunction cardinalOrientationFlip(orientation, axis) {\r\n if (axis === axis_1.Axis.NORTH_SOUTH) {\r\n return ((9 - orientation) & 7);\r\n }\r\n else {\r\n return ((13 - orientation) & 7);\r\n }\r\n}\r\nexports.cardinalOrientationFlip = cardinalOrientationFlip;\r\nfunction cardinalOrientationReverse(orientation) {\r\n if (orientation === CardinalOrientation.HEADS_EAST) {\r\n return CardinalOrientation.HEADS_WEST;\r\n }\r\n else if (orientation === CardinalOrientation.HEADS_WEST) {\r\n return CardinalOrientation.HEADS_EAST;\r\n }\r\n else {\r\n return orientation;\r\n }\r\n}\r\nexports.cardinalOrientationReverse = cardinalOrientationReverse;\r\n// conversion\r\nfunction cardinalOrientationFromFlipAndCardinalDirection(flip, dir) {\r\n return (dir * 2 + (flip !== flip_1.Flip.HEADS ? 1 : 0));\r\n}\r\nexports.cardinalOrientationFromFlipAndCardinalDirection = cardinalOrientationFromFlipAndCardinalDirection;\r\n// math\r\nfunction cardinalOrientationAddCardinalTurn(orientation, turn) {\r\n return ((orientation + turn * 2) & 7);\r\n}\r\nexports.cardinalOrientationAddCardinalTurn = cardinalOrientationAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.cardinalTurnAddCardinalTurn = exports.cardinalTurnFromTurn = exports.cardinalTurnFromCardinalDirections = exports.cardinalTurnReverse = exports.cardinalTurnToDegrees = exports.cardinalTurnToString = exports.CARDINAL_TURNS = exports.CardinalTurn = void 0;\r\nvar CardinalTurn;\r\n(function (CardinalTurn) {\r\n CardinalTurn[CardinalTurn[\"NONE\"] = 0] = \"NONE\";\r\n CardinalTurn[CardinalTurn[\"RIGHT\"] = 1] = \"RIGHT\";\r\n CardinalTurn[CardinalTurn[\"AROUND\"] = 2] = \"AROUND\";\r\n CardinalTurn[CardinalTurn[\"LEFT\"] = 3] = \"LEFT\";\r\n})(CardinalTurn = exports.CardinalTurn || (exports.CardinalTurn = {}));\r\nexports.CARDINAL_TURNS = [\r\n CardinalTurn.NONE,\r\n CardinalTurn.RIGHT,\r\n CardinalTurn.AROUND,\r\n CardinalTurn.LEFT,\r\n];\r\nconst CARDINAL_TURNS_STR = [\r\n 'T0',\r\n 'T+90',\r\n 'T180',\r\n 'T-90',\r\n];\r\nfunction cardinalTurnToString(dir) {\r\n return CARDINAL_TURNS_STR[dir];\r\n}\r\nexports.cardinalTurnToString = cardinalTurnToString;\r\nfunction cardinalTurnToDegrees(turn) {\r\n return turn * 90;\r\n}\r\nexports.cardinalTurnToDegrees = cardinalTurnToDegrees;\r\nfunction cardinalTurnReverse(dir) {\r\n return ((4 - dir) & 3);\r\n}\r\nexports.cardinalTurnReverse = cardinalTurnReverse;\r\n// conversion\r\nfunction cardinalTurnFromCardinalDirections(from, to) {\r\n return ((to - from) & 3);\r\n}\r\nexports.cardinalTurnFromCardinalDirections = cardinalTurnFromCardinalDirections;\r\nfunction cardinalTurnFromTurn(turn) {\r\n return (turn >> 1);\r\n}\r\nexports.cardinalTurnFromTurn = cardinalTurnFromTurn;\r\n// math\r\nfunction cardinalTurnAddCardinalTurn(turn1, turn2) {\r\n return ((turn1 + turn2) & 3);\r\n}\r\nexports.cardinalTurnAddCardinalTurn = cardinalTurnAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.directionAddCardinalTurn = exports.directionAddTurn = exports.directionFromCardinalDirection = exports.directionOpposite = exports.directionIsCardinal = exports.directionToString = exports.DIRECTIONS = exports.Direction = void 0;\r\nvar Direction;\r\n(function (Direction) {\r\n Direction[Direction[\"NORTH\"] = 0] = \"NORTH\";\r\n Direction[Direction[\"NORTHEAST\"] = 1] = \"NORTHEAST\";\r\n Direction[Direction[\"EAST\"] = 2] = \"EAST\";\r\n Direction[Direction[\"SOUTHEAST\"] = 3] = \"SOUTHEAST\";\r\n Direction[Direction[\"SOUTH\"] = 4] = \"SOUTH\";\r\n Direction[Direction[\"SOUTHWEST\"] = 5] = \"SOUTHWEST\";\r\n Direction[Direction[\"WEST\"] = 6] = \"WEST\";\r\n Direction[Direction[\"NORTHWEST\"] = 7] = \"NORTHWEST\";\r\n})(Direction = exports.Direction || (exports.Direction = {}));\r\nexports.DIRECTIONS = [\r\n Direction.NORTH,\r\n Direction.NORTHEAST,\r\n Direction.EAST,\r\n Direction.SOUTHEAST,\r\n Direction.SOUTH,\r\n Direction.SOUTHWEST,\r\n Direction.WEST,\r\n Direction.NORTHWEST,\r\n];\r\nconst DIRECTIONS_STR = [\r\n 'N',\r\n 'NE',\r\n 'E',\r\n 'SE',\r\n 'S',\r\n 'SW',\r\n 'W',\r\n 'NW',\r\n];\r\nfunction directionToString(dir) {\r\n return DIRECTIONS_STR[dir];\r\n}\r\nexports.directionToString = directionToString;\r\nfunction directionIsCardinal(dir) {\r\n return (dir & 1) === 0;\r\n}\r\nexports.directionIsCardinal = directionIsCardinal;\r\nfunction directionOpposite(dir) {\r\n return ((dir + 4) & 7);\r\n}\r\nexports.directionOpposite = directionOpposite;\r\n// conversion\r\nfunction directionFromCardinalDirection(dir) {\r\n return (dir << 1);\r\n}\r\nexports.directionFromCardinalDirection = directionFromCardinalDirection;\r\n// math\r\nfunction directionAddTurn(dir, turn) {\r\n return ((dir + turn) & 7);\r\n}\r\nexports.directionAddTurn = directionAddTurn;\r\nfunction directionAddCardinalTurn(dir, turn) {\r\n return ((dir + turn * 2) & 7);\r\n}\r\nexports.directionAddCardinalTurn = directionAddCardinalTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.flipFromCardinalOrientation = exports.flipFromBoolean = exports.flipOpposite = exports.flipToString = exports.FLIPS = exports.Flip = void 0;\r\nvar Flip;\r\n(function (Flip) {\r\n Flip[Flip[\"HEADS\"] = 0] = \"HEADS\";\r\n Flip[Flip[\"TAILS\"] = 1] = \"TAILS\";\r\n})(Flip = exports.Flip || (exports.Flip = {}));\r\nexports.FLIPS = [\r\n Flip.HEADS,\r\n Flip.TAILS,\r\n];\r\nconst FLIPS_STR = [\r\n 'H',\r\n 'T',\r\n];\r\nfunction flipToString(flip) {\r\n return FLIPS_STR[flip];\r\n}\r\nexports.flipToString = flipToString;\r\nfunction flipOpposite(flip) {\r\n return (flip ^ 1);\r\n}\r\nexports.flipOpposite = flipOpposite;\r\n// conversion\r\nfunction flipFromBoolean(tails) {\r\n return tails ? Flip.TAILS : Flip.HEADS;\r\n}\r\nexports.flipFromBoolean = flipFromBoolean;\r\nfunction flipFromCardinalOrientation(orientation) {\r\n return (orientation & 1);\r\n}\r\nexports.flipFromCardinalOrientation = flipFromCardinalOrientation;\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\n__exportStar(require(\"./direction\"), exports);\r\n__exportStar(require(\"./turn\"), exports);\r\n__exportStar(require(\"./cardinal-direction\"), exports);\r\n__exportStar(require(\"./cardinal-turn\"), exports);\r\n__exportStar(require(\"./cardinal-direction-flags\"), exports);\r\n__exportStar(require(\"./flip\"), exports);\r\n__exportStar(require(\"./cardinal-orientation\"), exports);\r\n__exportStar(require(\"./axis\"), exports);\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.turnAddTurn = exports.turnFromDirections = exports.turnFromCardinalTurn = exports.turnFromCardinalDirections = exports.turnReverse = exports.turnIsCardinal = exports.turnToDegrees = exports.turnToString = exports.TURNS = exports.Turn = void 0;\r\nvar Turn;\r\n(function (Turn) {\r\n Turn[Turn[\"NONE\"] = 0] = \"NONE\";\r\n Turn[Turn[\"R_45\"] = 1] = \"R_45\";\r\n Turn[Turn[\"R_90\"] = 2] = \"R_90\";\r\n Turn[Turn[\"R_135\"] = 3] = \"R_135\";\r\n Turn[Turn[\"T_180\"] = 4] = \"T_180\";\r\n Turn[Turn[\"L_135\"] = 5] = \"L_135\";\r\n Turn[Turn[\"L_90\"] = 6] = \"L_90\";\r\n Turn[Turn[\"L_45\"] = 7] = \"L_45\";\r\n})(Turn = exports.Turn || (exports.Turn = {}));\r\nexports.TURNS = [\r\n Turn.NONE,\r\n Turn.R_45,\r\n Turn.R_90,\r\n Turn.R_135,\r\n Turn.T_180,\r\n Turn.L_135,\r\n Turn.L_90,\r\n Turn.L_45,\r\n];\r\nconst TURNS_STR = [\r\n 'T0',\r\n 'T+45',\r\n 'T+90',\r\n 'T+135',\r\n 'T180',\r\n 'T-135',\r\n 'T-90',\r\n 'T-45',\r\n];\r\nfunction turnToString(turn) {\r\n return TURNS_STR[turn];\r\n}\r\nexports.turnToString = turnToString;\r\nfunction turnToDegrees(turn) {\r\n return turn * 45;\r\n}\r\nexports.turnToDegrees = turnToDegrees;\r\nfunction turnIsCardinal(turn) {\r\n return (turn & 1) === 0;\r\n}\r\nexports.turnIsCardinal = turnIsCardinal;\r\nfunction turnReverse(turn) {\r\n return ((8 - turn) & 7);\r\n}\r\nexports.turnReverse = turnReverse;\r\n// conversion\r\nfunction turnFromCardinalDirections(from, to) {\r\n return (((to - from) * 2) & 7);\r\n}\r\nexports.turnFromCardinalDirections = turnFromCardinalDirections;\r\nfunction turnFromCardinalTurn(turn) {\r\n return (turn << 1);\r\n}\r\nexports.turnFromCardinalTurn = turnFromCardinalTurn;\r\nfunction turnFromDirections(from, to) {\r\n return ((to - from) & 7);\r\n}\r\nexports.turnFromDirections = turnFromDirections;\r\n// math\r\nfunction turnAddTurn(turn1, turn2) {\r\n return ((turn1 + turn2) & 7);\r\n}\r\nexports.turnAddTurn = turnAddTurn;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.CardinalPath = void 0;\r\nconst compass_1 = require(\"../compass\");\r\nconst offset_1 = require(\"./offset\");\r\nconst rectangle_1 = require(\"./rectangle\");\r\nconst raster_mask_1 = require(\"./raster-mask\");\r\nconst LOCAL_OFF = new offset_1.Offset();\r\nfunction sortedInsert(array, value) {\r\n array.push(value);\r\n let i = array.length - 1;\r\n while (i > 0 && value < array[i - 1]) {\r\n array[i] = array[i - 1];\r\n i--;\r\n }\r\n array[i] = value;\r\n}\r\nclass CardinalPath {\r\n constructor(start, segments) {\r\n this._start = new offset_1.Offset();\r\n this._start.copyFrom(start);\r\n this._segments = segments;\r\n }\r\n // accessors\r\n toString() {\r\n return `${this._start.toString()}:`\r\n + `${this._segments.map((segment) => compass_1.cardinalDirectionToString(segment)).join('')}`;\r\n }\r\n equals(other) {\r\n return this._start.equals(other._start)\r\n && this._segments.length === other._segments.length\r\n && this._segments.every((v, i) => v === other._segments[i]);\r\n }\r\n get length() {\r\n return this._segments.length;\r\n }\r\n // utilities\r\n getIsClosed() {\r\n LOCAL_OFF.copyFrom(this._start);\r\n for (const segment of this._segments) {\r\n LOCAL_OFF.addCardinalDirection(segment);\r\n }\r\n return this._start.equals(LOCAL_OFF);\r\n }\r\n *offsets() {\r\n let { x, y } = this._start;\r\n yield { x, y };\r\n for (const segment of this._segments) {\r\n LOCAL_OFF.setFromCardinalDirection(segment);\r\n x += LOCAL_OFF.x;\r\n y += LOCAL_OFF.y;\r\n yield { x, y };\r\n }\r\n }\r\n getBounds() {\r\n let northY = this._start.y;\r\n let southY = northY;\r\n let westX = this._start.x;\r\n let eastX = westX;\r\n LOCAL_OFF.copyFrom(this._start);\r\n for (const segment of this._segments) {\r\n LOCAL_OFF.addCardinalDirection(segment);\r\n switch (segment) {\r\n case compass_1.CardinalDirection.NORTH:\r\n northY = Math.min(northY, LOCAL_OFF.y);\r\n break;\r\n case compass_1.CardinalDirection.EAST:\r\n eastX = Math.max(eastX, LOCAL_OFF.x);\r\n break;\r\n case compass_1.CardinalDirection.SOUTH:\r\n southY = Math.max(southY, LOCAL_OFF.y);\r\n break;\r\n case compass_1.CardinalDirection.WEST:\r\n westX = Math.min(westX, LOCAL_OFF.x);\r\n break;\r\n // istanbul ignore next\r\n default:\r\n throw new Error(`bad direction ${segment} in cardinal path`);\r\n }\r\n }\r\n return new rectangle_1.Rectangle(westX, northY, eastX - westX + 1, southY - northY + 1);\r\n }\r\n getArea() {\r\n let total = 0;\r\n LOCAL_OFF.copyFrom(this._start);\r\n for (const segment of this._segments) {\r\n LOCAL_OFF.addCardinalDirection(segment);\r\n switch (segment) {\r\n case compass_1.CardinalDirection.NORTH:\r\n total -= LOCAL_OFF.x;\r\n break;\r\n case compass_1.CardinalDirection.SOUTH:\r\n total += LOCAL_OFF.x;\r\n break;\r\n }\r\n }\r\n return Math.abs(total);\r\n }\r\n rasterize(bounds) {\r\n const lines = new Array();\r\n if (typeof bounds === 'undefined') {\r\n bounds = this.getBounds();\r\n }\r\n // assert(this.getIsClosed())\r\n LOCAL_OFF.copyFrom(this._start);\r\n const { northY } = bounds;\r\n const southY = northY + bounds.height - 1;\r\n for (let y = northY; y < southY; y++) {\r\n lines.push([]);\r\n }\r\n LOCAL_OFF.copyFrom(this._start);\r\n // assert(LOCAL_OFF.y >= northY && LOCAL_OFF.y <= southY)\r\n for (const segment of this._segments) {\r\n if (segment === compass_1.CardinalDirection.SOUTH) {\r\n sortedInsert(lines[LOCAL_OFF.y - northY], LOCAL_OFF.x);\r\n }\r\n LOCAL_OFF.addCardinalDirection(segment);\r\n // assert(LOCAL_OFF.y >= northY && LOCAL_OFF.y <= southY)\r\n if (segment === compass_1.CardinalDirection.NORTH) {\r\n sortedInsert(lines[LOCAL_OFF.y - northY], LOCAL_OFF.x);\r\n }\r\n }\r\n return new raster_mask_1.RasterMask({\r\n westX: bounds.westX,\r\n northY: bounds.northY,\r\n width: bounds.width - 1,\r\n height: bounds.height - 1,\r\n }, lines);\r\n }\r\n}\r\nexports.CardinalPath = CardinalPath;\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\n__exportStar(require(\"./offset\"), exports);\r\n__exportStar(require(\"./size\"), exports);\r\n__exportStar(require(\"./rectangle\"), exports);\r\n__exportStar(require(\"./mask\"), exports);\r\n__exportStar(require(\"./mask-rectangle\"), exports);\r\n__exportStar(require(\"./raster-mask\"), exports);\r\n__exportStar(require(\"./cardinal-path\"), exports);\r\n__exportStar(require(\"./transform-rectangle\"), exports);\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.MaskRectangle = void 0;\r\nconst rectangle_1 = require(\"./rectangle\");\r\nconst mask_1 = require(\"./mask\");\r\nclass MaskRectangle {\r\n constructor(rect, initialValue = false, outsideValue = false) {\r\n this._rect = new rectangle_1.Rectangle();\r\n if (typeof rect !== 'undefined') {\r\n this._rect.copyFrom(rect);\r\n }\r\n this._mask = new mask_1.Mask(rect, initialValue);\r\n this._outsideValue = outsideValue;\r\n }\r\n // accessors\r\n toString() {\r\n return `${this._rect.northWest}/${this._outsideValue}\\n${this._mask}`;\r\n }\r\n equals(other) {\r\n return this._rect.equals(other._rect)\r\n && this._mask.equals(other._mask)\r\n && this._outsideValue === other._outsideValue;\r\n }\r\n get westX() {\r\n return this._rect.westX;\r\n }\r\n get northY() {\r\n return this._rect.northY;\r\n }\r\n get width() {\r\n return this._rect.width;\r\n }\r\n get height() {\r\n return this._rect.height;\r\n }\r\n get(x, y) {\r\n if (!this._rect.contains(x, y)) {\r\n return this._outsideValue;\r\n }\r\n return this._mask.get(x - this.westX, y - this.northY);\r\n }\r\n getAtIndex(index) {\r\n return this._mask.getAtIndex(index);\r\n }\r\n getAtOffset(off) {\r\n return this.get(off.x, off.y);\r\n }\r\n // mutators\r\n copyFrom(other) {\r\n this._rect.copyFrom(other._rect);\r\n this._mask.copyFrom(other._mask);\r\n this._outsideValue = other._outsideValue;\r\n return this;\r\n }\r\n set(x, y, value) {\r\n this._mask.set(x - this.westX, y - this.northY, value);\r\n return this;\r\n }\r\n setAtOffset(off, value) {\r\n return this.set(off.x, off.y, value);\r\n }\r\n setAtIndex(index, value) {\r\n this._mask.setAtIndex(index, value);\r\n return this;\r\n }\r\n // utilities\r\n index(x, y) {\r\n return this._mask.index(x - this.westX, y - this.northY);\r\n }\r\n *locations() {\r\n for (const loc of this._mask.locations()) {\r\n const x = loc.x + this.westX;\r\n const y = loc.y + this.northY;\r\n const { value } = loc;\r\n yield { x, y, value };\r\n }\r\n }\r\n *offsetsWithTrue() {\r\n for (const off of this._mask.offsetsWithTrue()) {\r\n const x = off.x + this.westX;\r\n const y = off.y + this.northY;\r\n yield { x, y };\r\n }\r\n }\r\n}\r\nexports.MaskRectangle = MaskRectangle;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.Mask = void 0;\r\nconst size_1 = require(\"./size\");\r\nclass Mask {\r\n constructor(size, initialValue = false) {\r\n this._size = new size_1.Size();\r\n if (typeof size !== 'undefined') {\r\n this._size.copyFrom(size);\r\n }\r\n this._bits = new Array(Math.ceil(this._size.area / 32)).fill(initialValue ? 0xffffffff : 0);\r\n }\r\n // accessors\r\n toString() {\r\n let ret = '';\r\n for (let y = 0; y < this.height; y++) {\r\n for (let x = 0; x < this.width; x++) {\r\n ret += this.get(x, y) ? '☑' : '☐';\r\n }\r\n ret += '\\n';\r\n }\r\n return ret;\r\n }\r\n equals(other) {\r\n return this._size.equals(other._size)\r\n && this._bits.length === other._bits.length\r\n && this._bits.every((v, i) => v === other._bits[i]);\r\n }\r\n get width() {\r\n return this._size.width;\r\n }\r\n get height() {\r\n return this._size.height;\r\n }\r\n get(x, y) {\r\n return this.getAtIndex(this.index(x, y));\r\n }\r\n getAtOffset(off) {\r\n return this.get(off.x, off.y);\r\n }\r\n getAtIndex(index) {\r\n // assert(index >= 0 && index < this._size.area)\r\n const arrayIndex = index >>> 5;\r\n const bitMask = 1 << (index & 31);\r\n return (this._bits[arrayIndex] & bitMask) !== 0;\r\n }\r\n // mutators\r\n copyFrom(other) {\r\n this._size.copyFrom(other._size);\r\n this._bits = other._bits.slice();\r\n return this;\r\n }\r\n set(x, y, value) {\r\n return this.setAtIndex(this.index(x, y), value);\r\n }\r\n setAtOffset(off, value) {\r\n return this.set(off.x, off.y, value);\r\n }\r\n setAtIndex(index, value) {\r\n // assert(index >= 0 && index < this._size.area)\r\n const arrayIndex = index >>> 5;\r\n const bitMask = 1 << (index & 31);\r\n if (value) {\r\n this._bits[arrayIndex] |= bitMask;\r\n }\r\n else {\r\n this._bits[arrayIndex] &= ~bitMask;\r\n }\r\n return this;\r\n }\r\n // utilities\r\n index(x, y) {\r\n return this._size.index(x, y);\r\n }\r\n *locations() {\r\n let arrayIndex = 0;\r\n let bitMask = 1;\r\n for (const { x, y } of this._size.offsets()) {\r\n const value = (this._bits[arrayIndex] & bitMask) !== 0;\r\n yield { x, y, value };\r\n if (bitMask === (1 << 31)) {\r\n bitMask = 1;\r\n arrayIndex++;\r\n }\r\n else {\r\n bitMask <<= 1;\r\n }\r\n }\r\n }\r\n *offsetsWithTrue() {\r\n for (const { x, y, value } of this.locations()) {\r\n if (value) {\r\n yield { x, y };\r\n }\r\n }\r\n }\r\n}\r\nexports.Mask = Mask;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.Offset = void 0;\r\nconst compass_1 = require(\"../compass\");\r\nconst X_FROM_DIRECTION = [0, 1, 1, 1, 0, -1, -1, -1];\r\nconst Y_FROM_DIRECTION = [-1, -1, 0, 1, 1, 1, 0, -1];\r\nconst X_FROM_CARDINAL_DIRECTION = [0, 1, 0, -1];\r\nconst Y_FROM_CARDINAL_DIRECTION = [-1, 0, 1, 0];\r\nclass Offset {\r\n constructor(x, y) {\r\n if (typeof x === 'undefined') {\r\n x = 0;\r\n }\r\n if (typeof y === 'undefined') {\r\n y = 0;\r\n }\r\n this.x = x;\r\n this.y = y;\r\n }\r\n // accessors\r\n toString() {\r\n return `(${this.x},${this.y})`;\r\n }\r\n equals(other) {\r\n return this.x === other.x && this.y === other.y;\r\n }\r\n // mutators\r\n set(x, y) {\r\n this.x = x;\r\n this.y = y;\r\n return this;\r\n }\r\n copyFrom(other) {\r\n return this.set(other.x, other.y);\r\n }\r\n setFromDirection(dir) {\r\n return this.set(X_FROM_DIRECTION[dir], Y_FROM_DIRECTION[dir]);\r\n }\r\n setFromCardinalDirection(dir) {\r\n return this.set(X_FROM_CARDINAL_DIRECTION[dir], Y_FROM_CARDINAL_DIRECTION[dir]);\r\n }\r\n add(x, y) {\r\n this.x += x;\r\n this.y += y;\r\n return this;\r\n }\r\n addSize(size) {\r\n return this.add(size.width, size.height);\r\n }\r\n addOffset(off) {\r\n return this.add(off.x, off.y);\r\n }\r\n addDirection(dir) {\r\n return this.add(X_FROM_DIRECTION[dir], Y_FROM_DIRECTION[dir]);\r\n }\r\n addCardinalDirection(dir) {\r\n return this.add(X_FROM_CARDINAL_DIRECTION[dir], Y_FROM_CARDINAL_DIRECTION[dir]);\r\n }\r\n subtractOffset(off) {\r\n return this.add(-off.x, -off.y);\r\n }\r\n multiply(factor) {\r\n this.x *= factor;\r\n this.y *= factor;\r\n return this;\r\n }\r\n rotate(turn, anchor) {\r\n if (anchor) {\r\n return this.subtractOffset(anchor).rotate(turn).addOffset(anchor);\r\n }\r\n else {\r\n const dir = compass_1.cardinalDirectionFromNorthTurn(turn);\r\n const { x, y } = this;\r\n const dirx = X_FROM_CARDINAL_DIRECTION[dir];\r\n const diry = Y_FROM_CARDINAL_DIRECTION[dir];\r\n const nx = -y * dirx - x * diry;\r\n const ny = x * dirx - y * diry;\r\n return this.set(nx, ny);\r\n }\r\n }\r\n // utilities\r\n // chebyshev: can move in any direction (diagonals are ok)\r\n distanceChebyshev(other) {\r\n return Math.max(Math.abs(this.x - other.x), Math.abs(this.y - other.y));\r\n }\r\n // manhattan: can move only in cardinal directions (no diagonals)\r\n distanceManhattan(other) {\r\n return Math.abs(this.x - other.x) + Math.abs(this.y - other.y);\r\n }\r\n // chebyshev: can move in any direction (diagonals are ok)\r\n *nearbyChebyshevOffsets(cursor, radius) {\r\n if (radius >= 0) {\r\n for (let dy = -radius; dy <= radius; dy++) {\r\n for (let dx = -radius; dx <= radius; dx++) {\r\n yield cursor.set(this.x + dx, this.y + dy);\r\n }\r\n }\r\n }\r\n }\r\n}\r\nexports.Offset = Offset;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.RasterMask = void 0;\r\nconst rectangle_1 = require(\"./rectangle\");\r\nclass RasterMask {\r\n constructor(bounds, lines) {\r\n this._rect = new rectangle_1.Rectangle();\r\n if (lines.length !== bounds.height) {\r\n throw new Error(`bad lines array length ${lines.length} for bounds ${bounds}`);\r\n }\r\n this._rect.copyFrom(bounds);\r\n this._lines = lines;\r\n }\r\n // accessors\r\n toString() {\r\n let shape = '';\r\n const { eastX } = this._rect;\r\n for (let y = 0; y < this.height; y++) {\r\n const line = this._lines[y];\r\n let x = this.westX;\r\n for (let i = 0; i < line.length; i += 2) {\r\n const start = line[i];\r\n const end = line[i + 1];\r\n while (x < start) {\r\n shape += '∙';\r\n x++;\r\n }\r\n while (x < end) {\r\n shape += '█';\r\n x++;\r\n }\r\n }\r\n while (x <= eastX) {\r\n shape += '∙';\r\n x++;\r\n }\r\n shape += '\\n';\r\n }\r\n return `(${this._rect.westX},${this._rect.northY})\\n${shape}`;\r\n }\r\n equals(other) {\r\n return this._rect.equals(other._rect)\r\n && this._lines.length === other._lines.length\r\n && this._lines.every((v, i) => (v.length === other._lines[i].length\r\n && v.every((w, j) => w === other._lines[i][j])));\r\n }\r\n get northY() {\r\n return this._rect.northY;\r\n }\r\n get southY() {\r\n return this._rect.southY;\r\n }\r\n get westX() {\r\n return this._rect.westX;\r\n }\r\n get width() {\r\n return this._rect.width;\r\n }\r\n get height() {\r\n return this._rect.height;\r\n }\r\n get(x, y) {\r\n if (y < this.northY || y > this._rect.southY) {\r\n return false;\r\n }\r\n const line = this._lines[y - this.northY];\r\n for (let i = 0; i < line.length; i += 2) {\r\n if (x >= line[i] && x < line[i + 1]) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n getAtOffset(off) {\r\n return this.get(off.x, off.y);\r\n }\r\n // utilities\r\n *bandsAt(y) {\r\n if (y >= this.northY && y <= this._rect.southY) {\r\n const line = this._lines[y - this.northY];\r\n for (let i = 0; i < line.length; i += 2) {\r\n yield {\r\n westX: line[i],\r\n eastX: line[i + 1] - 1,\r\n };\r\n }\r\n }\r\n }\r\n}\r\nexports.RasterMask = RasterMask;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.Rectangle = void 0;\r\nconst size_1 = require(\"./size\");\r\nconst offset_1 = require(\"./offset\");\r\nconst ROTATE_CORNER_X = [0, 0, 1, 1];\r\nconst ROTATE_CORNER_Y = [0, 1, 1, 0];\r\nclass Rectangle {\r\n constructor(westX, northY, width, height) {\r\n if (typeof westX === 'undefined') {\r\n westX = 0;\r\n }\r\n if (typeof northY === 'undefined') {\r\n northY = 0;\r\n }\r\n if (typeof width === 'undefined') {\r\n width = 0;\r\n }\r\n if (typeof height === 'undefined') {\r\n height = 0;\r\n }\r\n this.northWest = new offset_1.Offset(westX, northY);\r\n this.size = new size_1.Size(width, height);\r\n }\r\n // accessors\r\n toString() {\r\n return `(${this.westX},${this.northY} ${this.width}x${this.height})`;\r\n }\r\n equals(other) {\r\n return this.westX === other.westX && this.northY === other.northY && this.size.equals(other);\r\n }\r\n get northY() {\r\n return this.northWest.y;\r\n }\r\n get southY() {\r\n return this.northWest.y + this.size.height - 1;\r\n }\r\n get westX() {\r\n return this.northWest.x;\r\n }\r\n get eastX() {\r\n return this.northWest.x + this.size.width - 1;\r\n }\r\n get width() {\r\n return this.size.width;\r\n }\r\n get height() {\r\n return this.size.height;\r\n }\r\n get empty() {\r\n return this.size.empty;\r\n }\r\n get area() {\r\n return this.size.area;\r\n }\r\n // mutators\r\n set(westX, northY, width, height) {\r\n this.northWest.set(westX, northY);\r\n this.size.set(width, height);\r\n return this;\r\n }\r\n setFromCorners(off1, off2) {\r\n const westX = Math.min(off1.x, off2.x);\r\n const eastX = Math.max(off1.x, off2.x);\r\n const northY = Math.min(off1.y, off2.y);\r\n const southY = Math.max(off1.y, off2.y);\r\n return this.set(westX, northY, eastX - westX + 1, southY - northY + 1);\r\n }\r\n copyFrom(other) {\r\n return this.set(other.westX, other.northY, other.width, other.height);\r\n }\r\n addOffset(off) {\r\n this.northWest.addOffset(off);\r\n return this;\r\n }\r\n scale(factor) {\r\n this.northWest.multiply(factor);\r\n this.size.multiply(factor);\r\n return this;\r\n }\r\n rotate(turn, anchor) {\r\n const cx = ROTATE_CORNER_X[turn];\r\n const cy = ROTATE_CORNER_Y[turn];\r\n this.northWest.add(cx * (this.width - 1), cy * (this.height - 1)).rotate(turn, anchor);\r\n this.size.rotate(turn);\r\n return this;\r\n }\r\n extendToInclude(off) {\r\n const dx = off.x - this.westX;\r\n if (dx < 0) {\r\n this.size.width -= dx;\r\n this.northWest.x = off.x;\r\n }\r\n else if (dx >= this.size.width) {\r\n this.size.width = dx + 1;\r\n }\r\n const dy = off.y - this.northWest.y;\r\n if (dy < 0) {\r\n this.size.height -= dy;\r\n this.northWest.y = off.y;\r\n }\r\n else if (dy >= this.size.height) {\r\n this.size.height = dy + 1;\r\n }\r\n return this;\r\n }\r\n // utilities\r\n contains(x, y) {\r\n return this.size.contains(x - this.westX, y - this.northY);\r\n }\r\n index(x, y) {\r\n return this.size.index(x - this.westX, y - this.northY);\r\n }\r\n containsOffset(off) {\r\n return this.contains(off.x, off.y);\r\n }\r\n containsRectangle(other) {\r\n if (other.width === 0 && other.height === 0) {\r\n return false;\r\n }\r\n const x = other.westX - this.westX;\r\n const y = other.northY - this.northY;\r\n if (!this.size.contains(x, y)) {\r\n return false;\r\n }\r\n return this.size.contains(x + other.width - 1, y + other.height - 1);\r\n }\r\n overlapsRectangle(other) {\r\n return this.northY <= other.northY + other.height - 1\r\n && this.southY >= other.northY\r\n && this.westX <= other.westX + other.width - 1\r\n && this.eastX >= other.westX\r\n && !this.empty\r\n && other.width !== 0 && other.height !== 0;\r\n }\r\n *offsets() {\r\n const { eastX, southY } = this;\r\n for (let y = this.northY; y <= southY; y++) {\r\n for (let x = this.westX; x <= eastX; x++) {\r\n yield { x, y };\r\n }\r\n }\r\n }\r\n anyOf(predicate) {\r\n for (const { x, y } of this.offsets()) {\r\n if (predicate(x, y)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n}\r\nexports.Rectangle = Rectangle;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.Size = void 0;\r\nconst compass_1 = require(\"../compass\");\r\nclass Size {\r\n constructor(width, height) {\r\n if (typeof width === 'undefined') {\r\n width = 0;\r\n }\r\n if (typeof height === 'undefined') {\r\n height = 0;\r\n }\r\n if (width < 0 || height < 0) {\r\n throw new Error(`bad size (${width}x${height})`);\r\n }\r\n this.width = width;\r\n this.height = height;\r\n }\r\n // accessors\r\n toString() {\r\n return `(${this.width}x${this.height})`;\r\n }\r\n equals(other) {\r\n return this.width === other.width && this.height === other.height;\r\n }\r\n get empty() {\r\n return this.width === 0 || this.height === 0;\r\n }\r\n get area() {\r\n return this.width * this.height;\r\n }\r\n // mutators\r\n set(width, height) {\r\n if (width < 0 || height < 0) {\r\n throw new Error(`bad size (${width}x${height})`);\r\n }\r\n this.width = width;\r\n this.height = height;\r\n return this;\r\n }\r\n copyFrom(other) {\r\n return this.set(other.width, other.height);\r\n }\r\n add(width, height) {\r\n this.width += width;\r\n this.height += height;\r\n return this;\r\n }\r\n multiply(factor) {\r\n this.width *= factor;\r\n this.height *= factor;\r\n return this;\r\n }\r\n rotate(turn) {\r\n if (compass_1.axisFromNorthSouthTurn(turn) === compass_1.Axis.WEST_EAST) {\r\n this.set(this.height, this.width);\r\n }\r\n return this;\r\n }\r\n // utilities\r\n contains(x, y) {\r\n return x >= 0 && y >= 0 && x < this.width && y < this.height;\r\n }\r\n containsOffset(off) {\r\n return this.contains(off.x, off.y);\r\n }\r\n index(x, y) {\r\n return y * this.width + x;\r\n }\r\n *offsets() {\r\n for (let y = 0; y < this.height; y++) {\r\n for (let x = 0; x < this.width; x++) {\r\n yield { x, y };\r\n }\r\n }\r\n }\r\n anyOf(predicate) {\r\n for (const { x, y } of this.offsets()) {\r\n if (predicate(x, y)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n}\r\nexports.Size = Size;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.TransformRectangle = void 0;\r\nconst rectangle_1 = require(\"./rectangle\");\r\nconst compass_1 = require(\"../compass\");\r\nconst offset_1 = require(\"./offset\");\r\nconst size_1 = require(\"./size\");\r\nconst LOCAL_OFF = new offset_1.Offset();\r\nconst LOCAL_OFF2 = new offset_1.Offset();\r\nconst LOCAL_SIZE = new size_1.Size();\r\nclass TransformRectangle {\r\n constructor(width, height) {\r\n this._size = new size_1.Size();\r\n this._flip = compass_1.Flip.HEADS;\r\n this._rotate = compass_1.CardinalTurn.NONE;\r\n this._translate = new offset_1.Offset();\r\n this._matrix = [1, 0, 0, 0, 1, 0];\r\n this._targetRect = new rectangle_1.Rectangle();\r\n if (typeof width === 'undefined') {\r\n // nothing\r\n }\r\n else if (typeof width === 'number') {\r\n this._size.set(width, height);\r\n }\r\n else {\r\n this._size.copyFrom(width);\r\n }\r\n this._update();\r\n }\r\n // accessors\r\n toString() {\r\n return `[${this._size}`\r\n + ` -> ${compass_1.flipToString(this._flip)} ${compass_1.cardinalTurnToString(this._rotate)} ${this._translate}`\r\n + ` -> ${this._targetRect}]`;\r\n }\r\n equals(other) {\r\n return this._size.equals(other._size)\r\n && this._flip === other._flip\r\n && this._rotate === other._rotate\r\n && this._translate.equals(other._translate);\r\n }\r\n get flip() {\r\n return this._flip;\r\n }\r\n get rotate() {\r\n return this._rotate;\r\n }\r\n get northY() {\r\n return this._translate.y;\r\n }\r\n get southY() {\r\n return this._translate.y + this._targetRect.height - 1;\r\n }\r\n get westX() {\r\n return this._translate.x;\r\n }\r\n get eastX() {\r\n return this._translate.x + this._targetRect.width - 1;\r\n }\r\n get width() {\r\n return this._targetRect.width;\r\n }\r\n get height() {\r\n return this._targetRect.height;\r\n }\r\n // internal\r\n // 0\r\n // 0 -1\r\n // +90\r\n // 1 0\r\n // 180\r\n // 0 1\r\n // -90\r\n // -1 0\r\n //\r\n // heads:\r\n // 0\r\n // 1 0 x\r\n // 0 1 y\r\n // +90\r\n // 0 -1 x + h - 1\r\n // 1 0 y\r\n // 180\r\n // -1 0 x + w - 1\r\n // 0 -1 y + h - 1\r\n // -90\r\n // 0 1 x\r\n // -1 0 y + w - 1\r\n //\r\n // tails:\r\n // 0\r\n // -1 0 x + w - 1\r\n // 0 1 y\r\n // +90\r\n // 0 -1 x + h - 1\r\n // -1 0 y + w - 1\r\n // 180\r\n // 1 0 x\r\n // 0 -1 y + h - 1\r\n // -90\r\n // 0 1 x\r\n // 1 0 y\r\n _update() {\r\n LOCAL_OFF.setFromCardinalDirection(compass_1.cardinalDirectionFromNorthTurn(this._rotate));\r\n const flipSign = this._flip === compass_1.Flip.TAILS ? -1 : 1;\r\n this._matrix[0] = -LOCAL_OFF.y * flipSign;\r\n this._matrix[1] = -LOCAL_OFF.x;\r\n this._matrix[2] = this._translate.x;\r\n this._matrix[3] = LOCAL_OFF.x * flipSign;\r\n this._matrix[4] = -LOCAL_OFF.y;\r\n this._matrix[5] = this._translate.y;\r\n switch (this._rotate) {\r\n case compass_1.CardinalTurn.NONE:\r\n if (this._flip === compass_1.Flip.TAILS) {\r\n this._matrix[2] += this._size.width - 1;\r\n }\r\n break;\r\n case compass_1.CardinalTurn.RIGHT:\r\n this._matrix[2] += this._size.height - 1;\r\n if (this._flip === compass_1.Flip.TAILS) {\r\n this._matrix[5] += this._size.width - 1;\r\n }\r\n break;\r\n case compass_1.CardinalTurn.AROUND:\r\n this._matrix[5] += this._size.height - 1;\r\n if (this._flip === compass_1.Flip.HEADS) {\r\n this._matrix[2] += this._size.width - 1;\r\n }\r\n break;\r\n case compass_1.CardinalTurn.LEFT:\r\n if (this._flip === compass_1.Flip.HEADS) {\r\n this._matrix[5] += this._size.width - 1;\r\n }\r\n break;\r\n }\r\n LOCAL_SIZE.copyFrom(this._size).rotate(this._rotate);\r\n this._targetRect.set(this._translate.x, this._translate.y, LOCAL_SIZE.width, LOCAL_SIZE.height);\r\n return this;\r\n }\r\n // mutators\r\n copyFrom(other) {\r\n this._size.copyFrom(other._size);\r\n this._flip = other._flip;\r\n this._rotate = other._rotate;\r\n this._translate.copyFrom(other._translate);\r\n other._matrix.forEach((v, i) => this._matrix[i] = v);\r\n this._targetRect.copyFrom(other._targetRect);\r\n return this;\r\n }\r\n reset() {\r\n this._flip = compass_1.Flip.HEADS;\r\n this._rotate = compass_1.CardinalTurn.NONE;\r\n this._translate.set(0, 0);\r\n return this._update();\r\n }\r\n invert() {\r\n const nrotate = compass_1.cardinalTurnFromCardinalDirections(compass_1.CardinalDirection.NORTH, compass_1.cardinalDirectionFromCardinalOrientation(compass_1.cardinalOrientationReverse(compass_1.cardinalOrientationFromFlipAndCardinalDirection(this._flip, compass_1.cardinalDirectionFromNorthTurn(this._rotate)))));\r\n this._rotate = nrotate;\r\n this._size.rotate(nrotate);\r\n this._translate.multiply(-1);\r\n return this._update();\r\n }\r\n setTransform(flip, rotate, translate) {\r\n this._flip = flip;\r\n this._rotate = rotate;\r\n this._translate.copyFrom(translate);\r\n return this._update();\r\n }\r\n setFlip(flip) {\r\n this._flip = flip;\r\n return this._update();\r\n }\r\n setRotate(rotate) {\r\n this._rotate = rotate;\r\n return this._update();\r\n }\r\n setTranslate(x, y) {\r\n this._translate.set(x, y);\r\n return this._update();\r\n }\r\n setTranslateOffset(translate) {\r\n this._translate.copyFrom(translate);\r\n return this._update();\r\n }\r\n // utility\r\n applyToCardinalOrientation(orientation) {\r\n if (this._flip === compass_1.Flip.TAILS) {\r\n orientation = compass_1.cardinalOrientationFlip(orientation, compass_1.Axis.NORTH_SOUTH);\r\n }\r\n return compass_1.cardinalOrientationAddCardinalTurn(orientation, this._rotate);\r\n }\r\n unapplyFromCardinalOrientation(orientation) {\r\n orientation = compass_1.cardinalOrientationAddCardinalTurn(orientation, compass_1.cardinalTurnReverse(this._rotate));\r\n if (this._flip === compass_1.Flip.TAILS) {\r\n orientation = compass_1.cardinalOrientationFlip(orientation, compass_1.Axis.NORTH_SOUTH);\r\n }\r\n return orientation;\r\n }\r\n applyToCardinalDirection(orientation) {\r\n return compass_1.cardinalDirectionFromCardinalOrientation(this.applyToCardinalOrientation(compass_1.cardinalOrientationFromFlipAndCardinalDirection(compass_1.Flip.HEADS, orientation)));\r\n }\r\n unapplyFromCardinalDirection(orientation) {\r\n return compass_1.cardinalDirectionFromCardinalOrientation(this.unapplyFromCardinalOrientation(compass_1.cardinalOrientationFromFlipAndCardinalDirection(compass_1.Flip.HEADS, orientation)));\r\n }\r\n applyTo(offOut, x, y) {\r\n const nx = x * this._matrix[0] + y * this._matrix[1] + this._matrix[2];\r\n const ny = x * this._matrix[3] + y * this._matrix[4] + this._matrix[5];\r\n return offOut.set(nx, ny);\r\n }\r\n unapplyFrom(offOut, x, y) {\r\n const tx = x - this._matrix[2];\r\n const ty = y - this._matrix[5];\r\n const nx = tx * this._matrix[0] + ty * this._matrix[3];\r\n const ny = tx * this._matrix[1] + ty * this._matrix[4];\r\n return offOut.set(nx, ny);\r\n }\r\n applyToOffset(offOut, off) {\r\n if (typeof off === 'undefined') {\r\n off = offOut;\r\n }\r\n return this.applyTo(offOut, off.x, off.y);\r\n }\r\n unapplyFromOffset(offOut, off) {\r\n if (typeof off === 'undefined') {\r\n off = offOut;\r\n }\r\n return this.unapplyFrom(offOut, off.x, off.y);\r\n }\r\n applyToRectangle(rectOut, rect) {\r\n if (typeof rect !== 'undefined') {\r\n rectOut.copyFrom(rect);\r\n }\r\n LOCAL_OFF.set(rectOut.westX, rectOut.northY);\r\n LOCAL_OFF2.set(rectOut.eastX, rectOut.southY);\r\n this.applyToOffset(LOCAL_OFF);\r\n this.applyToOffset(LOCAL_OFF2);\r\n return rectOut.setFromCorners(LOCAL_OFF, LOCAL_OFF2);\r\n }\r\n unapplyFromRectangle(rectOut, rect) {\r\n if (typeof rect !== 'undefined') {\r\n rectOut.copyFrom(rect);\r\n }\r\n LOCAL_OFF.set(rectOut.westX, rectOut.northY);\r\n LOCAL_OFF2.set(rectOut.eastX, rectOut.southY);\r\n this.unapplyFromOffset(LOCAL_OFF);\r\n this.unapplyFromOffset(LOCAL_OFF2);\r\n return rectOut.setFromCorners(LOCAL_OFF, LOCAL_OFF2);\r\n }\r\n}\r\nexports.TransformRectangle = TransformRectangle;\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\n__exportStar(require(\"./compass\"), exports);\r\n__exportStar(require(\"./grid\"), exports);\r\n","\"use strict\";\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n});\r\nvar __importStar = (this && this.__importStar) || function (mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.makeBlockFractal = void 0;\r\nconst geom = __importStar(require(\"tiled-geometry\"));\r\nfunction nextToLastMatch(points, next) {\r\n return points.length > 1 && points[points.length - 2].equals(next);\r\n}\r\nfunction addPoint(points, mask, next) {\r\n if (nextToLastMatch(points, next)) {\r\n mask.setAtOffset(points.splice(points.length - 1, 1)[0], false);\r\n }\r\n else {\r\n points.push(next);\r\n mask.setAtOffset(next, true);\r\n }\r\n}\r\nfunction verticalHelper(points, random, variation, newPoints, mask, i, p1, p2) {\r\n const x = 2 * p1.x;\r\n const yDir = p2.y - p1.y;\r\n for (let y = 2 * p1.y; y !== 2 * p2.y; y += yDir) {\r\n const np3 = new geom.Offset(x, y + yDir);\r\n // console.info(`- ${np3}`);\r\n if (nextToLastMatch(newPoints, np3)) {\r\n // This can happen around a corner, when just before the corner\r\n // we dip into the corner\r\n // console.info(` remove ${newPoints[newPoints.length - 1]}`);\r\n mask.setAtOffset(newPoints.splice(newPoints.length - 1, 1)[0], false);\r\n continue;\r\n }\r\n if (i === points.length - 2 && mask.getAtOffset(np3)) {\r\n // This can happen if the first point was on a corner and the\r\n // first move was to dip into the corner\r\n const index = newPoints.findIndex((point) => point.equals(np3));\r\n // console.info(`remove ${index} from beginning`);\r\n for (const point of newPoints.splice(0, index)) {\r\n mask.setAtOffset(point, false);\r\n }\r\n addPoint(newPoints, mask, np3);\r\n break;\r\n }\r\n if (random() < variation) {\r\n const v = Math.floor(random() * 2) * 2 - 1;\r\n const np1 = new geom.Offset(x + v, y);\r\n const np2 = new geom.Offset(x + v, y + yDir);\r\n if (!mask.getAtOffset(np2)) {\r\n if (!mask.getAtOffset(np1) || nextToLastMatch(newPoints, np1)) {\r\n addPoint(newPoints, mask, np1);\r\n addPoint(newPoints, mask, np2);\r\n }\r\n }\r\n }\r\n addPoint(newPoints, mask, np3);\r\n }\r\n}\r\nfunction horizontalHelper(points, random, variation, newPoints, mask, i, p1, p2) {\r\n const y = 2 * p1.y;\r\n const xDir = p2.x - p1.x;\r\n for (let x = 2 * p1.x; x !== 2 * p2.x; x += xDir) {\r\n const np3 = new geom.Offset(x + xDir, y);\r\n // console.info(`- ${np3}`);\r\n if (nextToLastMatch(newPoints, np3)) {\r\n // This can happen around a corner, when just before the corner\r\n // we dip in the direction of the corner\r\n // console.info(` remove ${newPoints[newPoints.length - 1]}`);\r\n mask.setAtOffset(newPoints.splice(newPoints.length - 1, 1)[0], false);\r\n continue;\r\n }\r\n if (i === points.length - 2 && mask.getAtOffset(np3)) {\r\n // This can happen if the first point was on a corner and the\r\n // first move was to dip into the corner\r\n const index = newPoints.findIndex((point) => point.equals(np3));\r\n // console.info(`remove ${index} from beginning`);\r\n for (const point of newPoints.splice(0, index)) {\r\n mask.setAtOffset(point, false);\r\n }\r\n addPoint(newPoints, mask, np3);\r\n break;\r\n }\r\n if (random() < variation) {\r\n const v = Math.floor(random() * 2) * 2 - 1;\r\n const np1 = new geom.Offset(x, y + v);\r\n const np2 = new geom.Offset(x + xDir, y + v);\r\n if (!mask.getAtOffset(np2)) {\r\n if (!mask.getAtOffset(np1) || nextToLastMatch(newPoints, np1)) {\r\n addPoint(newPoints, mask, np1);\r\n addPoint(newPoints, mask, np2);\r\n }\r\n }\r\n }\r\n addPoint(newPoints, mask, np3);\r\n }\r\n}\r\nfunction blockFractalIteration(random, points, bounds, variation) {\r\n const newPoints = new Array();\r\n const newBounds = new geom.Rectangle(bounds.westX * 2 - 1, bounds.northY * 2 - 1, bounds.width * 2 + 2, bounds.height * 2 + 2);\r\n // console.info(` bounds ${newBounds}`);\r\n const mask = new geom.MaskRectangle(newBounds);\r\n for (let i = 0; i < points.length - 1; i++) {\r\n const p1 = points[i];\r\n const p2 = points[i + 1];\r\n if (i === 0) {\r\n addPoint(newPoints, mask, new geom.Offset(p1.x * 2, p1.y * 2));\r\n }\r\n if (p1.x === p2.x) {\r\n verticalHelper(points, random, variation, newPoints, mask, i, p1, p2);\r\n }\r\n else {\r\n horizontalHelper(points, random, variation, newPoints, mask, i, p1, p2);\r\n }\r\n }\r\n return {\r\n points: newPoints,\r\n bounds: newBounds,\r\n };\r\n}\r\nfunction makeBlockFractal(param) {\r\n let { random, shape, variation } = param;\r\n if (typeof random === 'undefined') {\r\n random = Math.random;\r\n }\r\n if (typeof shape === 'undefined') {\r\n shape = new geom.CardinalPath({ x: -1, y: -1 }, [\r\n geom.CardinalDirection.EAST,\r\n geom.CardinalDirection.EAST,\r\n geom.CardinalDirection.SOUTH,\r\n geom.CardinalDirection.SOUTH,\r\n geom.CardinalDirection.WEST,\r\n geom.CardinalDirection.WEST,\r\n geom.CardinalDirection.NORTH,\r\n geom.CardinalDirection.NORTH,\r\n ]);\r\n }\r\n if (typeof variation === 'undefined') {\r\n variation = 0.4;\r\n }\r\n let points = new Array();\r\n let bounds = shape.getBounds();\r\n for (const off of shape.offsets()) {\r\n points.push(new geom.Offset(off.x, off.y));\r\n }\r\n for (let iter = 0; iter < param.iterations; iter++) {\r\n // console.info(`iteration ${iter + 1}`);\r\n ({ points, bounds } = blockFractalIteration(random, points, bounds, variation));\r\n }\r\n const segments = new Array();\r\n for (let i = 0; i < points.length - 1; i++) {\r\n const curPoint = points[i];\r\n const nextPoint = points[i + 1];\r\n if (nextPoint.y === curPoint.y - 1) {\r\n segments.push(geom.CardinalDirection.NORTH);\r\n }\r\n else if (nextPoint.x === curPoint.x + 1) {\r\n segments.push(geom.CardinalDirection.EAST);\r\n }\r\n else if (nextPoint.y === curPoint.y + 1) {\r\n segments.push(geom.CardinalDirection.SOUTH);\r\n }\r\n else if (nextPoint.x === curPoint.x - 1) {\r\n segments.push(geom.CardinalDirection.WEST);\r\n }\r\n }\r\n return new geom.CardinalPath(points[0], segments);\r\n}\r\nexports.makeBlockFractal = makeBlockFractal;\r\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","\"use strict\";\r\n/*\r\n * BlockFractal\r\n * github.com/sbj42/block-fractal\r\n * James Clark\r\n * Licensed under the MIT license.\r\n */\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.RasterMask = exports.CardinalPath = exports.Offset = exports.CardinalDirectionFlags = exports.CardinalDirection = exports.makeBlockFractal = void 0;\r\nvar block_fractal_1 = require(\"./block-fractal\");\r\nObject.defineProperty(exports, \"makeBlockFractal\", { enumerable: true, get: function () { return block_fractal_1.makeBlockFractal; } });\r\nvar tiled_geometry_1 = require(\"tiled-geometry\");\r\nObject.defineProperty(exports, \"CardinalDirection\", { enumerable: true, get: function () { return tiled_geometry_1.CardinalDirection; } });\r\nObject.defineProperty(exports, \"CardinalDirectionFlags\", { enumerable: true, get: function () { return tiled_geometry_1.CardinalDirectionFlags; } });\r\nObject.defineProperty(exports, \"Offset\", { enumerable: true, get: function () { return tiled_geometry_1.Offset; } });\r\nObject.defineProperty(exports, \"CardinalPath\", { enumerable: true, get: function () { return tiled_geometry_1.CardinalPath; } });\r\nObject.defineProperty(exports, \"RasterMask\", { enumerable: true, get: function () { return tiled_geometry_1.RasterMask; } });\r\n"],"names":["Axis","Object","defineProperty","exports","value","axisAddCardinalTurn","axisFromNorthSouthTurn","axisFromCardinalDirection","axisOrthogonal","axisToString","AXES","NORTH_SOUTH","WEST_EAST","AXES_STR","axis","dir","turn","CardinalDirectionFlags","cardinalDirectionFlagsFromCardinalDirection","cardinalDirectionFlagsRemoveCardinalDirection","cardinalDirectionFlagsSetCardinalDirection","cardinalDirectionFlagsHasCardinalDirection","cardinalDirectionFlagsToString","flags","ret","NORTH","EAST","SOUTH","WEST","CardinalDirection","cardinalDirectionAddCardinalTurn","cardinalDirectionFromCardinalOrientation","cardinalDirectionFromNorthTurn","cardinalDirectionFromDirection","cardinalDirectionOpposite","cardinalDirectionToString","CARDINAL_DIRECTIONS","CARDINAL_DIRECTIONS_STR","orientation","cardinalOrientationAddCardinalTurn","cardinalOrientationFromFlipAndCardinalDirection","cardinalOrientationReverse","cardinalOrientationFlip","cardinalOrientationToString","CARDINAL_ORIENTATIONS","CardinalOrientation","axis_1","flip_1","HEADS_NORTH","TAILS_NORTH","HEADS_EAST","TAILS_EAST","HEADS_SOUTH","TAILS_SOUTH","HEADS_WEST","TAILS_WEST","CARDINAL_ORIENTATIONS_STR","flip","Flip","HEADS","CardinalTurn","cardinalTurnAddCardinalTurn","cardinalTurnFromTurn","cardinalTurnFromCardinalDirections","cardinalTurnReverse","cardinalTurnToDegrees","cardinalTurnToString","CARDINAL_TURNS","NONE","RIGHT","AROUND","LEFT","CARDINAL_TURNS_STR","from","to","turn1","turn2","Direction","directionAddCardinalTurn","directionAddTurn","directionFromCardinalDirection","directionOpposite","directionIsCardinal","directionToString","DIRECTIONS","NORTHEAST","SOUTHEAST","SOUTHWEST","NORTHWEST","DIRECTIONS_STR","flipFromCardinalOrientation","flipFromBoolean","flipOpposite","flipToString","FLIPS","TAILS","FLIPS_STR","tails","__createBinding","this","create","o","m","k","k2","undefined","enumerable","get","__exportStar","p","prototype","hasOwnProperty","call","Turn","turnAddTurn","turnFromDirections","turnFromCardinalTurn","turnFromCardinalDirections","turnReverse","turnIsCardinal","turnToDegrees","turnToString","TURNS","R_45","R_90","R_135","T_180","L_135","L_90","L_45","TURNS_STR","CardinalPath","compass_1","offset_1","rectangle_1","raster_mask_1","LOCAL_OFF","Offset","sortedInsert","array","push","i","length","constructor","start","segments","_start","copyFrom","_segments","toString","map","segment","join","equals","other","every","v","getIsClosed","addCardinalDirection","x","y","setFromCardinalDirection","getBounds","northY","southY","westX","eastX","Math","min","max","Error","Rectangle","getArea","total","abs","rasterize","bounds","lines","Array","height","RasterMask","width","MaskRectangle","mask_1","rect","initialValue","outsideValue","_rect","_mask","Mask","_outsideValue","northWest","contains","getAtIndex","index","getAtOffset","off","set","setAtOffset","setAtIndex","loc","locations","offsetsWithTrue","size_1","size","_size","Size","_bits","ceil","area","fill","arrayIndex","bitMask","slice","offsets","X_FROM_DIRECTION","Y_FROM_DIRECTION","X_FROM_CARDINAL_DIRECTION","Y_FROM_CARDINAL_DIRECTION","setFromDirection","add","addSize","addOffset","addDirection","subtractOffset","multiply","factor","rotate","anchor","dirx","diry","nx","ny","distanceChebyshev","distanceManhattan","cursor","radius","dy","dx","_lines","shape","line","end","w","j","ROTATE_CORNER_X","ROTATE_CORNER_Y","empty","setFromCorners","off1","off2","scale","cx","cy","extendToInclude","containsOffset","containsRectangle","overlapsRectangle","anyOf","predicate","TransformRectangle","LOCAL_OFF2","LOCAL_SIZE","_flip","_rotate","_translate","_matrix","_targetRect","_update","flipSign","forEach","reset","invert","nrotate","setTransform","translate","setFlip","setRotate","setTranslate","setTranslateOffset","applyToCardinalOrientation","unapplyFromCardinalOrientation","applyToCardinalDirection","unapplyFromCardinalDirection","applyTo","offOut","unapplyFrom","tx","ty","applyToOffset","unapplyFromOffset","applyToRectangle","rectOut","unapplyFromRectangle","__setModuleDefault","__importStar","mod","__esModule","result","makeBlockFractal","geom","nextToLastMatch","points","next","addPoint","mask","splice","verticalHelper","random","variation","newPoints","p1","p2","yDir","np3","findIndex","point","floor","np1","np2","horizontalHelper","xDir","blockFractalIteration","newBounds","param","iter","iterations","curPoint","nextPoint","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","module","__webpack_modules__","block_fractal_1","tiled_geometry_1"],"sourceRoot":""} \ No newline at end of file diff --git a/package.json b/package.json index 52b295c..6736a12 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "block-fractal", - "version": "2.0.0", + "version": "2.0.2", "description": "Generates a blocky fractal-like shape, like a tile-based randomized koch curve", "keywords": [ "fractal",