pacman-contribution-graph 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -95,6 +95,15 @@ const drawPacman = (store) => {
95
95
  store.config.canvas.getContext('2d').lineTo(x, y);
96
96
  store.config.canvas.getContext('2d').fill();
97
97
  };
98
+ const preloadedImages = {};
99
+ const getLoadedImage = (key, imgDate) => {
100
+ if (!preloadedImages[key]) {
101
+ const image = new Image();
102
+ image.src = imgDate;
103
+ preloadedImages[key] = image;
104
+ }
105
+ return preloadedImages[key];
106
+ };
98
107
  const drawGhosts = (store) => {
99
108
  store.ghosts.forEach((ghost) => {
100
109
  const x = ghost.y * (_constants__WEBPACK_IMPORTED_MODULE_0__.CELL_SIZE + _constants__WEBPACK_IMPORTED_MODULE_0__.GAP_SIZE);
@@ -102,10 +111,10 @@ const drawGhosts = (store) => {
102
111
  const size = _constants__WEBPACK_IMPORTED_MODULE_0__.CELL_SIZE;
103
112
  const ctx = store.config.canvas.getContext('2d');
104
113
  if (ghost.scared) {
105
- ctx.drawImage(_constants__WEBPACK_IMPORTED_MODULE_0__.GHOSTS['scared'].img, x, y, size, size);
114
+ ctx.drawImage(getLoadedImage('scared', _constants__WEBPACK_IMPORTED_MODULE_0__.GHOSTS['scared'].imgDate), x, y, size, size);
106
115
  }
107
116
  else {
108
- ctx.drawImage(_constants__WEBPACK_IMPORTED_MODULE_0__.GHOSTS[ghost.name].img, x, y, size, size);
117
+ ctx.drawImage(getLoadedImage(ghost.name, _constants__WEBPACK_IMPORTED_MODULE_0__.GHOSTS[ghost.name].imgDate), x, y, size, size);
109
118
  }
110
119
  });
111
120
  };
@@ -213,7 +222,7 @@ const PACMAN_COLOR_POWERUP = 'red';
213
222
  const PACMAN_COLOR_DEAD = '#80808064';
214
223
  const GHOST_NAMES = ['blinky', 'clyde', 'inky', 'pinky'];
215
224
  const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
216
- const DELTA_TIME = 250;
225
+ const DELTA_TIME = 200;
217
226
  const PACMAN_DEATH_DURATION = 10;
218
227
  const PACMAN_POWERUP_DURATION = 15;
219
228
  const GAME_THEMES = {
@@ -244,24 +253,19 @@ const GAME_THEMES = {
244
253
  };
245
254
  const GHOSTS = {
246
255
  blinky: {
247
- imgDate: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAfUlEQVQ4T+2TUQ7AIAhDy/0PzQIRAqxmLtnn/DJPWypBAVkKKOMCyOQN7IRElLrcnIrDLNK4wVtxNbkb6Hq+jOcSbim6QVzKEstkw92gxVeFrMpqokix4wA+NvCOnvfArvcEbHoe2G9QmmhDMUc65p3xYC6q3zQPxtdl3NgF5QpL/b/rs3IAAAAASUVORK5CYIIA',
248
- img: new Image()
256
+ imgDate: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAfUlEQVQ4T+2TUQ7AIAhDy/0PzQIRAqxmLtnn/DJPWypBAVkKKOMCyOQN7IRElLrcnIrDLNK4wVtxNbkb6Hq+jOcSbim6QVzKEstkw92gxVeFrMpqokix4wA+NvCOnvfArvcEbHoe2G9QmmhDMUc65p3xYC6q3zQPxtdl3NgF5QpL/b/rs3IAAAAASUVORK5CYIIA'
249
257
  },
250
258
  clyde: {
251
- imgDate: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAgUlEQVQ4T+2T0Q6AIAhFLx9sH1MfTIPCAeLKrcd8PHqP4JBQLN7BFacNlHkAs+AQcqIueBs2mVWjgtWwl4yCdrd/pHYLLlVEgR2yK0wy4SoI5TcGXU4wM+AEJQfwsUCuXngDOR4rqKbngf0C94gyFHmkbd4rbkxD/pv2jfR1Ky7sBNrzXbHpnBX+AAAAAElFTkSuQmCC',
252
- img: new Image()
259
+ imgDate: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAgUlEQVQ4T+2T0Q6AIAhFLx9sH1MfTIPCAeLKrcd8PHqP4JBQLN7BFacNlHkAs+AQcqIueBs2mVWjgtWwl4yCdrd/pHYLLlVEgR2yK0wy4SoI5TcGXU4wM+AEJQfwsUCuXngDOR4rqKbngf0C94gyFHmkbd4rbkxD/pv2jfR1Ky7sBNrzXbHpnBX+AAAAAElFTkSuQmCC'
253
260
  },
254
261
  inky: {
255
- imgDate: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAg0lEQVQ4T+WTWxKAIAhFuQvK/a+jFoT5QAVxypn+6vMEx6sDIO/jk12OAMs1WDVOXV3UBW+bRVbTFMFu8yCZBExH/g26VHCXI0AJpKgdUCUrTlkwxE+FECdzS7HiJemXgvyeO29gE7jD8wDVFX4vSLNtR1q2z+OVlaZxTaXYrq7HbxYBS8VgMVrqzkEAAAAASUVORK5CYIIA',
256
- img: new Image()
262
+ imgDate: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAg0lEQVQ4T+WTWxKAIAhFuQvK/a+jFoT5QAVxypn+6vMEx6sDIO/jk12OAMs1WDVOXV3UBW+bRVbTFMFu8yCZBExH/g26VHCXI0AJpKgdUCUrTlkwxE+FECdzS7HiJemXgvyeO29gE7jD8wDVFX4vSLNtR1q2z+OVlaZxTaXYrq7HbxYBS8VgMVrqzkEAAAAASUVORK5CYIIA'
257
263
  },
258
264
  pinky: {
259
- imgDate: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAhklEQVQ4T+2T0Q2AIAwF281wC50Qt9DNagoptqVESfyUz4N3vJCCECxaD4o47gt6bsAo2IWUqAnehkUmbYpgNqwlvSCnur+dtnnAuYUVyCGJimTAi8DUzwmwOoGI7hYjDgAfC/jqiTfg47ZBND0P7BeoR+Sh8CMt8x5xYSWkv2nbcF834swuA/9u49Yy5bgAAAAASUVORK5CYIIA',
260
- img: new Image()
265
+ imgDate: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAhklEQVQ4T+2T0Q2AIAwF281wC50Qt9DNagoptqVESfyUz4N3vJCCECxaD4o47gt6bsAo2IWUqAnehkUmbYpgNqwlvSCnur+dtnnAuYUVyCGJimTAi8DUzwmwOoGI7hYjDgAfC/jqiTfg47ZBND0P7BeoR+Sh8CMt8x5xYSWkv2nbcF834swuA/9u49Yy5bgAAAAASUVORK5CYIIA'
261
266
  },
262
267
  scared: {
263
- imgDate: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAeUlEQVQ4T82TUQ6AMAhD7UX0/sdyF0GREVmDmTN+bH9r6Bs0A0t2VpFULwDrrfBkZFcA3YC3ZodViAFGzQHyP0B2w2NrB0/1AoDbHwLoQ5/nrw1OBuD5e/crbM9Aiz35njHWzpSB/m3+0r40mV41M8U19WJe3Uw/tQOKt08pUUbBEQAAAABJRU5ErkJgggAA',
264
- img: new Image()
268
+ imgDate: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAeUlEQVQ4T82TUQ6AMAhD7UX0/sdyF0GREVmDmTN+bH9r6Bs0A0t2VpFULwDrrfBkZFcA3YC3ZodViAFGzQHyP0B2w2NrB0/1AoDbHwLoQ5/nrw1OBuD5e/crbM9Aiz35njHWzpSB/m3+0r40mV41M8U19WJe3Uw/tQOKt08pUUbBEQAAAABJRU5ErkJgggAA'
265
269
  }
266
270
  };
267
271
 
@@ -393,11 +397,6 @@ const startGame = (store) => __awaiter(void 0, void 0, void 0, function* () {
393
397
  placePacman(store);
394
398
  placeGhosts(store);
395
399
  }
396
- _constants__WEBPACK_IMPORTED_MODULE_1__.GHOSTS.blinky.img.src = _constants__WEBPACK_IMPORTED_MODULE_1__.GHOSTS.blinky.imgDate;
397
- _constants__WEBPACK_IMPORTED_MODULE_1__.GHOSTS.clyde.img.src = _constants__WEBPACK_IMPORTED_MODULE_1__.GHOSTS.clyde.imgDate;
398
- _constants__WEBPACK_IMPORTED_MODULE_1__.GHOSTS.inky.img.src = _constants__WEBPACK_IMPORTED_MODULE_1__.GHOSTS.inky.imgDate;
399
- _constants__WEBPACK_IMPORTED_MODULE_1__.GHOSTS.pinky.img.src = _constants__WEBPACK_IMPORTED_MODULE_1__.GHOSTS.pinky.imgDate;
400
- _constants__WEBPACK_IMPORTED_MODULE_1__.GHOSTS.scared.img.src = _constants__WEBPACK_IMPORTED_MODULE_1__.GHOSTS.scared.imgDate;
401
400
  if (store.config.outputFormat == 'svg') {
402
401
  while (remainingCells()) {
403
402
  yield updateGame(store);
@@ -804,7 +803,7 @@ const generateAnimatedSVG = (store) => {
804
803
  const svgWidth = _constants__WEBPACK_IMPORTED_MODULE_0__.GRID_WIDTH * (_constants__WEBPACK_IMPORTED_MODULE_0__.CELL_SIZE + _constants__WEBPACK_IMPORTED_MODULE_0__.GAP_SIZE);
805
804
  const svgHeight = _constants__WEBPACK_IMPORTED_MODULE_0__.GRID_HEIGHT * (_constants__WEBPACK_IMPORTED_MODULE_0__.CELL_SIZE + _constants__WEBPACK_IMPORTED_MODULE_0__.GAP_SIZE) + 20;
806
805
  let svg = `<svg width="${svgWidth}" height="${svgHeight}" xmlns="http://www.w3.org/2000/svg">`;
807
- svg += `<desc>Generated with https://github.com/abozanona/pacman-contribution-graph</desc>`;
806
+ svg += `<desc>Generated with https://github.com/abozanona/pacman-contribution-graph on ${new Date()}</desc>`;
808
807
  svg += `<rect width="100%" height="100%" fill="${_utils__WEBPACK_IMPORTED_MODULE_1__.Utils.getCurrentTheme(store).gridBackground}"/>`;
809
808
  svg += generateGhostsPredefinition();
810
809
  // Month labels
@@ -823,38 +822,42 @@ const generateAnimatedSVG = (store) => {
823
822
  const cellY = x * (_constants__WEBPACK_IMPORTED_MODULE_0__.CELL_SIZE + _constants__WEBPACK_IMPORTED_MODULE_0__.GAP_SIZE) + 15;
824
823
  const intensity = store.gameHistory[0].grid[x][y];
825
824
  const color = intensity > 0 ? getContributionColor(store, intensity) : _utils__WEBPACK_IMPORTED_MODULE_1__.Utils.getCurrentTheme(store).emptyContributionBoxColor;
826
- svg += `<rect id="cell-${x}-${y}" x="${cellX}" y="${cellY}" width="${_constants__WEBPACK_IMPORTED_MODULE_0__.CELL_SIZE}" height="${_constants__WEBPACK_IMPORTED_MODULE_0__.CELL_SIZE}" rx="5" fill="${color}">
827
- <animate attributeName="fill" dur="${store.gameHistory.length * 300}ms" repeatCount="indefinite"
828
- values="${generateCellColorValues(store, x, y)}"
829
- keyTimes="${generateKeyTimes(store)}"/>
825
+ const cellColorAnimation = generateChangingValuesAnimation(store, generateCellColorValues(store, x, y));
826
+ svg += `<rect id="c-${x}-${y}" x="${cellX}" y="${cellY}" width="${_constants__WEBPACK_IMPORTED_MODULE_0__.CELL_SIZE}" height="${_constants__WEBPACK_IMPORTED_MODULE_0__.CELL_SIZE}" rx="5" fill="${color}">
827
+ <animate attributeName="fill" dur="${store.gameHistory.length * _constants__WEBPACK_IMPORTED_MODULE_0__.DELTA_TIME}ms" repeatCount="indefinite"
828
+ values="${cellColorAnimation.values}"
829
+ keyTimes="${cellColorAnimation.keyTimes}"/>
830
830
  </rect>`;
831
831
  }
832
832
  }
833
833
  // Pacman
834
- svg += `<path id="pacman" d="${generatePacManPath(0.35)}"
834
+ const pacmanColorAnimation = generateChangingValuesAnimation(store, generatePacManColors(store));
835
+ const pacmanPositionAnimation = generateChangingValuesAnimation(store, generatePacManPositions(store));
836
+ svg += `<path id="pacman" d="${generatePacManPath(0.55)}"
835
837
  transform="translate(${store.pacman.y * (_constants__WEBPACK_IMPORTED_MODULE_0__.CELL_SIZE + _constants__WEBPACK_IMPORTED_MODULE_0__.GAP_SIZE)}, ${store.pacman.x * (_constants__WEBPACK_IMPORTED_MODULE_0__.CELL_SIZE + _constants__WEBPACK_IMPORTED_MODULE_0__.GAP_SIZE) + 15})">
836
- <animate attributeName="fill" dur="${store.gameHistory.length * 300}ms" repeatCount="indefinite"
837
- keyTimes="${generateKeyTimes(store)}"
838
- values="${generatePacManColors(store)}"/>
839
- <animateTransform attributeName="transform" type="translate" dur="${store.gameHistory.length * 300}ms" repeatCount="indefinite"
840
- keyTimes="${generateKeyTimes(store)}"
841
- values="${generatePacManPositions(store)}"/>
842
- <animate attributeName="d" dur="0.2s" repeatCount="indefinite"
843
- values="${generatePacManPath(0.25)};${generatePacManPath(0.05)};${generatePacManPath(0.25)}"/>
838
+ <animate attributeName="fill" dur="${store.gameHistory.length * _constants__WEBPACK_IMPORTED_MODULE_0__.DELTA_TIME}ms" repeatCount="indefinite"
839
+ keyTimes="${pacmanColorAnimation.keyTimes}"
840
+ values="${pacmanColorAnimation.values}"/>
841
+ <animateTransform attributeName="transform" type="translate" dur="${store.gameHistory.length * _constants__WEBPACK_IMPORTED_MODULE_0__.DELTA_TIME}ms" repeatCount="indefinite"
842
+ keyTimes="${pacmanPositionAnimation.keyTimes}"
843
+ values="${pacmanPositionAnimation.values}"/>
844
+ <animate attributeName="d" dur="0.5s" repeatCount="indefinite"
845
+ values="${generatePacManPath(0.55)};${generatePacManPath(0.05)};${generatePacManPath(0.55)}"/>
844
846
  </path>`;
845
847
  // Ghosts
846
848
  store.ghosts.forEach((ghost, index) => {
849
+ const ghostPositionAnimation = generateChangingValuesAnimation(store, generateGhostPositions(store, index));
850
+ const ghostColorAnimation = generateChangingValuesAnimation(store, generateGhostColors(store, index));
847
851
  svg += `<use id="ghost${index}" width="${_constants__WEBPACK_IMPORTED_MODULE_0__.CELL_SIZE}" height="${_constants__WEBPACK_IMPORTED_MODULE_0__.CELL_SIZE}" href="#ghost-${ghost.name}">
848
- <animateTransform attributeName="transform" type="translate" dur="${store.gameHistory.length * 300}ms" repeatCount="indefinite"
849
- keyTimes="${generateKeyTimes(store)}"
850
- values="${generateGhostPositions(store, index)}"/>
851
- <animate attributeName="href" dur="${store.gameHistory.length * 300}ms" repeatCount="indefinite"
852
- keyTimes="${generateKeyTimes(store)}"
853
- values="${generateGhostColors(store, index)}"/>
852
+ <animateTransform attributeName="transform" type="translate" dur="${store.gameHistory.length * _constants__WEBPACK_IMPORTED_MODULE_0__.DELTA_TIME}ms" repeatCount="indefinite"
853
+ keyTimes="${ghostPositionAnimation.keyTimes}"
854
+ values="${ghostPositionAnimation.values}"/>
855
+ <animate attributeName="href" dur="${store.gameHistory.length * _constants__WEBPACK_IMPORTED_MODULE_0__.DELTA_TIME}ms" repeatCount="indefinite"
856
+ keyTimes="${ghostColorAnimation.keyTimes}"
857
+ values="${ghostColorAnimation.values}"/>
854
858
  </use>`;
855
859
  });
856
860
  svg += '</svg>';
857
- // TODO: minify SVG
858
861
  return svg;
859
862
  };
860
863
  const generatePacManPath = (mouthAngle) => {
@@ -866,21 +869,15 @@ const generatePacManPath = (mouthAngle) => {
866
869
  A ${radius},${radius} 0 1,1 ${radius + radius * Math.cos(endAngle)},${radius + radius * Math.sin(endAngle)}
867
870
  Z`;
868
871
  };
869
- const generateKeyTimes = (store) => {
870
- return store.gameHistory.map((_, index) => index / (store.gameHistory.length - 1)).join(';');
871
- };
872
872
  const generatePacManPositions = (store) => {
873
- return store.gameHistory
874
- .map((state) => {
873
+ return store.gameHistory.map((state) => {
875
874
  const x = state.pacman.y * (_constants__WEBPACK_IMPORTED_MODULE_0__.CELL_SIZE + _constants__WEBPACK_IMPORTED_MODULE_0__.GAP_SIZE);
876
875
  const y = state.pacman.x * (_constants__WEBPACK_IMPORTED_MODULE_0__.CELL_SIZE + _constants__WEBPACK_IMPORTED_MODULE_0__.GAP_SIZE) + 15;
877
876
  return `${x},${y}`;
878
- })
879
- .join(';');
877
+ });
880
878
  };
881
879
  const generatePacManColors = (store) => {
882
- return store.gameHistory
883
- .map((state) => {
880
+ return store.gameHistory.map((state) => {
884
881
  if (state.pacman.deadRemainingDuration) {
885
882
  return _constants__WEBPACK_IMPORTED_MODULE_0__.PACMAN_COLOR_DEAD;
886
883
  }
@@ -890,58 +887,98 @@ const generatePacManColors = (store) => {
890
887
  else {
891
888
  return _constants__WEBPACK_IMPORTED_MODULE_0__.PACMAN_COLOR;
892
889
  }
893
- })
894
- .join(';');
890
+ });
895
891
  };
896
892
  const generateCellColorValues = (store, x, y) => {
897
- return store.gameHistory
898
- .map((state) => {
893
+ return store.gameHistory.map((state) => {
899
894
  const intensity = state.grid[x][y];
900
895
  return intensity > 0 ? getContributionColor(store, intensity) : _utils__WEBPACK_IMPORTED_MODULE_1__.Utils.getCurrentTheme(store).emptyContributionBoxColor;
901
- })
902
- .join(';');
896
+ });
903
897
  };
904
898
  const getContributionColor = (store, intensity) => {
905
899
  const adjustedIntensity = intensity < 0.2 ? 0.3 : intensity;
906
- return _utils__WEBPACK_IMPORTED_MODULE_1__.Utils.hexToRGBA(_utils__WEBPACK_IMPORTED_MODULE_1__.Utils.getCurrentTheme(store).contributionBoxColor, adjustedIntensity);
900
+ return _utils__WEBPACK_IMPORTED_MODULE_1__.Utils.hexToHexAlpha(_utils__WEBPACK_IMPORTED_MODULE_1__.Utils.getCurrentTheme(store).contributionBoxColor, adjustedIntensity);
907
901
  };
908
902
  const generateGhostPositions = (store, ghostIndex) => {
909
- return store.gameHistory
910
- .map((state) => {
903
+ return store.gameHistory.map((state) => {
911
904
  const ghost = state.ghosts[ghostIndex];
912
905
  const x = ghost.y * (_constants__WEBPACK_IMPORTED_MODULE_0__.CELL_SIZE + _constants__WEBPACK_IMPORTED_MODULE_0__.GAP_SIZE);
913
906
  const y = ghost.x * (_constants__WEBPACK_IMPORTED_MODULE_0__.CELL_SIZE + _constants__WEBPACK_IMPORTED_MODULE_0__.GAP_SIZE) + 15;
914
907
  return `${x},${y}`;
915
- })
916
- .join(';');
908
+ });
917
909
  };
918
910
  const generateGhostColors = (store, ghostIndex) => {
919
- return store.gameHistory
920
- .map((state) => {
911
+ return store.gameHistory.map((state) => {
921
912
  const ghost = state.ghosts[ghostIndex];
922
- return ghost.scared ? '#scared' : '#' + ghost.name;
923
- })
924
- .join(';');
913
+ return '#' + (ghost.scared ? ghostShort('scared') : ghostShort(ghost.name));
914
+ });
925
915
  };
926
916
  const generateGhostsPredefinition = () => {
927
917
  return `<defs>
928
- <symbol id="blinky" viewBox="0 0 100 100">
918
+ <symbol id="${ghostShort('blinky')}" viewBox="0 0 100 100">
929
919
  <image href="${_constants__WEBPACK_IMPORTED_MODULE_0__.GHOSTS['blinky'].imgDate}" width="100" height="100"/>
930
920
  </symbol>
931
- <symbol id="clyde" viewBox="0 0 100 100">
921
+ <symbol id="${ghostShort('clyde')}" viewBox="0 0 100 100">
932
922
  <image href="${_constants__WEBPACK_IMPORTED_MODULE_0__.GHOSTS['clyde'].imgDate}" width="100" height="100"/>
933
923
  </symbol>
934
- <symbol id="inky" viewBox="0 0 100 100">
924
+ <symbol id="${ghostShort('inky')}" viewBox="0 0 100 100">
935
925
  <image href="${_constants__WEBPACK_IMPORTED_MODULE_0__.GHOSTS['inky'].imgDate}" width="100" height="100"/>
936
926
  </symbol>
937
- <symbol id="pinky" viewBox="0 0 100 100">
927
+ <symbol id="${ghostShort('pinky')}" viewBox="0 0 100 100">
938
928
  <image href="${_constants__WEBPACK_IMPORTED_MODULE_0__.GHOSTS['pinky'].imgDate}" width="100" height="100"/>
939
929
  </symbol>
940
- <symbol id="scared" viewBox="0 0 100 100">
930
+ <symbol id="${ghostShort('scared')}" viewBox="0 0 100 100">
941
931
  <image href="${_constants__WEBPACK_IMPORTED_MODULE_0__.GHOSTS['scared'].imgDate}" width="100" height="100"/>
942
932
  </symbol>
943
933
  </defs>`;
944
934
  };
935
+ const ghostShort = (ghostName) => {
936
+ switch (ghostName) {
937
+ case 'blinky':
938
+ return 'gb';
939
+ case 'clyde':
940
+ return 'gc';
941
+ case 'inky':
942
+ return 'gi';
943
+ case 'pinky':
944
+ return 'gp';
945
+ case 'scared':
946
+ return 'gs';
947
+ default:
948
+ return ghostName;
949
+ }
950
+ };
951
+ const generateChangingValuesAnimation = (store, changingValues) => {
952
+ if (store.gameHistory.length !== changingValues.length) {
953
+ throw new Error('The length of changingValues must match the length of gameHistory');
954
+ }
955
+ const totalFrames = store.gameHistory.length;
956
+ let keyTimes = [];
957
+ let values = [];
958
+ let lastValue = null;
959
+ changingValues.forEach((currentValue, index) => {
960
+ if (currentValue !== lastValue) {
961
+ if (lastValue !== null) {
962
+ // Add a keyframe right before the color change
963
+ keyTimes.push(Number(((index - 0.000001) / (totalFrames - 1)).toFixed(6)));
964
+ values.push(lastValue);
965
+ }
966
+ // Add the new color keyframe
967
+ keyTimes.push(Number((index / (totalFrames - 1)).toFixed(6)));
968
+ values.push(currentValue);
969
+ lastValue = currentValue;
970
+ }
971
+ });
972
+ // Ensure the last frame is always included
973
+ if (keyTimes[keyTimes.length - 1] !== 1) {
974
+ keyTimes.push(1);
975
+ values.push(lastValue);
976
+ }
977
+ return {
978
+ keyTimes: keyTimes.join(';'),
979
+ values: values.join(';')
980
+ };
981
+ };
945
982
  const SVG = {
946
983
  generateAnimatedSVG
947
984
  };
@@ -1016,17 +1053,28 @@ const getCurrentTheme = (store) => {
1016
1053
  var _a;
1017
1054
  return (_a = _constants__WEBPACK_IMPORTED_MODULE_0__.GAME_THEMES[store.config.gameTheme]) !== null && _a !== void 0 ? _a : _constants__WEBPACK_IMPORTED_MODULE_0__.GAME_THEMES['github'];
1018
1055
  };
1019
- function hexToRGBA(hex, alpha) {
1056
+ const hexToRGBA = (hex, alpha) => {
1020
1057
  const r = parseInt(hex.slice(1, 3), 16);
1021
1058
  const g = parseInt(hex.slice(3, 5), 16);
1022
1059
  const b = parseInt(hex.slice(5, 7), 16);
1023
1060
  return `rgba(${r}, ${g}, ${b}, ${alpha})`;
1024
- }
1061
+ };
1062
+ const hexToHexAlpha = (hex, alpha) => {
1063
+ hex = hex.replace(/^#/, '');
1064
+ if (hex.length === 3) {
1065
+ hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
1066
+ }
1067
+ const alphaHex = Math.round(alpha * 255)
1068
+ .toString(16)
1069
+ .padStart(2, '0');
1070
+ return `#${hex}${alphaHex}`;
1071
+ };
1025
1072
  const Utils = {
1026
1073
  getGitlabContribution,
1027
1074
  getGithubContribution,
1028
1075
  getCurrentTheme,
1029
- hexToRGBA
1076
+ hexToRGBA,
1077
+ hexToHexAlpha
1030
1078
  };
1031
1079
 
1032
1080
 
@@ -1129,7 +1177,7 @@ class PacmanRenderer {
1129
1177
  gameOverCallback: () => () => { },
1130
1178
  gameTheme: 'github',
1131
1179
  gameSpeed: 1,
1132
- enableSounds: true,
1180
+ enableSounds: false,
1133
1181
  pointsIncreasedCallback: (_) => { }
1134
1182
  };
1135
1183
  this.store.config = Object.assign(Object.assign({}, defaultConfing), this.conf);