@vpmedia/phaser 1.124.0 → 1.125.0

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.
Files changed (76) hide show
  1. package/dist/index.js +305 -309
  2. package/dist/index.js.map +1 -1
  3. package/dist/phaser/core/animation_parser.d.ts.map +1 -1
  4. package/dist/phaser/core/dom.d.ts.map +1 -1
  5. package/dist/phaser/core/frame_data.d.ts.map +1 -1
  6. package/dist/phaser/core/loader.d.ts.map +1 -1
  7. package/dist/phaser/core/scale_manager.d.ts.map +1 -1
  8. package/dist/phaser/core/sound.d.ts.map +1 -1
  9. package/dist/phaser/core/sound_manager.d.ts.map +1 -1
  10. package/dist/phaser/core/tween.d.ts.map +1 -1
  11. package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
  12. package/dist/phaser/display/display_object.d.ts +2 -2
  13. package/dist/phaser/display/display_object.d.ts.map +1 -1
  14. package/dist/phaser/display/graphics.d.ts +1 -1
  15. package/dist/phaser/display/graphics.d.ts.map +1 -1
  16. package/dist/phaser/display/group.d.ts.map +1 -1
  17. package/dist/phaser/display/image.d.ts.map +1 -1
  18. package/dist/phaser/display/text.d.ts.map +1 -1
  19. package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
  20. package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
  21. package/dist/phaser/geom/rectangle.d.ts.map +1 -1
  22. package/dist/phaser/geom/util/circle.d.ts.map +1 -1
  23. package/dist/phaser/geom/util/point.d.ts.map +1 -1
  24. package/dist/phaser/util/math.d.ts.map +1 -1
  25. package/package.json +1 -1
  26. package/src/phaser/core/animation.ts +7 -7
  27. package/src/phaser/core/animation_manager.ts +2 -2
  28. package/src/phaser/core/animation_parser.ts +11 -15
  29. package/src/phaser/core/array_set.ts +2 -2
  30. package/src/phaser/core/cache.ts +4 -4
  31. package/src/phaser/core/device_util.ts +4 -4
  32. package/src/phaser/core/dom.ts +23 -19
  33. package/src/phaser/core/frame_data.ts +2 -5
  34. package/src/phaser/core/game.ts +12 -12
  35. package/src/phaser/core/input.ts +2 -2
  36. package/src/phaser/core/input_handler.ts +13 -13
  37. package/src/phaser/core/input_mouse.ts +4 -4
  38. package/src/phaser/core/input_pointer.ts +1 -1
  39. package/src/phaser/core/loader.ts +38 -50
  40. package/src/phaser/core/scale_manager.ts +10 -9
  41. package/src/phaser/core/scene_manager.ts +2 -2
  42. package/src/phaser/core/signal.ts +2 -2
  43. package/src/phaser/core/sound.ts +25 -32
  44. package/src/phaser/core/sound_manager.ts +12 -16
  45. package/src/phaser/core/sound_sprite.ts +1 -1
  46. package/src/phaser/core/stage.ts +3 -3
  47. package/src/phaser/core/timer.ts +1 -1
  48. package/src/phaser/core/tween.ts +6 -11
  49. package/src/phaser/display/bitmap_text.ts +3 -3
  50. package/src/phaser/display/button.ts +12 -12
  51. package/src/phaser/display/canvas/graphics.ts +2 -2
  52. package/src/phaser/display/canvas/pool.ts +3 -3
  53. package/src/phaser/display/canvas/renderer.ts +6 -5
  54. package/src/phaser/display/canvas/tinter.ts +1 -1
  55. package/src/phaser/display/canvas/util.ts +2 -2
  56. package/src/phaser/display/display_object.ts +13 -14
  57. package/src/phaser/display/graphics.test.ts +2 -2
  58. package/src/phaser/display/graphics.ts +9 -11
  59. package/src/phaser/display/group.ts +10 -9
  60. package/src/phaser/display/image.ts +7 -6
  61. package/src/phaser/display/sprite_util.ts +1 -1
  62. package/src/phaser/display/text.ts +35 -44
  63. package/src/phaser/display/webgl/abstract_filter.ts +1 -1
  64. package/src/phaser/display/webgl/earcut.ts +46 -42
  65. package/src/phaser/display/webgl/graphics.ts +1 -1
  66. package/src/phaser/display/webgl/renderer.ts +3 -3
  67. package/src/phaser/display/webgl/shader/normal.ts +6 -6
  68. package/src/phaser/display/webgl/shader_manager.ts +1 -1
  69. package/src/phaser/display/webgl/sprite_batch.ts +2 -2
  70. package/src/phaser/display/webgl/texture.ts +2 -1
  71. package/src/phaser/display/webgl/util.ts +3 -3
  72. package/src/phaser/geom/polygon.ts +2 -2
  73. package/src/phaser/geom/rectangle.ts +1 -2
  74. package/src/phaser/geom/util/circle.ts +6 -10
  75. package/src/phaser/geom/util/point.ts +5 -7
  76. package/src/phaser/util/math.ts +2 -3
@@ -8,10 +8,11 @@ import { Node } from './earcut_node.js';
8
8
  export function sortLinked(list: Node | null): Node | null {
9
9
  let numMerges;
10
10
  let inSize = 1;
11
+ let sorted = list;
11
12
  do {
12
- let p: Node | null = list;
13
+ let p: Node | null = sorted;
13
14
  let tail: Node | null = null;
14
- list = null;
15
+ sorted = null;
15
16
  numMerges = 0;
16
17
  while (p) {
17
18
  numMerges += 1;
@@ -55,7 +56,7 @@ export function sortLinked(list: Node | null): Node | null {
55
56
  if (tail) {
56
57
  tail.nextZ = e;
57
58
  } else {
58
- list = e;
59
+ sorted = e;
59
60
  }
60
61
  e.prevZ = tail;
61
62
  tail = e;
@@ -67,7 +68,7 @@ export function sortLinked(list: Node | null): Node | null {
67
68
  }
68
69
  inSize *= 2;
69
70
  } while (numMerges > 1);
70
- return list;
71
+ return sorted;
71
72
  }
72
73
 
73
74
  /**
@@ -91,17 +92,17 @@ export function compareX(a: Node, b: Node): number {
91
92
  */
92
93
  export function zOrder(x: number, y: number, minX: number, minY: number, size: number): number {
93
94
  // coords are transformed into non-negative 15-bit integer range
94
- x = (32_767 * (x - minX)) / size;
95
- y = (32_767 * (y - minY)) / size;
96
- x = (x | (x << 8)) & 0x00ff00ff;
97
- x = (x | (x << 4)) & 0x0f0f0f0f;
98
- x = (x | (x << 2)) & 0x33333333;
99
- x = (x | (x << 1)) & 0x55555555;
100
- y = (y | (y << 8)) & 0x00ff00ff;
101
- y = (y | (y << 4)) & 0x0f0f0f0f;
102
- y = (y | (y << 2)) & 0x33333333;
103
- y = (y | (y << 1)) & 0x55555555;
104
- return x | (y << 1);
95
+ let ix = (32_767 * (x - minX)) / size;
96
+ let iy = (32_767 * (y - minY)) / size;
97
+ ix = (ix | (ix << 8)) & 0x00ff00ff;
98
+ ix = (ix | (ix << 4)) & 0x0f0f0f0f;
99
+ ix = (ix | (ix << 2)) & 0x33333333;
100
+ ix = (ix | (ix << 1)) & 0x55555555;
101
+ iy = (iy | (iy << 8)) & 0x00ff00ff;
102
+ iy = (iy | (iy << 4)) & 0x0f0f0f0f;
103
+ iy = (iy | (iy << 2)) & 0x33333333;
104
+ iy = (iy | (iy << 1)) & 0x55555555;
105
+ return ix | (iy << 1);
105
106
  }
106
107
 
107
108
  /**
@@ -446,7 +447,7 @@ export function filterPoints(start: Node | null, end?: Node | null): Node | null
446
447
  if (!start) {
447
448
  return start;
448
449
  }
449
- end ??= start;
450
+ let last = end ?? start;
450
451
  let p = start;
451
452
  let again;
452
453
  do {
@@ -454,7 +455,7 @@ export function filterPoints(start: Node | null, end?: Node | null): Node | null
454
455
  if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
455
456
  removeNode(p);
456
457
  p = p.prev;
457
- end = p;
458
+ last = p;
458
459
  if (p === p.next) {
459
460
  return null;
460
461
  }
@@ -462,8 +463,8 @@ export function filterPoints(start: Node | null, end?: Node | null): Node | null
462
463
  } else {
463
464
  p = p.next;
464
465
  }
465
- } while (again || p !== end);
466
- return end;
466
+ } while (again || p !== last);
467
+ return last;
467
468
  }
468
469
 
469
470
  /**
@@ -567,14 +568,15 @@ export function eliminateHoles(
567
568
  }
568
569
  queue.sort(compareX);
569
570
  // process holes from left to right
571
+ let outer = outerNode;
570
572
  for (i = 0; i < queue.length; i += 1) {
571
- if (!outerNode) {
572
- return outerNode;
573
+ if (!outer) {
574
+ return outer;
573
575
  }
574
- eliminateHole(queue[i]!, outerNode);
575
- outerNode = filterPoints(outerNode, outerNode.next);
576
+ eliminateHole(queue[i]!, outer);
577
+ outer = filterPoints(outer, outer.next);
576
578
  }
577
- return outerNode;
579
+ return outer;
578
580
  }
579
581
 
580
582
  /**
@@ -586,6 +588,7 @@ export function eliminateHoles(
586
588
  */
587
589
  export function cureLocalIntersections(start: Node, triangles: number[], dim: number): Node {
588
590
  let p = start;
591
+ let first = start;
589
592
  do {
590
593
  const a = p.prev;
591
594
  const b = p.next.next;
@@ -598,10 +601,10 @@ export function cureLocalIntersections(start: Node, triangles: number[], dim: nu
598
601
  removeNode(p);
599
602
  removeNode(p.next);
600
603
  p = b;
601
- start = p;
604
+ first = p;
602
605
  }
603
606
  p = p.next;
604
- } while (p !== start);
607
+ } while (p !== first);
605
608
  return p;
606
609
  }
607
610
 
@@ -659,40 +662,41 @@ export function earcutLinked(
659
662
  if (!ear) {
660
663
  return;
661
664
  }
665
+ let current = ear;
662
666
  // interlink polygon nodes in z-order
663
- if (!pass && size) {
664
- indexCurve(ear, minX, minY, size);
667
+ if (pass === undefined && size !== undefined) {
668
+ indexCurve(current, minX, minY, size);
665
669
  }
666
- let stop = ear;
670
+ let stop = current;
667
671
  let prev;
668
672
  let next;
669
673
  // iterate through ears, slicing them one by one
670
- while (ear.prev !== ear.next) {
671
- ({ prev, next } = ear);
672
- if (size ? isEarHashed(ear, minX, minY, size) : isEar(ear)) {
674
+ while (current.prev !== current.next) {
675
+ ({ prev, next } = current);
676
+ if (size === undefined ? isEar(current) : isEarHashed(current, minX, minY, size)) {
673
677
  // cut off the triangle
674
678
  triangles.push(prev.i / dim);
675
- triangles.push(ear.i / dim);
679
+ triangles.push(current.i / dim);
676
680
  triangles.push(next.i / dim);
677
- removeNode(ear);
681
+ removeNode(current);
678
682
  // skipping the next vertice leads to less sliver triangles
679
- ear = next.next;
683
+ current = next.next;
680
684
  stop = next.next;
681
685
  continue;
682
686
  }
683
- ear = next;
687
+ current = next;
684
688
  // if we looped through the whole remaining polygon and can't find any more ears
685
- if (ear === stop) {
689
+ if (current === stop) {
686
690
  // try filtering points and slicing again
687
- if (!pass) {
688
- earcutLinked(filterPoints(ear), triangles, dim, minX, minY, size, 1);
691
+ if (pass === undefined) {
692
+ earcutLinked(filterPoints(current), triangles, dim, minX, minY, size, 1);
689
693
  // if this didn't work, try curing all small self-intersections locally
690
694
  } else if (pass === 1) {
691
- ear = cureLocalIntersections(ear, triangles, dim);
692
- earcutLinked(ear, triangles, dim, minX, minY, size, 2);
695
+ current = cureLocalIntersections(current, triangles, dim);
696
+ earcutLinked(current, triangles, dim, minX, minY, size, 2);
693
697
  // as a last resort, try splitting the remaining polygon into two
694
698
  } else if (pass === 2) {
695
- splitEarcut(ear, triangles, dim, minX, minY, size);
699
+ splitEarcut(current, triangles, dim, minX, minY, size);
696
700
  }
697
701
  break;
698
702
  }
@@ -471,7 +471,7 @@ export const buildPoly = (graphicsData: DisplayGraphicsData, webGLData: Graphics
471
471
  const g = color[1] * alpha;
472
472
  const b = color[2] * alpha;
473
473
  const triangles = triangulate(points, null, 2);
474
- if (!triangles) {
474
+ if (triangles.length === 0) {
475
475
  return false;
476
476
  }
477
477
  const vertPos = verts.length / 6;
@@ -75,7 +75,7 @@ export class WebGLRenderer {
75
75
  alpha: Boolean(game.config.transparent),
76
76
  depth: false,
77
77
  antialias: game.config.antialias,
78
- premultipliedAlpha: game.config.transparent && game.config.transparent !== 'notMultiplied',
78
+ premultipliedAlpha: game.config.transparent !== false && game.config.transparent !== 'notMultiplied',
79
79
  stencil: true,
80
80
  failIfMajorPerformanceCaveat: false,
81
81
  preserveDrawingBuffer: game.config.preserveDrawingBuffer,
@@ -111,7 +111,7 @@ export class WebGLRenderer {
111
111
  this.shaderManager.destroy();
112
112
  this.spriteBatch.destroy();
113
113
  this.filterManager.destroy();
114
- if (this.gl) {
114
+ if (this.gl as IdentifiedWebGLRenderingContext | undefined) {
115
115
  this.gl.canvas.width = 1;
116
116
  this.gl.canvas.height = 1;
117
117
  const loseContextExt = this.gl.getExtension('WEBGL_lose_context');
@@ -289,7 +289,7 @@ export class WebGLRenderer {
289
289
  * Maps blend modes to WebGL rendering operations.
290
290
  */
291
291
  public mapBlendModes(): void {
292
- if (globalThis.PhaserRegistry.blendModesWebGL) {
292
+ if (globalThis.PhaserRegistry.blendModesWebGL as number[][] | undefined) {
293
293
  return;
294
294
  }
295
295
  const { gl } = this;
@@ -197,7 +197,7 @@ export class NormalShader {
197
197
  */
198
198
  public initSampler2D(uniform: SamplerUniform): void {
199
199
  const texture = uniform.value;
200
- if (!texture?.baseTexture.hasLoaded) {
200
+ if (texture?.baseTexture.hasLoaded !== true) {
201
201
  return;
202
202
  }
203
203
  const { gl } = this;
@@ -218,13 +218,13 @@ export class NormalShader {
218
218
  const minFilter = data.minFilter ?? gl.LINEAR;
219
219
  let wrapS = data.wrapS ?? gl.CLAMP_TO_EDGE;
220
220
  let wrapT = data.wrapT ?? gl.CLAMP_TO_EDGE;
221
- const format = data.luminance ? gl.LUMINANCE : gl.RGBA;
222
- if (data.repeat) {
221
+ const format = data.luminance === true ? gl.LUMINANCE : gl.RGBA;
222
+ if (data.repeat === true) {
223
223
  wrapS = gl.REPEAT;
224
224
  wrapT = gl.REPEAT;
225
225
  }
226
226
  gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, Boolean(data.flipY));
227
- if (data.width) {
227
+ if (data.width !== undefined) {
228
228
  const width = data.width ?? 512;
229
229
  const height = data.height ?? 2;
230
230
  const border = data.border ?? 0;
@@ -268,10 +268,10 @@ export class NormalShader {
268
268
  } else if (uniform.glValueLength === 4) {
269
269
  callUniformSetter(uniform.glFunc, gl, uniform.uniformLocation, vector.x, vector.y, vector.z, vector.w);
270
270
  } else if (uniform.type === 'sampler2D') {
271
- if (uniform._init) {
271
+ if (uniform._init === true) {
272
272
  gl.activeTexture(glMember(gl, `TEXTURE${this.textureCount}`));
273
273
  const { baseTexture } = sampler.value!;
274
- if (baseTexture._dirty[gl.id]) {
274
+ if (baseTexture._dirty[gl.id] === true) {
275
275
  globalThis.PhaserRegistry.INSTANCES[gl.id]?.updateTexture(baseTexture);
276
276
  } else {
277
277
  // bind the current texture
@@ -71,7 +71,7 @@ export class WebGLShaderManager {
71
71
  for (i = 0; i < this.attribState.length; i += 1) {
72
72
  if (this.attribState[i] !== this.tempAttribState[i]) {
73
73
  this.attribState[i] = this.tempAttribState[i];
74
- if (this.tempAttribState[i]) {
74
+ if (this.tempAttribState[i] === true) {
75
75
  gl.enableVertexAttribArray(i);
76
76
  } else {
77
77
  gl.disableVertexAttribArray(i);
@@ -266,7 +266,7 @@ export class WebGLSpriteBatch {
266
266
  nextBlendMode = sprite.blendMode;
267
267
  nextShader = sprite.shader ?? this.defaultShader;
268
268
  blendSwap = currentBlendMode !== nextBlendMode;
269
- shaderSwap = !currentShader || !nextShader || currentShader._UID !== nextShader._UID;
269
+ shaderSwap = currentShader === null || currentShader._UID !== nextShader._UID;
270
270
  let skip = nextTexture.skipRender;
271
271
  if (skip && sprite.children.length > 0) {
272
272
  skip = false;
@@ -323,7 +323,7 @@ export class WebGLSpriteBatch {
323
323
  }
324
324
  const { gl } = this;
325
325
  // check if a texture is dirty..
326
- if (texture._dirty[gl.id]) {
326
+ if (texture._dirty[gl.id] === true) {
327
327
  if (!this.renderSession.renderer.updateTexture(texture)) {
328
328
  // If updateTexture returns false then we cannot render it, so bail out now
329
329
  return;
@@ -121,7 +121,8 @@ export class Texture {
121
121
  this.valid = false;
122
122
  return;
123
123
  }
124
- this.valid = Boolean(frame && frame.width && frame.height && this.baseTexture.source && this.baseTexture.hasLoaded);
124
+ this.valid =
125
+ frame.width !== 0 && frame.height !== 0 && this.baseTexture.source !== null && this.baseTexture.hasLoaded;
125
126
  if (this.trim) {
126
127
  this.width = this.trim.width;
127
128
  this.height = this.trim.height;
@@ -82,7 +82,7 @@ export const compileShader = (
82
82
  }
83
83
  gl.shaderSource(shader, src);
84
84
  gl.compileShader(shader);
85
- if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
85
+ if (gl.getShaderParameter(shader, gl.COMPILE_STATUS) !== true) {
86
86
  getRegistry();
87
87
  globalThis.PhaserRegistry.GL_SHADER_INFO_LOG = gl.getShaderInfoLog(shader);
88
88
  return null;
@@ -125,14 +125,14 @@ export const compileProgram = (
125
125
 
126
126
  const shaderProgram = gl.createProgram();
127
127
 
128
- if (!shaderProgram || !vertexShader || !fragmentShader) {
128
+ if (shaderProgram === null || vertexShader === null || fragmentShader === null) {
129
129
  return null;
130
130
  }
131
131
  gl.attachShader(shaderProgram, vertexShader);
132
132
  gl.attachShader(shaderProgram, fragmentShader);
133
133
  gl.linkProgram(shaderProgram);
134
134
 
135
- if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
135
+ if (gl.getProgramParameter(shaderProgram, gl.LINK_STATUS) !== true) {
136
136
  getRegistry();
137
137
  globalThis.PhaserRegistry.GL_PROGRAM_INFO_LOG = gl.getProgramInfoLog(shaderProgram);
138
138
  }
@@ -27,7 +27,7 @@ export class Polygon {
27
27
  this.flattened = false;
28
28
  /** @type {number} */
29
29
  this.type = GEOM_POLYGON;
30
- if (points) {
30
+ if (points !== null) {
31
31
  this.setTo(points);
32
32
  }
33
33
  }
@@ -111,7 +111,7 @@ export class Polygon {
111
111
  this.area = 0;
112
112
  const vertices: Point[] = [];
113
113
  this._points = vertices;
114
- if (points) {
114
+ if (points.length > 0) {
115
115
  // If points isn't an array, use arguments as the array
116
116
  if (!Array.isArray(points)) {
117
117
  console.error('[Polygon] setTo() error, input parameter is not an array', points);
@@ -95,9 +95,8 @@ export class Rectangle {
95
95
  * @returns {Rectangle} This rectangle instance for chaining.
96
96
  */
97
97
  public scale(x: number, y?: number): this {
98
- y ??= x;
99
98
  this.width *= x;
100
- this.height *= y;
99
+ this.height *= y ?? x;
101
100
  return this;
102
101
  }
103
102
 
@@ -59,11 +59,9 @@ export const intersects = (a: Circle, b: Circle): boolean => distance(a.x, a.y,
59
59
  */
60
60
  export const circumferencePoint = (a: Circle, angle: number, asDegrees = false, output: Point | null = null): Point => {
61
61
  const result = output ?? new Point();
62
- if (asDegrees) {
63
- angle = degToRad(angle);
64
- }
65
- result.x = a.x + a.radius * Math.cos(angle);
66
- result.y = a.y + a.radius * Math.sin(angle);
62
+ const radians = asDegrees ? degToRad(angle) : angle;
63
+ result.x = a.x + a.radius * Math.cos(radians);
64
+ result.y = a.y + a.radius * Math.sin(radians);
67
65
  return result;
68
66
  };
69
67
 
@@ -77,11 +75,9 @@ export const circumferencePoint = (a: Circle, angle: number, asDegrees = false,
77
75
  */
78
76
  export const intersectsPoint = (a: Circle, angle: number, asDegrees = false, output: Point | null = null): Point => {
79
77
  const result = output ?? new Point();
80
- if (asDegrees) {
81
- angle = degToRad(angle);
82
- }
83
- result.x = a.x + a.radius * Math.cos(angle);
84
- result.y = a.y + a.radius * Math.sin(angle);
78
+ const radians = asDegrees ? degToRad(angle) : angle;
79
+ result.x = a.x + a.radius * Math.cos(radians);
80
+ result.y = a.y + a.radius * Math.sin(radians);
85
81
  return result;
86
82
  };
87
83
 
@@ -221,13 +221,11 @@ export const rotate = (
221
221
  asDegrees: boolean,
222
222
  dist: number | null | undefined
223
223
  ): Point => {
224
- if (asDegrees) {
225
- ang *= Math.PI / 180;
226
- }
224
+ const radians = asDegrees ? ang * (Math.PI / 180) : ang;
227
225
  if (dist === undefined || dist === null) {
228
226
  a.subtract(x, y);
229
- const s = Math.sin(ang);
230
- const c = Math.cos(ang);
227
+ const s = Math.sin(radians);
228
+ const c = Math.cos(radians);
231
229
  const tx = c * a.x - s * a.y;
232
230
  const ty = s * a.x + c * a.y;
233
231
  a.x = tx + x;
@@ -273,10 +271,10 @@ export const centroid = (points: Point[], output: Point | null = null): Point =>
273
271
  */
274
272
  export const parse = (obj: Record<string, unknown>, xProp = 'x', yProp = 'y'): Point => {
275
273
  const point = new Point();
276
- if (obj[xProp]) {
274
+ if (obj[xProp] !== undefined) {
277
275
  point.x = Math.trunc(Number(obj[xProp]));
278
276
  }
279
- if (obj[yProp]) {
277
+ if (obj[yProp] !== undefined) {
280
278
  point.y = Math.trunc(Number(obj[yProp]));
281
279
  }
282
280
  return point;
@@ -63,9 +63,8 @@ export const snapToCeil = (input: number, gap = 0, start = 0): number => {
63
63
  if (gap === 0) {
64
64
  return input;
65
65
  }
66
- input -= start;
67
- input = gap * Math.ceil(input / gap);
68
- return start + input;
66
+ const offset = gap * Math.ceil((input - start) / gap);
67
+ return start + offset;
69
68
  };
70
69
 
71
70
  /** Wraps a value within a range. */