🚀 optimize
This commit is contained in:
1
.github/workflows/main.yml
vendored
1
.github/workflows/main.yml
vendored
@@ -7,6 +7,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- run: sudo apt-get install gifsicle graphicsmagick
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- uses: actions/setup-node@v1
|
- uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const drawOptions = {
|
|||||||
|
|
||||||
const gameOptions = { maxSnakeLength: 5 };
|
const gameOptions = { maxSnakeLength: 5 };
|
||||||
|
|
||||||
const gifOptions = { delay: 100 };
|
const gifOptions = { delay: 20 };
|
||||||
|
|
||||||
const grid = generateGrid(42, 7, { colors: [1, 2, 3, 4], emptyP: 3 });
|
const grid = generateGrid(42, 7, { colors: [1, 2, 3, 4], emptyP: 3 });
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ export const createGif = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
const outFileName = path.join(dir, "out.gif");
|
const outFileName = path.join(dir, "out.gif");
|
||||||
|
const optimizedFileName = path.join(dir, "out.optimized.gif");
|
||||||
|
|
||||||
await execa(
|
await execa(
|
||||||
"gm",
|
"gm",
|
||||||
@@ -74,7 +75,17 @@ export const createGif = async (
|
|||||||
].flat()
|
].flat()
|
||||||
);
|
);
|
||||||
|
|
||||||
return fs.readFileSync(outFileName);
|
await execa(
|
||||||
|
"gifsicle",
|
||||||
|
[
|
||||||
|
//
|
||||||
|
"--optimize=3",
|
||||||
|
outFileName,
|
||||||
|
["--output", optimizedFileName],
|
||||||
|
].flat()
|
||||||
|
);
|
||||||
|
|
||||||
|
return fs.readFileSync(optimizedFileName);
|
||||||
} finally {
|
} finally {
|
||||||
cleanUp();
|
cleanUp();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user