earthnut 0.0.0 → 0.0.1

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 (88) hide show
  1. package/BackgroundRipple/index.cjs +1 -0
  2. package/BackgroundRipple/index.mjs +1 -0
  3. package/LICENSE +25 -0
  4. package/Layout/index.cjs +1 -0
  5. package/Layout/index.mjs +1 -0
  6. package/README.md +9 -5
  7. package/components/button/button.d.ts +5 -0
  8. package/components/button/index.d.ts +3 -0
  9. package/components/button/style/index.d.ts +1 -0
  10. package/components/index.d.ts +3 -0
  11. package/components/layout/content.d.ts +11 -0
  12. package/components/layout/footer.d.ts +16 -0
  13. package/components/layout/header.d.ts +18 -0
  14. package/components/layout/index.d.ts +2 -0
  15. package/components/layout/layout.d.ts +50 -0
  16. package/components/layout/sideBar.d.ts +24 -0
  17. package/components/layout/types.d.ts +71 -0
  18. package/components/menu/index.d.ts +0 -0
  19. package/components/menu/menu.d.ts +0 -0
  20. package/components/menu/style/index.d.ts +0 -0
  21. package/components/ripples/RipplesEle.d.ts +36 -0
  22. package/components/ripples/index.d.ts +4 -0
  23. package/components/ripples/style/index.d.ts +0 -0
  24. package/components/ripples/types.d.ts +11 -0
  25. package/components/ripples/useOptionUpdate.d.ts +5 -0
  26. package/customHooks/index.d.ts +5 -0
  27. package/customHooks/useAnimationFrame.d.ts +42 -0
  28. package/customHooks/useInputIsComposing.d.ts +46 -0
  29. package/customHooks/useRipples/buildBackground/default-background/_createImageData.d.ts +7 -0
  30. package/customHooks/useRipples/buildBackground/default-background/circleDataList.d.ts +18 -0
  31. package/customHooks/useRipples/buildBackground/default-background/createCanvasElementBySize.d.ts +2 -0
  32. package/customHooks/useRipples/buildBackground/default-background/createDefault.d.ts +2 -0
  33. package/customHooks/useRipples/buildBackground/default-background/index.d.ts +10 -0
  34. package/customHooks/useRipples/buildBackground/loadImage.d.ts +13 -0
  35. package/customHooks/useRipples/buildBackground/runSide.d.ts +9 -0
  36. package/customHooks/useRipples/buildBackground/type.d.ts +27 -0
  37. package/customHooks/useRipples/buildBackground/utils/bindImage.d.ts +3 -0
  38. package/customHooks/useRipples/buildBackground/utils/createCanvasElement.d.ts +3 -0
  39. package/customHooks/useRipples/buildBackground/utils/createImageBySrc.d.ts +2 -0
  40. package/customHooks/useRipples/buildBackground/utils/getBackgroundStyle.d.ts +3 -0
  41. package/customHooks/useRipples/buildBackground/utils/hideCssBackground.d.ts +10 -0
  42. package/customHooks/useRipples/buildBackground/utils/restore-css-background.d.ts +7 -0
  43. package/customHooks/useRipples/callback/destroy.d.ts +3 -0
  44. package/customHooks/useRipples/callback/drop.d.ts +3 -0
  45. package/customHooks/useRipples/callback/fade.d.ts +3 -0
  46. package/customHooks/useRipples/callback/reload-background.d.ts +6 -0
  47. package/customHooks/useRipples/callback/scale.d.ts +2 -0
  48. package/customHooks/useRipples/index.d.ts +40 -0
  49. package/customHooks/useRipples/init/index.d.ts +5 -0
  50. package/customHooks/useRipples/init/initEvent.d.ts +5 -0
  51. package/customHooks/useRipples/init/initShaders.d.ts +7 -0
  52. package/customHooks/useRipples/init/initTexture.d.ts +7 -0
  53. package/customHooks/useRipples/render/computeTextureBoundaries.d.ts +3 -0
  54. package/customHooks/useRipples/render/draw.d.ts +7 -0
  55. package/customHooks/useRipples/render/drawQuad.d.ts +7 -0
  56. package/customHooks/useRipples/render/dropAtPointer.d.ts +7 -0
  57. package/customHooks/useRipples/render/index.d.ts +6 -0
  58. package/customHooks/useRipples/render/swapBufferIndices.d.ts +5 -0
  59. package/customHooks/useRipples/render/update.d.ts +5 -0
  60. package/customHooks/useRipples/rippersData/defaultData.d.ts +5 -0
  61. package/customHooks/useRipples/rippersData/fadeData.d.ts +29 -0
  62. package/customHooks/useRipples/rippersData/index.d.ts +40 -0
  63. package/customHooks/useRipples/rippersData/loadConfig.d.ts +19 -0
  64. package/customHooks/useRipples/rippersData/renderData.d.ts +72 -0
  65. package/customHooks/useRipples/rippersData/useOptions.d.ts +81 -0
  66. package/customHooks/useRipples/rippersData/vertexSource.d.ts +28 -0
  67. package/customHooks/useRipples/ripple.html.d.ts +6 -0
  68. package/customHooks/useRipples/ripplesClass.d.ts +51 -0
  69. package/customHooks/useRipples/tools.d.ts +31 -0
  70. package/customHooks/useRipples/types.d.ts +192 -0
  71. package/customHooks/useTimeId.d.ts +55 -0
  72. package/dog.d.ts +3 -0
  73. package/index.cjs +1 -0
  74. package/index.d.ts +5 -0
  75. package/index.js.LICENSE.txt +79 -0
  76. package/index.mjs +1 -0
  77. package/package.json +87 -14
  78. package/styles/common.css +360 -0
  79. package/styles/common.scss +444 -0
  80. package/useAnimationFrame/index.cjs +1 -0
  81. package/useAnimationFrame/index.mjs +1 -0
  82. package/useInputIsComposing/index.cjs +1 -0
  83. package/useInputIsComposing/index.mjs +1 -0
  84. package/useRipples/index.cjs +1 -0
  85. package/useRipples/index.mjs +1 -0
  86. package/useTimeId/index.cjs +1 -0
  87. package/useTimeId/index.mjs +1 -0
  88. package/index.js +0 -1
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import { BackgroundRipplesProps } from 'customHooks/useRipples/types';
3
+ import { RippleEle } from './types';
4
+ import './style/index.scss';
5
+ /**
6
+ *
7
+ * ### 一个 ripple 背景组件
8
+ *
9
+ *
10
+ * *需要为该组件或父组件设置背景,否则即便的渲染了,效果不明显*
11
+ *
12
+ * 参数 props 属性:
13
+ * - children 内嵌的 ReactNode
14
+ * - style 更改显示的样式
15
+ * - option 初始化 ripples 的原始数据
16
+ * @param props 使用参数
17
+ * @version 0.0.1
18
+ * @see https://earthnut.dev/earthnut/background-ripple
19
+ * @example
20
+ * 使用:
21
+ *
22
+ * ```ts
23
+ * import { BackgroundRipple } from 'earthnut/BackgroundRipple';
24
+ * // 也可以全量导入
25
+ * // import { BackgroundRipple } from 'earthnut';
26
+ * ...
27
+ * const animationFrameId = useAnimationFrame();
28
+ *
29
+ * return <BackgroundRipple>
30
+ * ...
31
+ * </BackgroundRipple>
32
+ * ```
33
+ *
34
+ */
35
+ declare const BackgroundRipple: React.ForwardRefExoticComponent<BackgroundRipplesProps & React.RefAttributes<RippleEle>>;
36
+ export { BackgroundRipple };
@@ -0,0 +1,4 @@
1
+ import { RippleEle } from './types';
2
+ export { BackgroundRipple } from './RipplesEle';
3
+ export type { Ripples, BackgroundRipplesProps, RipplesOptions, } from '../../customHooks/useRipples/index';
4
+ export type { RippleEle };
File without changes
@@ -0,0 +1,11 @@
1
+ import { RipplesOptions } from 'customHooks';
2
+ export type RippleEle = {
3
+ /** 切换当前的状态 */
4
+ toggleState(): void;
5
+ /** 获取当前的状态 */
6
+ state: boolean;
7
+ /** 暂停当前涟漪的渲染 */
8
+ pause(): void;
9
+ /** 设置属性 */
10
+ set(options?: RipplesOptions): void;
11
+ };
@@ -0,0 +1,5 @@
1
+ import { BackgroundRipplesProps, Ripples } from 'customHooks';
2
+ /**
3
+ * 更新参数数据
4
+ */
5
+ export declare function useOptionUpdate(ripplesRef: React.RefObject<Ripples | null>, props: BackgroundRipplesProps): void;
@@ -0,0 +1,5 @@
1
+ export { useInputIsComposing } from './useInputIsComposing';
2
+ export { useTimeId } from './useTimeId';
3
+ export { useAnimationFrameId } from './useAnimationFrame';
4
+ export { useRipples } from './useRipples/index';
5
+ export type { Ripples, BackgroundRipplesProps, RipplesOptions } from './useRipples/index';
@@ -0,0 +1,42 @@
1
+ /****************************************************************************
2
+ * @Author earthnut
3
+ * @Email earthnut.dev@outlook.com
4
+ * @ProjectName earthnut
5
+ * @FilePath /src/customHooks/useAnimationFrame.ts
6
+ * @FileName useAnimationFrame.ts
7
+ * @CreateDate 周二 01/07/2025
8
+ * @Description 使用 animationFrame
9
+ ****************************************************************************/
10
+ /**
11
+ *
12
+ * ### 导出一个使用 `useRef` 创建的 `number`
13
+ *
14
+ * 该数值在组件卸载时会自动调用 `window.cancelAnimationFrame` 清理
15
+ * @description 一个接收 `window.requestAnimationFrame` 的返回值的 `ref`
16
+ * @returns <React.RefObject: number>
17
+ * @version 0.0.3
18
+ * @see https://earthnut.dev/use-animation-frame
19
+ * @example
20
+ * 使用:
21
+ *
22
+ * ```ts
23
+ * import { useAnimationFrame } from 'earthnut/useAnimationFrame';
24
+ * // 也可以全量导入
25
+ * // import { useAnimationFrame } from 'earthnut';
26
+ * ...
27
+ * const animationFrameId = useAnimationFrame();
28
+ *
29
+ * function performAction(time?: number){
30
+ * useAnimationFrame.current = window.requestAnimationFrame(performAction);
31
+ * ...
32
+ * }
33
+ *
34
+ * useEffect(()=>{
35
+ * animationFrameId.current = window.requestAnimationFrame(performAction);
36
+ * });
37
+ * ...
38
+ *
39
+ * ```
40
+ *
41
+ */
42
+ export declare function useAnimationFrameId(): React.RefObject<number>;
@@ -0,0 +1,46 @@
1
+ /****************************************************************************
2
+ * @Author earthnut
3
+ * @Email earthnut.dev@outlook.com
4
+ * @ProjectName earthnut
5
+ * @FilePath /src/customHooks/useAnimationFrame.ts
6
+ * @FileName useInputIsComposing.ts
7
+ * @CreateDate 周二 01/07/2025
8
+ * @Description 使用输入框是否完成输入状态
9
+ ****************************************************************************/
10
+ /**
11
+ *
12
+ * ### 导出一个使用 `useRef` 创建的 `boolean`
13
+ *
14
+ * *由于是包裹在 React.RefObject 之中,判断时务必使用 `isComposing.current` 进行判断*
15
+ * @description 用于判断当前的输入状态是否结束
16
+ * @param inputRef [React.RefObject<HTMLInputElement | HTMLTextAreaElement>] 输入框的 ref
17
+ * @returns React.RefObject<boolean>
18
+ * @version 0.0.4
19
+ * @see https://earthnut.dev/use-input-is-composing
20
+ * @example
21
+ *
22
+ * 使用:
23
+ *
24
+ * ```ts
25
+ * import { useInputIsComposing } from 'earthnut/useInputIsComposing';
26
+ * // 也可以全量导入
27
+ * // import { useInputIsComposing } from 'earthnut';
28
+ * ...
29
+ * const inputRef = useRef<HTMLInputElement>(null);
30
+ *
31
+ * const inputIsComposing = useInputIsComposing(inputRef);
32
+ * ...
33
+ * function enterDown()(e: React.KeyboardEvent<HTMLInputElement>) {
34
+ * if (e.key === 'Enter') {
35
+ * if (isComposing.current) {
36
+ * console.log("此时此景,按回车键说明为了从候选词中挑选");
37
+ * } else
38
+ * console.log("输入完毕,敲回车是为了看一些开发者是否绑定了其他事件");
39
+ * }
40
+ * }
41
+ * ...
42
+ * <input type="text" onKeyDown={enterDown} />
43
+ * ...
44
+ * ```
45
+ */
46
+ export declare function useInputIsComposing(inputRef: React.RefObject<HTMLInputElement | HTMLTextAreaElement | null>): React.RefObject<boolean>;
@@ -0,0 +1,7 @@
1
+ import { Ripples } from '../../ripplesClass';
2
+ /**
3
+ * 创建一个隐含像素数据的区域
4
+ *
5
+ * 用于构建默认的背景图
6
+ */
7
+ export declare function createImageData(this: Ripples, bindImage: () => void): void;
@@ -0,0 +1,18 @@
1
+ /** 圆数据 */
2
+ export declare const circleDataList: {
3
+ /** 计数器 */
4
+ "__#1@#cum": number;
5
+ /** 构建新的数据依据 */
6
+ build(): void;
7
+ /** 数据依据 */
8
+ data: {
9
+ /** 数据 */
10
+ list: [number, number, number, number][][];
11
+ /** 直径 */
12
+ diameter: number;
13
+ /** 半径 */
14
+ radius: number;
15
+ /** 晶格数 */
16
+ cells: number;
17
+ };
18
+ };
@@ -0,0 +1,2 @@
1
+ /** 通过尺寸创建一个默认图 */
2
+ export declare function createCanvasElementBySize(width: number, height: number): HTMLCanvasElement;
@@ -0,0 +1,2 @@
1
+ /** 构建默认的背景图 */
2
+ export declare function createDefault(width: number, height: number): ImageData;
@@ -0,0 +1,10 @@
1
+ import { Ripples } from '../../ripplesClass';
2
+ /**
3
+ *
4
+ * 设置透明的纹理
5
+ *
6
+ *
7
+ * 透明的纹理*默认会自动切换*
8
+ *
9
+ */
10
+ export declare function setTransparentTexture(this: Ripples): void;
@@ -0,0 +1,13 @@
1
+ import { Ripples } from '../ripplesClass';
2
+ /**
3
+ *
4
+ * 加载图像
5
+ *
6
+ * - 初始化的时候首先触发加载背景图像
7
+ * - 通过 Ripple 的 set 方法设置属性 imageUrl 值时将触发
8
+ * - 尺寸发生变化时亦将触发更改
9
+ * - 父元素的样式属性发生变更时也会触发
10
+ *
11
+ * 在加载过程中如果渲染的图片为非法的(加载错误)那么将查找当前的背景色或是背景图作为依据,再就是都没有的情况下将会渲染一个类似于旧地板的色
12
+ */
13
+ export declare function loadImage(this: Ripples): void;
@@ -0,0 +1,9 @@
1
+ import { Ripples } from '../ripplesClass';
2
+ /**
3
+ * 设置缓变
4
+ *
5
+ * 缓变分两种,一种是没有任何设置的缓变;另一种就是两个不同类型之间的缓变
6
+ *
7
+ *
8
+ */
9
+ export declare function runSide(this: Ripples): void;
@@ -0,0 +1,27 @@
1
+ /** 原使用的样式 */
2
+ export type OriginStyle = {
3
+ /** 原始使用行内背景样式 */
4
+ inlineBackground: string;
5
+ /** 原始使用的行内背景色 */
6
+ inlineBackgroundColor: string;
7
+ /** 原始使用的背景图的样式 */
8
+ inlineBackgroundImage: string;
9
+ /** 元素的位置 */
10
+ position: string;
11
+ /** 元素的背景色 */
12
+ backgroundColor: string;
13
+ /** 元素的背景图 */
14
+ backgroundImage: string;
15
+ /** 元素的背景图的尺寸(多背景下) */
16
+ backgroundSize: string;
17
+ /** 元素的背景图的位置 */
18
+ backgroundPosition: string;
19
+ /** 元素的背景图的重复方式 */
20
+ backgroundRepeat: string;
21
+ /** 元素的背景图的剪切方式 */
22
+ backgroundClip: string;
23
+ /** 元素的背景图的起点 */
24
+ backgroundOrigin: string;
25
+ /** 元素的背景图相对视口的滚动方式 */
26
+ backgroundAttachment: string;
27
+ };
@@ -0,0 +1,3 @@
1
+ import { Ripples } from '../../ripplesClass';
2
+ /** 绑定图片 */
3
+ export declare function bindImage(this: Ripples, texImageSource: TexImageSource): void;
@@ -0,0 +1,3 @@
1
+ import { Ripples } from 'components/ripples';
2
+ /** 根据给出的 html 数据构建一个 canvas */
3
+ export declare function createCanvasElement(this: Ripples, img: CanvasImageSource): HTMLCanvasElement;
@@ -0,0 +1,2 @@
1
+ /** 根据给出的 src 获取一个 img 对象 */
2
+ export declare function createImageBySrc(src: string, width: number, height: number): HTMLImageElement;
@@ -0,0 +1,3 @@
1
+ import { OriginStyle } from '../type';
2
+ /** 获取元素的样式 */
3
+ export declare function getBackgroundStyles(element: HTMLElement): OriginStyle;
@@ -0,0 +1,10 @@
1
+ import { Ripples } from '../../ripplesClass';
2
+ /**
3
+ * ## 隐藏背景
4
+ *
5
+ * 触发于
6
+ * - 手动恢复背景 webGl 的显示
7
+ * - 初始化时隐藏
8
+ * - 父级样式属性发生变更的时候
9
+ */
10
+ export declare function hideCssBackground(this: Ripples): void;
@@ -0,0 +1,7 @@
1
+ import { Ripples } from '../../ripplesClass';
2
+ /**
3
+ * 恢复背景样式
4
+ *
5
+ * 在使用过程中,可能会切换 webGL 的显隐状态,而手动处理背景的更替
6
+ */
7
+ export declare function restoreCssBackground(this: Ripples): void;
@@ -0,0 +1,3 @@
1
+ import { Ripples } from '../ripplesClass';
2
+ /** 注销 */
3
+ export declare function destroy(this: Ripples): void;
@@ -0,0 +1,3 @@
1
+ import { Ripples } from '../ripplesClass';
2
+ /** 触发滴落效果 */
3
+ export declare function drop(this: Ripples, x: number, y: number, radius: number, strength: number): void;
@@ -0,0 +1,3 @@
1
+ import { Ripples } from '../ripplesClass';
2
+ /** 两个图像间的淡入淡出 */
3
+ export declare function fade(this: Ripples): void;
@@ -0,0 +1,6 @@
1
+ import { Ripples } from '../ripplesClass';
2
+ /**
3
+ * 重新加载背景图片
4
+ *
5
+ */
6
+ export declare function reloadBackground(this: Ripples): void;
@@ -0,0 +1,2 @@
1
+ /** 缩放效果 (暂未用到) */
2
+ export declare function scale(): void;
@@ -0,0 +1,40 @@
1
+ import { BackgroundRipplesProps, RipplesOptions } from './types';
2
+ import { Ripples } from './ripplesClass';
3
+ /**
4
+ *
5
+ * ## 使用绘制 ripples 上一层
6
+ *
7
+ *
8
+ * @param canvas `usrRef` 包裹的 `HTMLCanvasElement`,用于绘制图像
9
+ * @param props 初始化的
10
+ * @version 0.0.3
11
+ * @see https://earthnut.dev/use-ripples
12
+ * @see JQuery https://github.com/sirxemic/jquery.ripples
13
+ * @example
14
+ *
15
+ * 下面是在 <BackgroundRipple> 中使用
16
+ *
17
+ * ```ts
18
+ * import { useRipples } from 'earthnut/useRipples';
19
+ * // 也可以使用包全量导入
20
+ * // import { useRipples } from 'earthnut';
21
+ *
22
+ * export function BackgroundRipple(props: BackgroundRipplesProps) {
23
+ *
24
+ * // canvas 元素
25
+ * const canvas = useRef<HTMLCanvasElement>(null);
26
+ *
27
+ * // 使用 ripples
28
+ * const ripplesRef = useRipples(canvas, props);
29
+ *
30
+ * return (<>
31
+ * <canvas ref={canvas}></canvas>
32
+ * {props.children}
33
+ * </>);
34
+ * }
35
+ *
36
+ * ```
37
+ *
38
+ */
39
+ export declare function useRipples(canvas: React.RefObject<HTMLCanvasElement | null>, props?: BackgroundRipplesProps): React.RefObject<Ripples | null>;
40
+ export type { Ripples, BackgroundRipplesProps, RipplesOptions };
@@ -0,0 +1,5 @@
1
+ import { Ripples } from '../ripplesClass';
2
+ /**
3
+ * 初始化 webGL
4
+ */
5
+ export declare function initGL(this: Ripples): void;
@@ -0,0 +1,5 @@
1
+ import { Ripples } from '../ripplesClass';
2
+ /**
3
+ * 初始化事件
4
+ */
5
+ export declare function setupPointerEvents(this: Ripples): void;
@@ -0,0 +1,7 @@
1
+ import { Ripples } from '../ripplesClass';
2
+ /**
3
+ *
4
+ * 初始化着色器
5
+ *
6
+ */
7
+ export declare function initShaders(this: Ripples): void;
@@ -0,0 +1,7 @@
1
+ import { Ripples } from '../ripplesClass';
2
+ /**
3
+ *
4
+ * 初始化纹理
5
+ *
6
+ */
7
+ export declare function initTexture(this: Ripples): void;
@@ -0,0 +1,3 @@
1
+ import { Ripples } from '../ripplesClass';
2
+ /** 计算纹理边界及背景图 */
3
+ export declare function computeTextureBoundaries(this: Ripples): void;
@@ -0,0 +1,7 @@
1
+ import { Ripples } from '../ripplesClass';
2
+ /**
3
+ *
4
+ * 绘制
5
+ *
6
+ */
7
+ export declare function draw(this: Ripples): void;
@@ -0,0 +1,7 @@
1
+ import { Ripples } from '../ripplesClass';
2
+ /**
3
+ *
4
+ * 绘制 GL 数据流
5
+ *
6
+ */
7
+ export declare function drawQuad(this: Ripples): void;
@@ -0,0 +1,7 @@
1
+ import { Ripples } from '../ripplesClass';
2
+ /**
3
+ *
4
+ * 触发的点
5
+ *
6
+ */
7
+ export declare function dropAtPointer(this: Ripples, pointer: MouseEvent | Touch, radius: number, strength: number): void;
@@ -0,0 +1,6 @@
1
+ import { Ripples } from '../ripplesClass';
2
+ /**
3
+ * 开启绘制
4
+ *
5
+ */
6
+ export declare function render(this: Ripples): void;
@@ -0,0 +1,5 @@
1
+ import { Ripples } from '../ripplesClass';
2
+ /**
3
+ * swap 缓冲区索引
4
+ */
5
+ export declare function swapBufferIndices(this: Ripples): void;
@@ -0,0 +1,5 @@
1
+ import { Ripples } from '../ripplesClass';
2
+ /**
3
+ * 更新
4
+ */
5
+ export declare function update(this: Ripples): void;
@@ -0,0 +1,5 @@
1
+ import { RipplesUseOptions } from '../types';
2
+ /**
3
+ * 默认值
4
+ */
5
+ export declare const defaultData: RipplesUseOptions;
@@ -0,0 +1,29 @@
1
+ import { Ripples } from '../ripplesClass';
2
+ /** 背景渐变的数据 */
3
+ export declare class FadeData {
4
+ /** 背景页面的数据 */
5
+ backgroundInfo: {
6
+ width: number;
7
+ height: number;
8
+ };
9
+ /** 缺省背景图时的 id */
10
+ transparentId: NodeJS.Timeout;
11
+ /** 最后使用
12
+ *
13
+ * 如果没有 toBeList 为空值,则当前渲染的为此纹理)绘制的图像
14
+ */
15
+ lastDrawImage: HTMLCanvasElement | HTMLImageElement;
16
+ /** 当前绘制的图像
17
+ *
18
+ * 该值仅出现在需要渐变过程中,一旦渐变完成,实际渲染的值就成了最后渲染的值
19
+ */
20
+ toBeList: (HTMLCanvasElement | HTMLImageElement)[];
21
+ /** 绘制进度 */
22
+ drawProgress: number;
23
+ /** 是否处于绘制过渡状态 */
24
+ isTransitioning: boolean;
25
+ /** 执行渐变 */
26
+ run(): void;
27
+ /** 创建背景渐变的数据 */
28
+ constructor(_Ripples: Ripples);
29
+ }
@@ -0,0 +1,40 @@
1
+ /****************************************************************************
2
+ * @Author earthnut
3
+ * @Email earthnut.dev@outlook.com
4
+ * @ProjectName website
5
+ * @FileName dataStore.ts
6
+ * @CreateDate 周六 12/07/2024
7
+ * @Description 数据库
8
+ ****************************************************************************/
9
+ /**
10
+ * Ripple 使用的数据,Ripple 继承该类
11
+ */
12
+ export declare class RipplesData {
13
+ /**
14
+ * canvas 元素
15
+ */
16
+ canvas: HTMLCanvasElement;
17
+ /**
18
+ * WebGL 绘图上下文
19
+ */
20
+ gl: WebGLRenderingContext;
21
+ /**
22
+ * 配置
23
+ */
24
+ config: {
25
+ type: number;
26
+ linearSupport: boolean;
27
+ extensions: string[];
28
+ arrayType: Float32ArrayConstructor | null;
29
+ } | null;
30
+ /**
31
+ * 初始化情况
32
+ */
33
+ initState: boolean;
34
+ /**
35
+ * 构造方法
36
+ *
37
+ * @param canvas 传入 canvas 元素来初始化必要的数据
38
+ */
39
+ constructor(canvas: HTMLCanvasElement);
40
+ }
@@ -0,0 +1,19 @@
1
+ /****************************************************************************
2
+ * @Author earthnut
3
+ * @Email earthnut.dev@outlook.com
4
+ * @ProjectName website
5
+ * @FileName loadConfig.ts
6
+ * @CreateDate 周五 12/13/2024
7
+ * @Description 加载 config
8
+ ****************************************************************************/
9
+ import { RipplesData } from './index';
10
+ /**
11
+ * 执行的配置数据
12
+ *
13
+ */
14
+ export declare function loadConfig(this: RipplesData): {
15
+ type: number;
16
+ linearSupport: boolean;
17
+ arrayType: Float32ArrayConstructor | null;
18
+ extensions: string[];
19
+ } | null;
@@ -0,0 +1,72 @@
1
+ import { OriginStyle } from '../buildBackground/type';
2
+ import { Ripples } from '../ripplesClass';
3
+ import { Program, Textures } from '../types';
4
+ /**
5
+ *
6
+ * 原始数据类
7
+ *
8
+ * 记录了除参数数据外的运行数据
9
+ *
10
+ */
11
+ export declare class RipplesRenderData {
12
+ /** 渲染数据流
13
+ *
14
+ * 该值在 init 中进行初始化
15
+ */
16
+ quad: WebGLBuffer;
17
+ /**
18
+ * 上一次雨滴滴落的时间
19
+ *
20
+ * 该时间更新触发时机:
21
+ * - 2.2s 内没有事件触发
22
+ * - 鼠标交互更新
23
+ */
24
+ lastRaindropsFallTime: number;
25
+ /** canvas 父级元素 该值在主 class 中初始化 */
26
+ parentElement: HTMLElement;
27
+ /** 父级元素的属性变化监听者 */
28
+ mutationObserver: null | MutationObserver;
29
+ /** 父级尺寸变化监听者 */
30
+ resizeObserver: null | ResizeObserver;
31
+ /** 渲染程序 */
32
+ renderProgram: Program;
33
+ /** 图像资源的配置 */
34
+ imageSource: string;
35
+ /** 该值于初始化着色器时初始化 */
36
+ dropProgram: Program;
37
+ /** 更新流 */
38
+ updateProgram: Program;
39
+ /** 纹理 */
40
+ textures: Textures;
41
+ /** 背景纹理 */
42
+ backgroundTexture: WebGLTexture;
43
+ /** 纹理数据 */
44
+ textureDelta: Float32Array<ArrayBuffer>;
45
+ /** */
46
+ framebuffers: WebGLFramebuffer[];
47
+ /** */
48
+ bufferWriteIndex: number;
49
+ /** */
50
+ bufferReadIndex: number;
51
+ /** 最原始的样式 */
52
+ originStyle: OriginStyle;
53
+ /** 上一次使用的样式 */
54
+ lastUseStyle: OriginStyle;
55
+ /** 事件 */
56
+ events: {
57
+ mousemove: (e: MouseEvent) => void;
58
+ mousedown: (e: MouseEvent) => void;
59
+ touchmove: (e: TouchEvent) => void;
60
+ touchstart: (e: TouchEvent) => void;
61
+ };
62
+ /** 渲染 id */
63
+ animationFrameId: number;
64
+ /**
65
+ * 构建 Ripple 的渲染数据
66
+ *
67
+ * @param canvas 使用初始化的 Canvas 元素
68
+ * @param callback 执行的回调,这里要对页面背景进行更新
69
+ * @param _Ripples 上一个回调在使用中的 this
70
+ */
71
+ constructor(canvas: HTMLCanvasElement, callback: () => void, _Ripples: Ripples);
72
+ }