📦 3.3.0
This commit is contained in:
@@ -4,7 +4,7 @@ author: "platane"
|
|||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: docker
|
using: docker
|
||||||
image: docker://platane/snk@sha256:1c8a0b51a75ad8cf36b7defddd2187bdbb92bbbb5521a9e6cc5df795b00fc590
|
image: docker://platane/snk@sha256:96390294299275740e5963058c9784c60c5393b3b8b16082dcf41b240db791f9
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
github_user_name:
|
github_user_name:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "snk",
|
"name": "snk",
|
||||||
"description": "Generates a snake game from a github user contributions grid",
|
"description": "Generates a snake game from a github user contributions grid",
|
||||||
"version": "3.2.0",
|
"version": "3.3.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"repository": "github:platane/snk",
|
"repository": "github:platane/snk",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
exports.id = 371;
|
exports.id = 155;
|
||||||
exports.ids = [371];
|
exports.ids = [155];
|
||||||
exports.modules = {
|
exports.modules = {
|
||||||
|
|
||||||
/***/ 3561:
|
/***/ 1680:
|
||||||
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
||||||
|
|
||||||
module.exports = __webpack_require__(9244)
|
module.exports = __webpack_require__(7739)
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 9244:
|
/***/ 7739:
|
||||||
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
||||||
|
|
||||||
const stream = __webpack_require__(2781)
|
const stream = __webpack_require__(2203)
|
||||||
const EventEmitter = __webpack_require__(2361)
|
const EventEmitter = __webpack_require__(4434)
|
||||||
const LZWEncoder = __webpack_require__(4348)
|
const LZWEncoder = __webpack_require__(3500)
|
||||||
const NeuQuant = __webpack_require__(3829)
|
const NeuQuant = __webpack_require__(222)
|
||||||
const { OctreeQuant, Color } = __webpack_require__(9328)
|
const { OctreeQuant, Color } = __webpack_require__(2756)
|
||||||
|
|
||||||
class ByteArray {
|
class ByteArray {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -417,7 +417,7 @@ module.exports = GIFEncoder
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 4348:
|
/***/ 3500:
|
||||||
/***/ ((module) => {
|
/***/ ((module) => {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -651,7 +651,7 @@ module.exports = LZWEncoder
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 9328:
|
/***/ 2756:
|
||||||
/***/ ((module) => {
|
/***/ ((module) => {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -878,7 +878,7 @@ module.exports = { OctreeQuant, Node, Color }
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 3829:
|
/***/ 222:
|
||||||
/***/ ((module) => {
|
/***/ ((module) => {
|
||||||
|
|
||||||
/* NeuQuant Neural-Net Quantization Algorithm
|
/* NeuQuant Neural-Net Quantization Algorithm
|
||||||
@@ -1334,7 +1334,7 @@ module.exports = NeuQuant
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 6382:
|
/***/ 2644:
|
||||||
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -1348,10 +1348,10 @@ module.exports = NeuQuant
|
|||||||
/*
|
/*
|
||||||
* Module dependencies.
|
* Module dependencies.
|
||||||
*/
|
*/
|
||||||
const fs = __webpack_require__(7147);
|
const fs = __webpack_require__(9896);
|
||||||
const os = __webpack_require__(2037);
|
const os = __webpack_require__(857);
|
||||||
const path = __webpack_require__(1017);
|
const path = __webpack_require__(6928);
|
||||||
const crypto = __webpack_require__(6113);
|
const crypto = __webpack_require__(6982);
|
||||||
const _c = { fs: fs.constants, os: os.constants };
|
const _c = { fs: fs.constants, os: os.constants };
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1,17 +1,15 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
exports.id = 407;
|
exports.id = 324;
|
||||||
exports.ids = [407];
|
exports.ids = [324];
|
||||||
exports.modules = {
|
exports.modules = {
|
||||||
|
|
||||||
/***/ 407:
|
/***/ 324:
|
||||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||||
|
|
||||||
// ESM COMPAT FLAG
|
|
||||||
__webpack_require__.r(__webpack_exports__);
|
|
||||||
|
|
||||||
// EXPORTS
|
// EXPORTS
|
||||||
__webpack_require__.d(__webpack_exports__, {
|
__webpack_require__.d(__webpack_exports__, {
|
||||||
"generateContributionSnake": () => (/* binding */ generateContributionSnake)
|
generateContributionSnake: () => (/* binding */ generateContributionSnake)
|
||||||
});
|
});
|
||||||
|
|
||||||
;// CONCATENATED MODULE: ../github-user-contribution/index.ts
|
;// CONCATENATED MODULE: ../github-user-contribution/index.ts
|
||||||
@@ -55,12 +53,13 @@ const getGithubUserContribution = async (userName, o) => {
|
|||||||
headers: {
|
headers: {
|
||||||
Authorization: `bearer ${o.githubToken}`,
|
Authorization: `bearer ${o.githubToken}`,
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
"User-Agent": "me@platane.me",
|
||||||
},
|
},
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify({ variables, query }),
|
body: JSON.stringify({ variables, query }),
|
||||||
});
|
});
|
||||||
if (!res.ok)
|
if (!res.ok)
|
||||||
throw new Error(res.statusText);
|
throw new Error(await res.text().catch(() => res.statusText));
|
||||||
const { data, errors } = (await res.json());
|
const { data, errors } = (await res.json());
|
||||||
if (errors?.[0])
|
if (errors?.[0])
|
||||||
throw errors[0];
|
throw errors[0];
|
||||||
@@ -78,18 +77,18 @@ const getGithubUserContribution = async (userName, o) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// EXTERNAL MODULE: ../types/grid.ts
|
// EXTERNAL MODULE: ../types/grid.ts
|
||||||
var types_grid = __webpack_require__(2881);
|
var types_grid = __webpack_require__(105);
|
||||||
;// CONCATENATED MODULE: ./userContributionToGrid.ts
|
;// CONCATENATED MODULE: ./userContributionToGrid.ts
|
||||||
|
|
||||||
const userContributionToGrid = (cells) => {
|
const userContributionToGrid = (cells) => {
|
||||||
const width = Math.max(0, ...cells.map((c) => c.x)) + 1;
|
const width = Math.max(0, ...cells.map((c) => c.x)) + 1;
|
||||||
const height = Math.max(0, ...cells.map((c) => c.y)) + 1;
|
const height = Math.max(0, ...cells.map((c) => c.y)) + 1;
|
||||||
const grid = (0,types_grid/* createEmptyGrid */.u1)(width, height);
|
const grid = (0,types_grid/* createEmptyGrid */.Kb)(width, height);
|
||||||
for (const c of cells) {
|
for (const c of cells) {
|
||||||
if (c.level > 0)
|
if (c.level > 0)
|
||||||
(0,types_grid/* setColor */.vk)(grid, c.x, c.y, c.level);
|
(0,types_grid/* setColor */.wW)(grid, c.x, c.y, c.level);
|
||||||
else
|
else
|
||||||
(0,types_grid/* setColorEmpty */.Dy)(grid, c.x, c.y);
|
(0,types_grid/* setColorEmpty */.l$)(grid, c.x, c.y);
|
||||||
}
|
}
|
||||||
return grid;
|
return grid;
|
||||||
};
|
};
|
||||||
@@ -107,10 +106,10 @@ const pointEquals = (a, b) => a.x === b.x && a.y === b.y;
|
|||||||
|
|
||||||
|
|
||||||
const createOutside = (grid, color = 0) => {
|
const createOutside = (grid, color = 0) => {
|
||||||
const outside = (0,types_grid/* createEmptyGrid */.u1)(grid.width, grid.height);
|
const outside = (0,types_grid/* createEmptyGrid */.Kb)(grid.width, grid.height);
|
||||||
for (let x = outside.width; x--;)
|
for (let x = outside.width; x--;)
|
||||||
for (let y = outside.height; y--;)
|
for (let y = outside.height; y--;)
|
||||||
(0,types_grid/* setColor */.vk)(outside, x, y, 1);
|
(0,types_grid/* setColor */.wW)(outside, x, y, 1);
|
||||||
fillOutside(outside, grid, color);
|
fillOutside(outside, grid, color);
|
||||||
return outside;
|
return outside;
|
||||||
};
|
};
|
||||||
@@ -120,19 +119,19 @@ const fillOutside = (outside, grid, color = 0) => {
|
|||||||
changed = false;
|
changed = false;
|
||||||
for (let x = outside.width; x--;)
|
for (let x = outside.width; x--;)
|
||||||
for (let y = outside.height; y--;)
|
for (let y = outside.height; y--;)
|
||||||
if ((0,types_grid/* getColor */.Lq)(grid, x, y) <= color &&
|
if ((0,types_grid/* getColor */.oU)(grid, x, y) <= color &&
|
||||||
!isOutside(outside, x, y) &&
|
!isOutside(outside, x, y) &&
|
||||||
around4.some((a) => isOutside(outside, x + a.x, y + a.y))) {
|
around4.some((a) => isOutside(outside, x + a.x, y + a.y))) {
|
||||||
changed = true;
|
changed = true;
|
||||||
(0,types_grid/* setColorEmpty */.Dy)(outside, x, y);
|
(0,types_grid/* setColorEmpty */.l$)(outside, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return outside;
|
return outside;
|
||||||
};
|
};
|
||||||
const isOutside = (outside, x, y) => !(0,types_grid/* isInside */.V0)(outside, x, y) || (0,types_grid/* isEmpty */.xb)((0,types_grid/* getColor */.Lq)(outside, x, y));
|
const isOutside = (outside, x, y) => !(0,types_grid/* isInside */.FK)(outside, x, y) || (0,types_grid/* isEmpty */.Im)((0,types_grid/* getColor */.oU)(outside, x, y));
|
||||||
|
|
||||||
// EXTERNAL MODULE: ../types/snake.ts
|
// EXTERNAL MODULE: ../types/snake.ts
|
||||||
var types_snake = __webpack_require__(9347);
|
var types_snake = __webpack_require__(777);
|
||||||
;// CONCATENATED MODULE: ../solver/utils/sortPush.ts
|
;// CONCATENATED MODULE: ../solver/utils/sortPush.ts
|
||||||
const sortPush = (arr, x, sortFn) => {
|
const sortPush = (arr, x, sortFn) => {
|
||||||
let a = 0;
|
let a = 0;
|
||||||
@@ -165,9 +164,9 @@ const getTunnelPath = (snake0, tunnel) => {
|
|||||||
const chain = [];
|
const chain = [];
|
||||||
let snake = snake0;
|
let snake = snake0;
|
||||||
for (let i = 1; i < tunnel.length; i++) {
|
for (let i = 1; i < tunnel.length; i++) {
|
||||||
const dx = tunnel[i].x - (0,types_snake/* getHeadX */.If)(snake);
|
const dx = tunnel[i].x - (0,types_snake/* getHeadX */.tN)(snake);
|
||||||
const dy = tunnel[i].y - (0,types_snake/* getHeadY */.IP)(snake);
|
const dy = tunnel[i].y - (0,types_snake/* getHeadY */.Ap)(snake);
|
||||||
snake = (0,types_snake/* nextSnake */.kv)(snake, dx, dy);
|
snake = (0,types_snake/* nextSnake */.Sc)(snake, dx, dy);
|
||||||
chain.unshift(snake);
|
chain.unshift(snake);
|
||||||
}
|
}
|
||||||
return chain;
|
return chain;
|
||||||
@@ -195,7 +194,7 @@ const updateTunnel = (grid, tunnel, toDelete) => {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const isEmptySafe = (grid, x, y) => !(0,types_grid/* isInside */.V0)(grid, x, y) || (0,types_grid/* isEmpty */.xb)((0,types_grid/* getColor */.Lq)(grid, x, y));
|
const isEmptySafe = (grid, x, y) => !(0,types_grid/* isInside */.FK)(grid, x, y) || (0,types_grid/* isEmpty */.Im)((0,types_grid/* getColor */.oU)(grid, x, y));
|
||||||
/**
|
/**
|
||||||
* remove empty cell from start
|
* remove empty cell from start
|
||||||
*/
|
*/
|
||||||
@@ -230,14 +229,14 @@ const trimTunnelEnd = (grid, tunnel) => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const getColorSafe = (grid, x, y) => (0,types_grid/* isInside */.V0)(grid, x, y) ? (0,types_grid/* getColor */.Lq)(grid, x, y) : 0;
|
const getColorSafe = (grid, x, y) => (0,types_grid/* isInside */.FK)(grid, x, y) ? (0,types_grid/* getColor */.oU)(grid, x, y) : 0;
|
||||||
const setEmptySafe = (grid, x, y) => {
|
const setEmptySafe = (grid, x, y) => {
|
||||||
if ((0,types_grid/* isInside */.V0)(grid, x, y))
|
if ((0,types_grid/* isInside */.FK)(grid, x, y))
|
||||||
(0,types_grid/* setColorEmpty */.Dy)(grid, x, y);
|
(0,types_grid/* setColorEmpty */.l$)(grid, x, y);
|
||||||
};
|
};
|
||||||
const unwrap = (m) => !m
|
const unwrap = (m) => !m
|
||||||
? []
|
? []
|
||||||
: [...unwrap(m.parent), { x: (0,types_snake/* getHeadX */.If)(m.snake), y: (0,types_snake/* getHeadY */.IP)(m.snake) }];
|
: [...unwrap(m.parent), { x: (0,types_snake/* getHeadX */.tN)(m.snake), y: (0,types_snake/* getHeadY */.Ap)(m.snake) }];
|
||||||
/**
|
/**
|
||||||
* returns the path to reach the outside which contains the least color cell
|
* returns the path to reach the outside which contains the least color cell
|
||||||
*/
|
*/
|
||||||
@@ -246,15 +245,15 @@ const getSnakeEscapePath = (grid, outside, snake0, color) => {
|
|||||||
const closeList = [];
|
const closeList = [];
|
||||||
while (openList[0]) {
|
while (openList[0]) {
|
||||||
const o = openList.shift();
|
const o = openList.shift();
|
||||||
const x = (0,types_snake/* getHeadX */.If)(o.snake);
|
const x = (0,types_snake/* getHeadX */.tN)(o.snake);
|
||||||
const y = (0,types_snake/* getHeadY */.IP)(o.snake);
|
const y = (0,types_snake/* getHeadY */.Ap)(o.snake);
|
||||||
if (isOutside(outside, x, y))
|
if (isOutside(outside, x, y))
|
||||||
return unwrap(o);
|
return unwrap(o);
|
||||||
for (const a of around4) {
|
for (const a of around4) {
|
||||||
const c = getColorSafe(grid, x + a.x, y + a.y);
|
const c = getColorSafe(grid, x + a.x, y + a.y);
|
||||||
if (c <= color && !(0,types_snake/* snakeWillSelfCollide */.nJ)(o.snake, a.x, a.y)) {
|
if (c <= color && !(0,types_snake/* snakeWillSelfCollide */.J)(o.snake, a.x, a.y)) {
|
||||||
const snake = (0,types_snake/* nextSnake */.kv)(o.snake, a.x, a.y);
|
const snake = (0,types_snake/* nextSnake */.Sc)(o.snake, a.x, a.y);
|
||||||
if (!closeList.some((s0) => (0,types_snake/* snakeEquals */.kE)(s0, snake))) {
|
if (!closeList.some((s0) => (0,types_snake/* snakeEquals */.sW)(s0, snake))) {
|
||||||
const w = o.w + 1 + +(c === color) * 1000;
|
const w = o.w + 1 + +(c === color) * 1000;
|
||||||
sortPush(openList, { snake, w, parent: o }, (a, b) => a.w - b.w);
|
sortPush(openList, { snake, w, parent: o }, (a, b) => a.w - b.w);
|
||||||
closeList.push(snake);
|
closeList.push(snake);
|
||||||
@@ -271,7 +270,7 @@ const getSnakeEscapePath = (grid, outside, snake0, color) => {
|
|||||||
*/
|
*/
|
||||||
const getBestTunnel = (grid, outside, x, y, color, snakeN) => {
|
const getBestTunnel = (grid, outside, x, y, color, snakeN) => {
|
||||||
const c = { x, y };
|
const c = { x, y };
|
||||||
const snake0 = (0,types_snake/* createSnakeFromCells */.xG)(Array.from({ length: snakeN }, () => c));
|
const snake0 = (0,types_snake/* createSnakeFromCells */.yS)(Array.from({ length: snakeN }, () => c));
|
||||||
const one = getSnakeEscapePath(grid, outside, snake0, color);
|
const one = getSnakeEscapePath(grid, outside, snake0, color);
|
||||||
if (!one)
|
if (!one)
|
||||||
return null;
|
return null;
|
||||||
@@ -279,9 +278,9 @@ const getBestTunnel = (grid, outside, x, y, color, snakeN) => {
|
|||||||
const snakeICells = one.slice(0, snakeN);
|
const snakeICells = one.slice(0, snakeN);
|
||||||
while (snakeICells.length < snakeN)
|
while (snakeICells.length < snakeN)
|
||||||
snakeICells.push(snakeICells[snakeICells.length - 1]);
|
snakeICells.push(snakeICells[snakeICells.length - 1]);
|
||||||
const snakeI = (0,types_snake/* createSnakeFromCells */.xG)(snakeICells);
|
const snakeI = (0,types_snake/* createSnakeFromCells */.yS)(snakeICells);
|
||||||
// remove from the grid the colors that one eat
|
// remove from the grid the colors that one eat
|
||||||
const gridI = (0,types_grid/* copyGrid */.VJ)(grid);
|
const gridI = (0,types_grid/* copyGrid */.mi)(grid);
|
||||||
for (const { x, y } of one)
|
for (const { x, y } of one)
|
||||||
setEmptySafe(gridI, x, y);
|
setEmptySafe(gridI, x, y);
|
||||||
const two = getSnakeEscapePath(gridI, outside, snakeI, color);
|
const two = getSnakeEscapePath(gridI, outside, snakeI, color);
|
||||||
@@ -309,15 +308,15 @@ const getPathTo = (grid, snake0, x, y) => {
|
|||||||
const closeList = [];
|
const closeList = [];
|
||||||
while (openList.length) {
|
while (openList.length) {
|
||||||
const c = openList.shift();
|
const c = openList.shift();
|
||||||
const cx = (0,types_snake/* getHeadX */.If)(c.snake);
|
const cx = (0,types_snake/* getHeadX */.tN)(c.snake);
|
||||||
const cy = (0,types_snake/* getHeadY */.IP)(c.snake);
|
const cy = (0,types_snake/* getHeadY */.Ap)(c.snake);
|
||||||
for (let i = 0; i < around4.length; i++) {
|
for (let i = 0; i < around4.length; i++) {
|
||||||
const { x: dx, y: dy } = around4[i];
|
const { x: dx, y: dy } = around4[i];
|
||||||
const nx = cx + dx;
|
const nx = cx + dx;
|
||||||
const ny = cy + dy;
|
const ny = cy + dy;
|
||||||
if (nx === x && ny === y) {
|
if (nx === x && ny === y) {
|
||||||
// unwrap
|
// unwrap
|
||||||
const path = [(0,types_snake/* nextSnake */.kv)(c.snake, dx, dy)];
|
const path = [(0,types_snake/* nextSnake */.Sc)(c.snake, dx, dy)];
|
||||||
let e = c;
|
let e = c;
|
||||||
while (e.parent) {
|
while (e.parent) {
|
||||||
path.push(e.snake);
|
path.push(e.snake);
|
||||||
@@ -325,11 +324,11 @@ const getPathTo = (grid, snake0, x, y) => {
|
|||||||
}
|
}
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
if ((0,types_grid/* isInsideLarge */.HJ)(grid, 2, nx, ny) &&
|
if ((0,types_grid/* isInsideLarge */.Yd)(grid, 2, nx, ny) &&
|
||||||
!(0,types_snake/* snakeWillSelfCollide */.nJ)(c.snake, dx, dy) &&
|
!(0,types_snake/* snakeWillSelfCollide */.J)(c.snake, dx, dy) &&
|
||||||
(!(0,types_grid/* isInside */.V0)(grid, nx, ny) || (0,types_grid/* isEmpty */.xb)((0,types_grid/* getColor */.Lq)(grid, nx, ny)))) {
|
(!(0,types_grid/* isInside */.FK)(grid, nx, ny) || (0,types_grid/* isEmpty */.Im)((0,types_grid/* getColor */.oU)(grid, nx, ny)))) {
|
||||||
const nsnake = (0,types_snake/* nextSnake */.kv)(c.snake, dx, dy);
|
const nsnake = (0,types_snake/* nextSnake */.Sc)(c.snake, dx, dy);
|
||||||
if (!closeList.some((s) => (0,types_snake/* snakeEquals */.kE)(nsnake, s))) {
|
if (!closeList.some((s) => (0,types_snake/* snakeEquals */.sW)(nsnake, s))) {
|
||||||
const w = c.w + 1;
|
const w = c.w + 1;
|
||||||
const h = Math.abs(nx - x) + Math.abs(ny - y);
|
const h = Math.abs(nx - x) + Math.abs(ny - y);
|
||||||
const f = w + h;
|
const f = w + h;
|
||||||
@@ -350,7 +349,7 @@ const getPathTo = (grid, snake0, x, y) => {
|
|||||||
|
|
||||||
|
|
||||||
const clearResidualColoredLayer = (grid, outside, snake0, color) => {
|
const clearResidualColoredLayer = (grid, outside, snake0, color) => {
|
||||||
const snakeN = (0,types_snake/* getSnakeLength */.JJ)(snake0);
|
const snakeN = (0,types_snake/* getSnakeLength */.T$)(snake0);
|
||||||
const tunnels = getTunnellablePoints(grid, outside, snakeN, color);
|
const tunnels = getTunnellablePoints(grid, outside, snakeN, color);
|
||||||
// sort
|
// sort
|
||||||
tunnels.sort((a, b) => b.priority - a.priority);
|
tunnels.sort((a, b) => b.priority - a.priority);
|
||||||
@@ -369,7 +368,7 @@ const clearResidualColoredLayer = (grid, outside, snake0, color) => {
|
|||||||
fillOutside(outside, grid);
|
fillOutside(outside, grid);
|
||||||
// update tunnels
|
// update tunnels
|
||||||
for (let i = tunnels.length; i--;)
|
for (let i = tunnels.length; i--;)
|
||||||
if ((0,types_grid/* isEmpty */.xb)((0,types_grid/* getColor */.Lq)(grid, tunnels[i].x, tunnels[i].y)))
|
if ((0,types_grid/* isEmpty */.Im)((0,types_grid/* getColor */.oU)(grid, tunnels[i].x, tunnels[i].y)))
|
||||||
tunnels.splice(i, 1);
|
tunnels.splice(i, 1);
|
||||||
else {
|
else {
|
||||||
const t = tunnels[i];
|
const t = tunnels[i];
|
||||||
@@ -390,8 +389,8 @@ const clearResidualColoredLayer = (grid, outside, snake0, color) => {
|
|||||||
const getNextTunnel = (ts, snake) => {
|
const getNextTunnel = (ts, snake) => {
|
||||||
let minDistance = Infinity;
|
let minDistance = Infinity;
|
||||||
let closestTunnel = null;
|
let closestTunnel = null;
|
||||||
const x = (0,types_snake/* getHeadX */.If)(snake);
|
const x = (0,types_snake/* getHeadX */.tN)(snake);
|
||||||
const y = (0,types_snake/* getHeadY */.IP)(snake);
|
const y = (0,types_snake/* getHeadY */.Ap)(snake);
|
||||||
const priority = ts[0].priority;
|
const priority = ts[0].priority;
|
||||||
for (let i = 0; ts[i] && ts[i].priority === priority; i++) {
|
for (let i = 0; ts[i] && ts[i].priority === priority; i++) {
|
||||||
const t = ts[i].tunnel;
|
const t = ts[i].tunnel;
|
||||||
@@ -410,8 +409,8 @@ const getTunnellablePoints = (grid, outside, snakeN, color) => {
|
|||||||
const points = [];
|
const points = [];
|
||||||
for (let x = grid.width; x--;)
|
for (let x = grid.width; x--;)
|
||||||
for (let y = grid.height; y--;) {
|
for (let y = grid.height; y--;) {
|
||||||
const c = (0,types_grid/* getColor */.Lq)(grid, x, y);
|
const c = (0,types_grid/* getColor */.oU)(grid, x, y);
|
||||||
if (!(0,types_grid/* isEmpty */.xb)(c) && c < color) {
|
if (!(0,types_grid/* isEmpty */.Im)(c) && c < color) {
|
||||||
const tunnel = getBestTunnel(grid, outside, x, y, color, snakeN);
|
const tunnel = getBestTunnel(grid, outside, x, y, color, snakeN);
|
||||||
if (tunnel) {
|
if (tunnel) {
|
||||||
const priority = getPriority(grid, color, tunnel);
|
const priority = getPriority(grid, color, tunnel);
|
||||||
@@ -432,7 +431,7 @@ const getPriority = (grid, color, tunnel) => {
|
|||||||
for (let i = 0; i < tunnel.length; i++) {
|
for (let i = 0; i < tunnel.length; i++) {
|
||||||
const { x, y } = tunnel[i];
|
const { x, y } = tunnel[i];
|
||||||
const c = clearResidualColoredLayer_getColorSafe(grid, x, y);
|
const c = clearResidualColoredLayer_getColorSafe(grid, x, y);
|
||||||
if (!(0,types_grid/* isEmpty */.xb)(c) && i === tunnel.findIndex((p) => p.x === x && p.y === y)) {
|
if (!(0,types_grid/* isEmpty */.Im)(c) && i === tunnel.findIndex((p) => p.x === x && p.y === y)) {
|
||||||
if (c === color)
|
if (c === color)
|
||||||
nColor += 1;
|
nColor += 1;
|
||||||
else
|
else
|
||||||
@@ -444,10 +443,10 @@ const getPriority = (grid, color, tunnel) => {
|
|||||||
return nLess / nColor;
|
return nLess / nColor;
|
||||||
};
|
};
|
||||||
const distanceSq = (ax, ay, bx, by) => (ax - bx) ** 2 + (ay - by) ** 2;
|
const distanceSq = (ax, ay, bx, by) => (ax - bx) ** 2 + (ay - by) ** 2;
|
||||||
const clearResidualColoredLayer_getColorSafe = (grid, x, y) => (0,types_grid/* isInside */.V0)(grid, x, y) ? (0,types_grid/* getColor */.Lq)(grid, x, y) : 0;
|
const clearResidualColoredLayer_getColorSafe = (grid, x, y) => (0,types_grid/* isInside */.FK)(grid, x, y) ? (0,types_grid/* getColor */.oU)(grid, x, y) : 0;
|
||||||
const clearResidualColoredLayer_setEmptySafe = (grid, x, y) => {
|
const clearResidualColoredLayer_setEmptySafe = (grid, x, y) => {
|
||||||
if ((0,types_grid/* isInside */.V0)(grid, x, y))
|
if ((0,types_grid/* isInside */.FK)(grid, x, y))
|
||||||
(0,types_grid/* setColorEmpty */.Dy)(grid, x, y);
|
(0,types_grid/* setColorEmpty */.l$)(grid, x, y);
|
||||||
};
|
};
|
||||||
|
|
||||||
;// CONCATENATED MODULE: ../solver/clearCleanColoredLayer.ts
|
;// CONCATENATED MODULE: ../solver/clearCleanColoredLayer.ts
|
||||||
@@ -457,14 +456,14 @@ const clearResidualColoredLayer_setEmptySafe = (grid, x, y) => {
|
|||||||
|
|
||||||
|
|
||||||
const clearCleanColoredLayer = (grid, outside, snake0, color) => {
|
const clearCleanColoredLayer = (grid, outside, snake0, color) => {
|
||||||
const snakeN = (0,types_snake/* getSnakeLength */.JJ)(snake0);
|
const snakeN = (0,types_snake/* getSnakeLength */.T$)(snake0);
|
||||||
const points = clearCleanColoredLayer_getTunnellablePoints(grid, outside, snakeN, color);
|
const points = clearCleanColoredLayer_getTunnellablePoints(grid, outside, snakeN, color);
|
||||||
const chain = [snake0];
|
const chain = [snake0];
|
||||||
while (points.length) {
|
while (points.length) {
|
||||||
const path = getPathToNextPoint(grid, chain[0], color, points);
|
const path = getPathToNextPoint(grid, chain[0], color, points);
|
||||||
path.pop();
|
path.pop();
|
||||||
for (const snake of path)
|
for (const snake of path)
|
||||||
clearCleanColoredLayer_setEmptySafe(grid, (0,types_snake/* getHeadX */.If)(snake), (0,types_snake/* getHeadY */.IP)(snake));
|
clearCleanColoredLayer_setEmptySafe(grid, (0,types_snake/* getHeadX */.tN)(snake), (0,types_snake/* getHeadY */.Ap)(snake));
|
||||||
chain.unshift(...path);
|
chain.unshift(...path);
|
||||||
}
|
}
|
||||||
fillOutside(outside, grid);
|
fillOutside(outside, grid);
|
||||||
@@ -477,19 +476,19 @@ const getPathToNextPoint = (grid, snake0, color, points) => {
|
|||||||
const openList = [{ snake: snake0 }];
|
const openList = [{ snake: snake0 }];
|
||||||
while (openList.length) {
|
while (openList.length) {
|
||||||
const o = openList.shift();
|
const o = openList.shift();
|
||||||
const x = (0,types_snake/* getHeadX */.If)(o.snake);
|
const x = (0,types_snake/* getHeadX */.tN)(o.snake);
|
||||||
const y = (0,types_snake/* getHeadY */.IP)(o.snake);
|
const y = (0,types_snake/* getHeadY */.Ap)(o.snake);
|
||||||
const i = points.findIndex((p) => p.x === x && p.y === y);
|
const i = points.findIndex((p) => p.x === x && p.y === y);
|
||||||
if (i >= 0) {
|
if (i >= 0) {
|
||||||
points.splice(i, 1);
|
points.splice(i, 1);
|
||||||
return clearCleanColoredLayer_unwrap(o);
|
return clearCleanColoredLayer_unwrap(o);
|
||||||
}
|
}
|
||||||
for (const { x: dx, y: dy } of around4) {
|
for (const { x: dx, y: dy } of around4) {
|
||||||
if ((0,types_grid/* isInsideLarge */.HJ)(grid, 2, x + dx, y + dy) &&
|
if ((0,types_grid/* isInsideLarge */.Yd)(grid, 2, x + dx, y + dy) &&
|
||||||
!(0,types_snake/* snakeWillSelfCollide */.nJ)(o.snake, dx, dy) &&
|
!(0,types_snake/* snakeWillSelfCollide */.J)(o.snake, dx, dy) &&
|
||||||
clearCleanColoredLayer_getColorSafe(grid, x + dx, y + dy) <= color) {
|
clearCleanColoredLayer_getColorSafe(grid, x + dx, y + dy) <= color) {
|
||||||
const snake = (0,types_snake/* nextSnake */.kv)(o.snake, dx, dy);
|
const snake = (0,types_snake/* nextSnake */.Sc)(o.snake, dx, dy);
|
||||||
if (!closeList.some((s0) => (0,types_snake/* snakeEquals */.kE)(s0, snake))) {
|
if (!closeList.some((s0) => (0,types_snake/* snakeEquals */.sW)(s0, snake))) {
|
||||||
closeList.push(snake);
|
closeList.push(snake);
|
||||||
openList.push({ snake, parent: o });
|
openList.push({ snake, parent: o });
|
||||||
}
|
}
|
||||||
@@ -504,8 +503,8 @@ const clearCleanColoredLayer_getTunnellablePoints = (grid, outside, snakeN, colo
|
|||||||
const points = [];
|
const points = [];
|
||||||
for (let x = grid.width; x--;)
|
for (let x = grid.width; x--;)
|
||||||
for (let y = grid.height; y--;) {
|
for (let y = grid.height; y--;) {
|
||||||
const c = (0,types_grid/* getColor */.Lq)(grid, x, y);
|
const c = (0,types_grid/* getColor */.oU)(grid, x, y);
|
||||||
if (!(0,types_grid/* isEmpty */.xb)(c) &&
|
if (!(0,types_grid/* isEmpty */.Im)(c) &&
|
||||||
c <= color &&
|
c <= color &&
|
||||||
!points.some((p) => p.x === x && p.y === y)) {
|
!points.some((p) => p.x === x && p.y === y)) {
|
||||||
const tunnel = getBestTunnel(grid, outside, x, y, color, snakeN);
|
const tunnel = getBestTunnel(grid, outside, x, y, color, snakeN);
|
||||||
@@ -517,12 +516,12 @@ const clearCleanColoredLayer_getTunnellablePoints = (grid, outside, snakeN, colo
|
|||||||
}
|
}
|
||||||
return points;
|
return points;
|
||||||
};
|
};
|
||||||
const clearCleanColoredLayer_getColorSafe = (grid, x, y) => (0,types_grid/* isInside */.V0)(grid, x, y) ? (0,types_grid/* getColor */.Lq)(grid, x, y) : 0;
|
const clearCleanColoredLayer_getColorSafe = (grid, x, y) => (0,types_grid/* isInside */.FK)(grid, x, y) ? (0,types_grid/* getColor */.oU)(grid, x, y) : 0;
|
||||||
const clearCleanColoredLayer_setEmptySafe = (grid, x, y) => {
|
const clearCleanColoredLayer_setEmptySafe = (grid, x, y) => {
|
||||||
if ((0,types_grid/* isInside */.V0)(grid, x, y))
|
if ((0,types_grid/* isInside */.FK)(grid, x, y))
|
||||||
(0,types_grid/* setColorEmpty */.Dy)(grid, x, y);
|
(0,types_grid/* setColorEmpty */.l$)(grid, x, y);
|
||||||
};
|
};
|
||||||
const clearCleanColoredLayer_isEmptySafe = (grid, x, y) => !(0,types_grid/* isInside */.V0)(grid, x, y) && (0,types_grid/* isEmpty */.xb)((0,types_grid/* getColor */.Lq)(grid, x, y));
|
const clearCleanColoredLayer_isEmptySafe = (grid, x, y) => !(0,types_grid/* isInside */.FK)(grid, x, y) && (0,types_grid/* isEmpty */.Im)((0,types_grid/* getColor */.oU)(grid, x, y));
|
||||||
|
|
||||||
;// CONCATENATED MODULE: ../solver/getBestRoute.ts
|
;// CONCATENATED MODULE: ../solver/getBestRoute.ts
|
||||||
|
|
||||||
@@ -530,7 +529,7 @@ const clearCleanColoredLayer_isEmptySafe = (grid, x, y) => !(0,types_grid/* isIn
|
|||||||
|
|
||||||
|
|
||||||
const getBestRoute = (grid0, snake0) => {
|
const getBestRoute = (grid0, snake0) => {
|
||||||
const grid = (0,types_grid/* copyGrid */.VJ)(grid0);
|
const grid = (0,types_grid/* copyGrid */.mi)(grid0);
|
||||||
const outside = createOutside(grid);
|
const outside = createOutside(grid);
|
||||||
const chain = [snake0];
|
const chain = [snake0];
|
||||||
for (const color of extractColors(grid)) {
|
for (const color of extractColors(grid)) {
|
||||||
@@ -548,7 +547,7 @@ const extractColors = (grid) => {
|
|||||||
|
|
||||||
;// CONCATENATED MODULE: ../types/__fixtures__/snake.ts
|
;// CONCATENATED MODULE: ../types/__fixtures__/snake.ts
|
||||||
|
|
||||||
const create = (length) => (0,types_snake/* createSnakeFromCells */.xG)(Array.from({ length }, (_, i) => ({ x: i, y: -1 })));
|
const create = (length) => (0,types_snake/* createSnakeFromCells */.yS)(Array.from({ length }, (_, i) => ({ x: i, y: -1 })));
|
||||||
const snake1 = create(1);
|
const snake1 = create(1);
|
||||||
const snake3 = create(3);
|
const snake3 = create(3);
|
||||||
const snake4 = create(4);
|
const snake4 = create(4);
|
||||||
@@ -561,20 +560,20 @@ const snake9 = create(9);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const getPathToPose_isEmptySafe = (grid, x, y) => !(0,types_grid/* isInside */.V0)(grid, x, y) || (0,types_grid/* isEmpty */.xb)((0,types_grid/* getColor */.Lq)(grid, x, y));
|
const getPathToPose_isEmptySafe = (grid, x, y) => !(0,types_grid/* isInside */.FK)(grid, x, y) || (0,types_grid/* isEmpty */.Im)((0,types_grid/* getColor */.oU)(grid, x, y));
|
||||||
const getPathToPose = (snake0, target, grid) => {
|
const getPathToPose = (snake0, target, grid) => {
|
||||||
if ((0,types_snake/* snakeEquals */.kE)(snake0, target))
|
if ((0,types_snake/* snakeEquals */.sW)(snake0, target))
|
||||||
return [];
|
return [];
|
||||||
const targetCells = (0,types_snake/* snakeToCells */.Ks)(target).reverse();
|
const targetCells = (0,types_snake/* snakeToCells */.HU)(target).reverse();
|
||||||
const snakeN = (0,types_snake/* getSnakeLength */.JJ)(snake0);
|
const snakeN = (0,types_snake/* getSnakeLength */.T$)(snake0);
|
||||||
const box = {
|
const box = {
|
||||||
min: {
|
min: {
|
||||||
x: Math.min((0,types_snake/* getHeadX */.If)(snake0), (0,types_snake/* getHeadX */.If)(target)) - snakeN - 1,
|
x: Math.min((0,types_snake/* getHeadX */.tN)(snake0), (0,types_snake/* getHeadX */.tN)(target)) - snakeN - 1,
|
||||||
y: Math.min((0,types_snake/* getHeadY */.IP)(snake0), (0,types_snake/* getHeadY */.IP)(target)) - snakeN - 1,
|
y: Math.min((0,types_snake/* getHeadY */.Ap)(snake0), (0,types_snake/* getHeadY */.Ap)(target)) - snakeN - 1,
|
||||||
},
|
},
|
||||||
max: {
|
max: {
|
||||||
x: Math.max((0,types_snake/* getHeadX */.If)(snake0), (0,types_snake/* getHeadX */.If)(target)) + snakeN + 1,
|
x: Math.max((0,types_snake/* getHeadX */.tN)(snake0), (0,types_snake/* getHeadX */.tN)(target)) + snakeN + 1,
|
||||||
y: Math.max((0,types_snake/* getHeadY */.IP)(snake0), (0,types_snake/* getHeadY */.IP)(target)) + snakeN + 1,
|
y: Math.max((0,types_snake/* getHeadY */.Ap)(snake0), (0,types_snake/* getHeadY */.Ap)(target)) + snakeN + 1,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const [t0, ...forbidden] = targetCells;
|
const [t0, ...forbidden] = targetCells;
|
||||||
@@ -583,8 +582,8 @@ const getPathToPose = (snake0, target, grid) => {
|
|||||||
const closeList = [];
|
const closeList = [];
|
||||||
while (openList.length) {
|
while (openList.length) {
|
||||||
const o = openList.shift();
|
const o = openList.shift();
|
||||||
const x = (0,types_snake/* getHeadX */.If)(o.snake);
|
const x = (0,types_snake/* getHeadX */.tN)(o.snake);
|
||||||
const y = (0,types_snake/* getHeadY */.IP)(o.snake);
|
const y = (0,types_snake/* getHeadY */.Ap)(o.snake);
|
||||||
if (x === t0.x && y === t0.y) {
|
if (x === t0.x && y === t0.y) {
|
||||||
const path = [];
|
const path = [];
|
||||||
let e = o;
|
let e = o;
|
||||||
@@ -601,17 +600,17 @@ const getPathToPose = (snake0, target, grid) => {
|
|||||||
const { x: dx, y: dy } = around4[i];
|
const { x: dx, y: dy } = around4[i];
|
||||||
const nx = x + dx;
|
const nx = x + dx;
|
||||||
const ny = y + dy;
|
const ny = y + dy;
|
||||||
if (!(0,types_snake/* snakeWillSelfCollide */.nJ)(o.snake, dx, dy) &&
|
if (!(0,types_snake/* snakeWillSelfCollide */.J)(o.snake, dx, dy) &&
|
||||||
(!grid || getPathToPose_isEmptySafe(grid, nx, ny)) &&
|
(!grid || getPathToPose_isEmptySafe(grid, nx, ny)) &&
|
||||||
(grid
|
(grid
|
||||||
? (0,types_grid/* isInsideLarge */.HJ)(grid, 2, nx, ny)
|
? (0,types_grid/* isInsideLarge */.Yd)(grid, 2, nx, ny)
|
||||||
: box.min.x <= nx &&
|
: box.min.x <= nx &&
|
||||||
nx <= box.max.x &&
|
nx <= box.max.x &&
|
||||||
box.min.y <= ny &&
|
box.min.y <= ny &&
|
||||||
ny <= box.max.y) &&
|
ny <= box.max.y) &&
|
||||||
!forbidden.some((p) => p.x === nx && p.y === ny)) {
|
!forbidden.some((p) => p.x === nx && p.y === ny)) {
|
||||||
const snake = (0,types_snake/* nextSnake */.kv)(o.snake, dx, dy);
|
const snake = (0,types_snake/* nextSnake */.Sc)(o.snake, dx, dy);
|
||||||
if (!closeList.some((s) => (0,types_snake/* snakeEquals */.kE)(snake, s))) {
|
if (!closeList.some((s) => (0,types_snake/* snakeEquals */.sW)(snake, s))) {
|
||||||
const w = o.w + 1;
|
const w = o.w + 1;
|
||||||
const h = Math.abs(nx - x) + Math.abs(ny - y);
|
const h = Math.abs(nx - x) + Math.abs(ny - y);
|
||||||
const f = w + h;
|
const f = w + h;
|
||||||
@@ -644,12 +643,12 @@ const generateContributionSnake = async (userName, outputs, options) => {
|
|||||||
switch (format) {
|
switch (format) {
|
||||||
case "svg": {
|
case "svg": {
|
||||||
console.log(`🖌 creating svg (outputs[${i}])`);
|
console.log(`🖌 creating svg (outputs[${i}])`);
|
||||||
const { createSvg } = await __webpack_require__.e(/* import() */ 340).then(__webpack_require__.bind(__webpack_require__, 8340));
|
const { createSvg } = await __webpack_require__.e(/* import() */ 578).then(__webpack_require__.bind(__webpack_require__, 4578));
|
||||||
return createSvg(grid, cells, chain, drawOptions, animationOptions);
|
return createSvg(grid, cells, chain, drawOptions, animationOptions);
|
||||||
}
|
}
|
||||||
case "gif": {
|
case "gif": {
|
||||||
console.log(`📹 creating gif (outputs[${i}])`);
|
console.log(`📹 creating gif (outputs[${i}])`);
|
||||||
const { createGif } = await Promise.all(/* import() */[__webpack_require__.e(371), __webpack_require__.e(142)]).then(__webpack_require__.bind(__webpack_require__, 7142));
|
const { createGif } = await Promise.all(/* import() */[__webpack_require__.e(155), __webpack_require__.e(642)]).then(__webpack_require__.bind(__webpack_require__, 3642));
|
||||||
return await createGif(grid, cells, chain, drawOptions, animationOptions);
|
return await createGif(grid, cells, chain, drawOptions, animationOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -659,18 +658,18 @@ const generateContributionSnake = async (userName, outputs, options) => {
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 2881:
|
/***/ 105:
|
||||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||||
|
|
||||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||||
/* harmony export */ "Dy": () => (/* binding */ setColorEmpty),
|
/* harmony export */ FK: () => (/* binding */ isInside),
|
||||||
/* harmony export */ "HJ": () => (/* binding */ isInsideLarge),
|
/* harmony export */ Im: () => (/* binding */ isEmpty),
|
||||||
/* harmony export */ "Lq": () => (/* binding */ getColor),
|
/* harmony export */ Kb: () => (/* binding */ createEmptyGrid),
|
||||||
/* harmony export */ "V0": () => (/* binding */ isInside),
|
/* harmony export */ Yd: () => (/* binding */ isInsideLarge),
|
||||||
/* harmony export */ "VJ": () => (/* binding */ copyGrid),
|
/* harmony export */ l$: () => (/* binding */ setColorEmpty),
|
||||||
/* harmony export */ "u1": () => (/* binding */ createEmptyGrid),
|
/* harmony export */ mi: () => (/* binding */ copyGrid),
|
||||||
/* harmony export */ "vk": () => (/* binding */ setColor),
|
/* harmony export */ oU: () => (/* binding */ getColor),
|
||||||
/* harmony export */ "xb": () => (/* binding */ isEmpty)
|
/* harmony export */ wW: () => (/* binding */ setColor)
|
||||||
/* harmony export */ });
|
/* harmony export */ });
|
||||||
/* unused harmony exports isGridEmpty, gridEquals */
|
/* unused harmony exports isGridEmpty, gridEquals */
|
||||||
const isInside = (grid, x, y) => x >= 0 && y >= 0 && x < grid.width && y < grid.height;
|
const isInside = (grid, x, y) => x >= 0 && y >= 0 && x < grid.width && y < grid.height;
|
||||||
@@ -703,18 +702,18 @@ const createEmptyGrid = (width, height) => ({
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 9347:
|
/***/ 777:
|
||||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||||
|
|
||||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||||
/* harmony export */ "IP": () => (/* binding */ getHeadY),
|
/* harmony export */ Ap: () => (/* binding */ getHeadY),
|
||||||
/* harmony export */ "If": () => (/* binding */ getHeadX),
|
/* harmony export */ HU: () => (/* binding */ snakeToCells),
|
||||||
/* harmony export */ "JJ": () => (/* binding */ getSnakeLength),
|
/* harmony export */ J: () => (/* binding */ snakeWillSelfCollide),
|
||||||
/* harmony export */ "Ks": () => (/* binding */ snakeToCells),
|
/* harmony export */ Sc: () => (/* binding */ nextSnake),
|
||||||
/* harmony export */ "kE": () => (/* binding */ snakeEquals),
|
/* harmony export */ T$: () => (/* binding */ getSnakeLength),
|
||||||
/* harmony export */ "kv": () => (/* binding */ nextSnake),
|
/* harmony export */ sW: () => (/* binding */ snakeEquals),
|
||||||
/* harmony export */ "nJ": () => (/* binding */ snakeWillSelfCollide),
|
/* harmony export */ tN: () => (/* binding */ getHeadX),
|
||||||
/* harmony export */ "xG": () => (/* binding */ createSnakeFromCells)
|
/* harmony export */ yS: () => (/* binding */ createSnakeFromCells)
|
||||||
/* harmony export */ });
|
/* harmony export */ });
|
||||||
/* unused harmony export copySnake */
|
/* unused harmony export copySnake */
|
||||||
const getHeadX = (snake) => snake[0] - 2;
|
const getHeadX = (snake) => snake[0] - 2;
|
||||||
@@ -1,23 +1,21 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
exports.id = 340;
|
exports.id = 578;
|
||||||
exports.ids = [340];
|
exports.ids = [578];
|
||||||
exports.modules = {
|
exports.modules = {
|
||||||
|
|
||||||
/***/ 8340:
|
/***/ 4578:
|
||||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||||
|
|
||||||
// ESM COMPAT FLAG
|
|
||||||
__webpack_require__.r(__webpack_exports__);
|
|
||||||
|
|
||||||
// EXPORTS
|
// EXPORTS
|
||||||
__webpack_require__.d(__webpack_exports__, {
|
__webpack_require__.d(__webpack_exports__, {
|
||||||
"createSvg": () => (/* binding */ createSvg)
|
createSvg: () => (/* binding */ createSvg)
|
||||||
});
|
});
|
||||||
|
|
||||||
// EXTERNAL MODULE: ../types/grid.ts
|
// EXTERNAL MODULE: ../types/grid.ts
|
||||||
var types_grid = __webpack_require__(2881);
|
var types_grid = __webpack_require__(105);
|
||||||
// EXTERNAL MODULE: ../types/snake.ts
|
// EXTERNAL MODULE: ../types/snake.ts
|
||||||
var types_snake = __webpack_require__(9347);
|
var types_snake = __webpack_require__(777);
|
||||||
;// CONCATENATED MODULE: ../svg-creator/xml-utils.ts
|
;// CONCATENATED MODULE: ../svg-creator/xml-utils.ts
|
||||||
const h = (element, attributes) => `<${element} ${toAttribute(attributes)}/>`;
|
const h = (element, attributes) => `<${element} ${toAttribute(attributes)}/>`;
|
||||||
const toAttribute = (o) => Object.entries(o)
|
const toAttribute = (o) => Object.entries(o)
|
||||||
@@ -62,10 +60,10 @@ const minifyCss = (css) => css
|
|||||||
|
|
||||||
const lerp = (k, a, b) => (1 - k) * a + k * b;
|
const lerp = (k, a, b) => (1 - k) * a + k * b;
|
||||||
const createSnake = (chain, { sizeCell, sizeDot }, duration) => {
|
const createSnake = (chain, { sizeCell, sizeDot }, duration) => {
|
||||||
const snakeN = chain[0] ? (0,types_snake/* getSnakeLength */.JJ)(chain[0]) : 0;
|
const snakeN = chain[0] ? (0,types_snake/* getSnakeLength */.T$)(chain[0]) : 0;
|
||||||
const snakeParts = Array.from({ length: snakeN }, () => []);
|
const snakeParts = Array.from({ length: snakeN }, () => []);
|
||||||
for (const snake of chain) {
|
for (const snake of chain) {
|
||||||
const cells = (0,types_snake/* snakeToCells */.Ks)(snake);
|
const cells = (0,types_snake/* snakeToCells */.HU)(snake);
|
||||||
for (let i = cells.length; i--;)
|
for (let i = cells.length; i--;)
|
||||||
snakeParts[i].push(cells[i]);
|
snakeParts[i].push(cells[i]);
|
||||||
}
|
}
|
||||||
@@ -237,15 +235,15 @@ const createLivingCells = (grid0, chain, cells) => {
|
|||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
t: null,
|
t: null,
|
||||||
color: (0,types_grid/* getColor */.Lq)(grid0, x, y),
|
color: (0,types_grid/* getColor */.oU)(grid0, x, y),
|
||||||
}));
|
}));
|
||||||
const grid = (0,types_grid/* copyGrid */.VJ)(grid0);
|
const grid = (0,types_grid/* copyGrid */.mi)(grid0);
|
||||||
for (let i = 0; i < chain.length; i++) {
|
for (let i = 0; i < chain.length; i++) {
|
||||||
const snake = chain[i];
|
const snake = chain[i];
|
||||||
const x = (0,types_snake/* getHeadX */.If)(snake);
|
const x = (0,types_snake/* getHeadX */.tN)(snake);
|
||||||
const y = (0,types_snake/* getHeadY */.IP)(snake);
|
const y = (0,types_snake/* getHeadY */.Ap)(snake);
|
||||||
if ((0,types_grid/* isInside */.V0)(grid, x, y) && !(0,types_grid/* isEmpty */.xb)((0,types_grid/* getColor */.Lq)(grid, x, y))) {
|
if ((0,types_grid/* isInside */.FK)(grid, x, y) && !(0,types_grid/* isEmpty */.Im)((0,types_grid/* getColor */.oU)(grid, x, y))) {
|
||||||
(0,types_grid/* setColorEmpty */.Dy)(grid, x, y);
|
(0,types_grid/* setColorEmpty */.l$)(grid, x, y);
|
||||||
const cell = livingCells.find((c) => c.x === x && c.y === y);
|
const cell = livingCells.find((c) => c.x === x && c.y === y);
|
||||||
cell.t = i / chain.length;
|
cell.t = i / chain.length;
|
||||||
}
|
}
|
||||||
@@ -1,31 +1,29 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
exports.id = 142;
|
exports.id = 642;
|
||||||
exports.ids = [142];
|
exports.ids = [642];
|
||||||
exports.modules = {
|
exports.modules = {
|
||||||
|
|
||||||
/***/ 7142:
|
/***/ 3642:
|
||||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||||
|
|
||||||
// ESM COMPAT FLAG
|
|
||||||
__webpack_require__.r(__webpack_exports__);
|
|
||||||
|
|
||||||
// EXPORTS
|
// EXPORTS
|
||||||
__webpack_require__.d(__webpack_exports__, {
|
__webpack_require__.d(__webpack_exports__, {
|
||||||
"createGif": () => (/* binding */ createGif)
|
createGif: () => (/* binding */ createGif)
|
||||||
});
|
});
|
||||||
|
|
||||||
// EXTERNAL MODULE: external "fs"
|
// EXTERNAL MODULE: external "fs"
|
||||||
var external_fs_ = __webpack_require__(7147);
|
var external_fs_ = __webpack_require__(9896);
|
||||||
var external_fs_default = /*#__PURE__*/__webpack_require__.n(external_fs_);
|
var external_fs_default = /*#__PURE__*/__webpack_require__.n(external_fs_);
|
||||||
// EXTERNAL MODULE: external "path"
|
// EXTERNAL MODULE: external "path"
|
||||||
var external_path_ = __webpack_require__(1017);
|
var external_path_ = __webpack_require__(6928);
|
||||||
var external_path_default = /*#__PURE__*/__webpack_require__.n(external_path_);
|
var external_path_default = /*#__PURE__*/__webpack_require__.n(external_path_);
|
||||||
// EXTERNAL MODULE: external "child_process"
|
// EXTERNAL MODULE: external "child_process"
|
||||||
var external_child_process_ = __webpack_require__(2081);
|
var external_child_process_ = __webpack_require__(5317);
|
||||||
// EXTERNAL MODULE: external "canvas"
|
// EXTERNAL MODULE: external "canvas"
|
||||||
var external_canvas_ = __webpack_require__(1813);
|
var external_canvas_ = __webpack_require__(9919);
|
||||||
// EXTERNAL MODULE: ../types/grid.ts
|
// EXTERNAL MODULE: ../types/grid.ts
|
||||||
var types_grid = __webpack_require__(2881);
|
var types_grid = __webpack_require__(105);
|
||||||
;// CONCATENATED MODULE: ../draw/pathRoundedRect.ts
|
;// CONCATENATED MODULE: ../draw/pathRoundedRect.ts
|
||||||
const pathRoundedRect_pathRoundedRect = (ctx, width, height, borderRadius) => {
|
const pathRoundedRect_pathRoundedRect = (ctx, width, height, borderRadius) => {
|
||||||
ctx.moveTo(borderRadius, 0);
|
ctx.moveTo(borderRadius, 0);
|
||||||
@@ -42,7 +40,7 @@ const drawGrid_drawGrid = (ctx, grid, cells, o) => {
|
|||||||
for (let x = grid.width; x--;)
|
for (let x = grid.width; x--;)
|
||||||
for (let y = grid.height; y--;) {
|
for (let y = grid.height; y--;) {
|
||||||
if (!cells || cells.some((c) => c.x === x && c.y === y)) {
|
if (!cells || cells.some((c) => c.x === x && c.y === y)) {
|
||||||
const c = (0,types_grid/* getColor */.Lq)(grid, x, y);
|
const c = (0,types_grid/* getColor */.oU)(grid, x, y);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const color = !c ? o.colorEmpty : o.colorDots[c];
|
const color = !c ? o.colorEmpty : o.colorDots[c];
|
||||||
ctx.save();
|
ctx.save();
|
||||||
@@ -144,27 +142,27 @@ const getCanvasWorldSize = (grid, o) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// EXTERNAL MODULE: ../types/snake.ts
|
// EXTERNAL MODULE: ../types/snake.ts
|
||||||
var types_snake = __webpack_require__(9347);
|
var types_snake = __webpack_require__(777);
|
||||||
;// CONCATENATED MODULE: ../solver/step.ts
|
;// CONCATENATED MODULE: ../solver/step.ts
|
||||||
|
|
||||||
|
|
||||||
const step = (grid, stack, snake) => {
|
const step = (grid, stack, snake) => {
|
||||||
const x = (0,types_snake/* getHeadX */.If)(snake);
|
const x = (0,types_snake/* getHeadX */.tN)(snake);
|
||||||
const y = (0,types_snake/* getHeadY */.IP)(snake);
|
const y = (0,types_snake/* getHeadY */.Ap)(snake);
|
||||||
const color = (0,types_grid/* getColor */.Lq)(grid, x, y);
|
const color = (0,types_grid/* getColor */.oU)(grid, x, y);
|
||||||
if ((0,types_grid/* isInside */.V0)(grid, x, y) && !(0,types_grid/* isEmpty */.xb)(color)) {
|
if ((0,types_grid/* isInside */.FK)(grid, x, y) && !(0,types_grid/* isEmpty */.Im)(color)) {
|
||||||
stack.push(color);
|
stack.push(color);
|
||||||
(0,types_grid/* setColorEmpty */.Dy)(grid, x, y);
|
(0,types_grid/* setColorEmpty */.l$)(grid, x, y);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// EXTERNAL MODULE: ../../node_modules/tmp/lib/tmp.js
|
// EXTERNAL MODULE: ../../node_modules/tmp/lib/tmp.js
|
||||||
var tmp = __webpack_require__(6382);
|
var tmp = __webpack_require__(2644);
|
||||||
// EXTERNAL MODULE: external "gifsicle"
|
// EXTERNAL MODULE: external "gifsicle"
|
||||||
var external_gifsicle_ = __webpack_require__(542);
|
var external_gifsicle_ = __webpack_require__(5667);
|
||||||
var external_gifsicle_default = /*#__PURE__*/__webpack_require__.n(external_gifsicle_);
|
var external_gifsicle_default = /*#__PURE__*/__webpack_require__.n(external_gifsicle_);
|
||||||
// EXTERNAL MODULE: ../../node_modules/gif-encoder-2/index.js
|
// EXTERNAL MODULE: ../../node_modules/gif-encoder-2/index.js
|
||||||
var gif_encoder_2 = __webpack_require__(3561);
|
var gif_encoder_2 = __webpack_require__(1680);
|
||||||
var gif_encoder_2_default = /*#__PURE__*/__webpack_require__.n(gif_encoder_2);
|
var gif_encoder_2_default = /*#__PURE__*/__webpack_require__.n(gif_encoder_2);
|
||||||
;// CONCATENATED MODULE: ../gif-creator/index.ts
|
;// CONCATENATED MODULE: ../gif-creator/index.ts
|
||||||
|
|
||||||
@@ -193,7 +191,7 @@ const createGif = async (grid0, cells, chain, drawOptions, animationOptions) =>
|
|||||||
const { width, height } = getCanvasWorldSize(grid0, drawOptions);
|
const { width, height } = getCanvasWorldSize(grid0, drawOptions);
|
||||||
const canvas = (0,external_canvas_.createCanvas)(width, height);
|
const canvas = (0,external_canvas_.createCanvas)(width, height);
|
||||||
const ctx = canvas.getContext("2d");
|
const ctx = canvas.getContext("2d");
|
||||||
const grid = (0,types_grid/* copyGrid */.VJ)(grid0);
|
const grid = (0,types_grid/* copyGrid */.mi)(grid0);
|
||||||
const stack = [];
|
const stack = [];
|
||||||
const encoder = new (gif_encoder_2_default())(width, height, "neuquant", true);
|
const encoder = new (gif_encoder_2_default())(width, height, "neuquant", true);
|
||||||
encoder.setRepeat(0);
|
encoder.setRepeat(0);
|
||||||
@@ -223,7 +221,7 @@ const createGif = async (grid0, cells, chain, drawOptions, animationOptions) =>
|
|||||||
outFileName,
|
outFileName,
|
||||||
["--output", optimizedFileName],
|
["--output", optimizedFileName],
|
||||||
].flat());
|
].flat());
|
||||||
return external_fs_default().readFileSync(optimizedFileName);
|
return new Uint8Array(external_fs_default().readFileSync(optimizedFileName));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
3809
svg-only/dist/index.js
vendored
3809
svg-only/dist/index.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user