@jsb188/gfx 1.1.2

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 (65) hide show
  1. package/README.md +522 -0
  2. package/elements/Shapes.helpers.ts +204 -0
  3. package/elements/Shapes.hooks.ts +171 -0
  4. package/elements/Shapes.tsx +505 -0
  5. package/elements/Shapes.types.ts +81 -0
  6. package/elements/Stack.helpers.ts +42 -0
  7. package/elements/Stack.tsx +143 -0
  8. package/elements/Text.helpers.ts +45 -0
  9. package/elements/Text.hooks.ts +197 -0
  10. package/elements/Text.tsx +98 -0
  11. package/libs/chain.ts +174 -0
  12. package/libs/dotGrid.helpers.ts +53 -0
  13. package/libs/dotGrid.ts +954 -0
  14. package/libs/effects/dotEffects.ts +136 -0
  15. package/libs/effects/effectQuad.ts +146 -0
  16. package/libs/effects/effectRegion.ts +299 -0
  17. package/libs/effects/imageEffects.ts +599 -0
  18. package/libs/effects/index.ts +8 -0
  19. package/libs/effects/ripple.ts +160 -0
  20. package/libs/glsl.ts +134 -0
  21. package/libs/passes.ts +374 -0
  22. package/libs/pointer.ts +151 -0
  23. package/libs/runtime.ts +329 -0
  24. package/libs/texture.ts +160 -0
  25. package/libs/types.ts +94 -0
  26. package/libs/uniforms.ts +32 -0
  27. package/main.ts +4 -0
  28. package/modules/Carousel.helpers.ts +316 -0
  29. package/modules/Carousel.hooks.ts +520 -0
  30. package/modules/Carousel.tsx +631 -0
  31. package/modules/Dots.tsx +269 -0
  32. package/modules/DotsBoard.helpers.ts +388 -0
  33. package/modules/DotsBoard.hooks.ts +144 -0
  34. package/modules/DotsBoard.strings.ts +649 -0
  35. package/modules/DotsBoard.types.ts +240 -0
  36. package/modules/DotsBoardCanvas.hooks.ts +49 -0
  37. package/modules/DotsBoardCanvas.tsx +190 -0
  38. package/modules/DotsBoardElements.tsx +330 -0
  39. package/modules/Gallery.helpers.ts +32 -0
  40. package/modules/Gallery.hooks.ts +149 -0
  41. package/modules/Gallery.tsx +194 -0
  42. package/modules/GfxCanvas.hooks.ts +12 -0
  43. package/modules/GfxCanvas.tsx +189 -0
  44. package/modules/Hero.tsx +90 -0
  45. package/modules/KineticHeader.helpers.ts +44 -0
  46. package/modules/KineticHeader.hooks.ts +206 -0
  47. package/modules/KineticHeader.tsx +305 -0
  48. package/modules/KineticHeader.types.ts +56 -0
  49. package/modules/ScrollSteps.hooks.ts +138 -0
  50. package/modules/ScrollSteps.tsx +98 -0
  51. package/package.json +52 -0
  52. package/scenes/Carousel.ts +277 -0
  53. package/scenes/DotsBoard.helpers.ts +12 -0
  54. package/scenes/DotsBoard.ts +245 -0
  55. package/scenes/Hero.ts +280 -0
  56. package/tsconfig.json +13 -0
  57. package/utils/align.ts +18 -0
  58. package/utils/color.ts +112 -0
  59. package/utils/dotEffectSpecs.ts +79 -0
  60. package/utils/dotGridSpecs.ts +469 -0
  61. package/utils/easing.ts +18 -0
  62. package/utils/imageEffectSpecs.ts +89 -0
  63. package/utils/motion.ts +88 -0
  64. package/utils/random.ts +22 -0
  65. package/utils/strings.ts +116 -0
@@ -0,0 +1,53 @@
1
+ import type { DotEffectSelection } from '../utils/dotEffectSpecs.ts';
2
+ import { DOT_EFFECTS, getDotEffectId } from '../utils/dotEffectSpecs.ts';
3
+
4
+ /** Maximum simultaneous click effects; another click replaces the oldest. */
5
+ export const DOT_CLICK_MAX_EFFECTS = 8;
6
+
7
+ /*
8
+ * Keep click origins, start times, and chosen effect IDs in a fixed GPU uniform buffer (x, y, seconds, active).
9
+ * Repeated clicks overlap without allocating per frame or growing the buffer indefinitely.
10
+ */
11
+ export function createDotClickEffects() {
12
+ // OGL recognizes uniform arrays through Array.isArray, so this must stay a plain array.
13
+ const data: number[] = Array(DOT_CLICK_MAX_EFFECTS * 4).fill(0);
14
+ const effects: number[] = Array(DOT_CLICK_MAX_EFFECTS).fill(0);
15
+ let next = 0;
16
+
17
+ /*
18
+ * Record a click, replacing the oldest when full, and return its shader ID. Random is chosen once here.
19
+ */
20
+ function add(x: number, y: number, seconds: number, effect: DotEffectSelection) {
21
+ const offset = next * 4;
22
+ data[offset] = x;
23
+ data[offset + 1] = y;
24
+ data[offset + 2] = seconds;
25
+ data[offset + 3] = 1;
26
+ if (effect === 'random') {
27
+ // The same board click selects the same effect in every scrolling and sticky layer.
28
+ let seed = Math.round(seconds * 1000) | 0;
29
+ seed = Math.imul(seed ^ (seed >>> 16), 0x45d9f3b);
30
+ seed = Math.imul(seed ^ (seed >>> 16), 0x45d9f3b);
31
+ effects[next] = ((seed ^ (seed >>> 16)) >>> 0) % DOT_EFFECTS.length;
32
+ } else {
33
+ effects[next] = getDotEffectId(effect);
34
+ }
35
+ const selectedEffect = effects[next];
36
+ next = (next + 1) % DOT_CLICK_MAX_EFFECTS;
37
+ return selectedEffect;
38
+ }
39
+
40
+ /*
41
+ * Expire completed effects and report whether more frames are needed; duration 0 clears all.
42
+ */
43
+ function update(seconds: number, duration: number) {
44
+ let active = false;
45
+ for (let i = 0; i < data.length; i += 4) {
46
+ if (duration <= 0 || seconds - data[i + 2] >= duration) data[i + 3] = 0;
47
+ if (data[i + 3] > 0) active = true;
48
+ }
49
+ return active;
50
+ }
51
+
52
+ return { data, effects, add, update };
53
+ }