@webeach/gl-circular-progress 0.2.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 (86) hide show
  1. package/LICENSE +5 -0
  2. package/README.md +118 -0
  3. package/README.ru.md +120 -0
  4. package/docs/en/CircularProgressFire.md +105 -0
  5. package/docs/en/CircularProgressLiquid.md +106 -0
  6. package/lib/cjs/classes/BaseCircularProgress/BaseCircularProgress.js +151 -0
  7. package/lib/cjs/classes/BaseCircularProgress/BaseCircularProgress.js.map +1 -0
  8. package/lib/cjs/classes/BaseCircularProgress/constants.js +27 -0
  9. package/lib/cjs/classes/BaseCircularProgress/constants.js.map +1 -0
  10. package/lib/cjs/classes/BaseCircularProgress/index.js +8 -0
  11. package/lib/cjs/classes/BaseCircularProgress/index.js.map +1 -0
  12. package/lib/cjs/classes/CircularProgressFire/CircularProgressFire.js +299 -0
  13. package/lib/cjs/classes/CircularProgressFire/CircularProgressFire.js.map +1 -0
  14. package/lib/cjs/classes/CircularProgressFire/index.js +8 -0
  15. package/lib/cjs/classes/CircularProgressFire/index.js.map +1 -0
  16. package/lib/cjs/classes/CircularProgressFire/shaders/fragment.frag.js +6 -0
  17. package/lib/cjs/classes/CircularProgressFire/shaders/fragment.frag.js.map +1 -0
  18. package/lib/cjs/classes/CircularProgressFire/shaders/vertex.vert.js +6 -0
  19. package/lib/cjs/classes/CircularProgressFire/shaders/vertex.vert.js.map +1 -0
  20. package/lib/cjs/classes/CircularProgressLiquid/CircularProgressLiquid.js +306 -0
  21. package/lib/cjs/classes/CircularProgressLiquid/CircularProgressLiquid.js.map +1 -0
  22. package/lib/cjs/classes/CircularProgressLiquid/index.js +8 -0
  23. package/lib/cjs/classes/CircularProgressLiquid/index.js.map +1 -0
  24. package/lib/cjs/classes/CircularProgressLiquid/shaders/fragment.frag.js +6 -0
  25. package/lib/cjs/classes/CircularProgressLiquid/shaders/fragment.frag.js.map +1 -0
  26. package/lib/cjs/classes/CircularProgressLiquid/shaders/vertex.vert.js +6 -0
  27. package/lib/cjs/classes/CircularProgressLiquid/shaders/vertex.vert.js.map +1 -0
  28. package/lib/cjs/index.js +10 -0
  29. package/lib/cjs/index.js.map +1 -0
  30. package/lib/cjs/utils/hexToCss/hexToCss.js +22 -0
  31. package/lib/cjs/utils/hexToCss/hexToCss.js.map +1 -0
  32. package/lib/esm/classes/BaseCircularProgress/BaseCircularProgress.js +149 -0
  33. package/lib/esm/classes/BaseCircularProgress/BaseCircularProgress.js.map +1 -0
  34. package/lib/esm/classes/BaseCircularProgress/constants.js +22 -0
  35. package/lib/esm/classes/BaseCircularProgress/constants.js.map +1 -0
  36. package/lib/esm/classes/BaseCircularProgress/index.js +2 -0
  37. package/lib/esm/classes/BaseCircularProgress/index.js.map +1 -0
  38. package/lib/esm/classes/CircularProgressFire/CircularProgressFire.js +297 -0
  39. package/lib/esm/classes/CircularProgressFire/CircularProgressFire.js.map +1 -0
  40. package/lib/esm/classes/CircularProgressFire/index.js +2 -0
  41. package/lib/esm/classes/CircularProgressFire/index.js.map +1 -0
  42. package/lib/esm/classes/CircularProgressFire/shaders/fragment.frag.js +4 -0
  43. package/lib/esm/classes/CircularProgressFire/shaders/fragment.frag.js.map +1 -0
  44. package/lib/esm/classes/CircularProgressFire/shaders/vertex.vert.js +4 -0
  45. package/lib/esm/classes/CircularProgressFire/shaders/vertex.vert.js.map +1 -0
  46. package/lib/esm/classes/CircularProgressLiquid/CircularProgressLiquid.js +304 -0
  47. package/lib/esm/classes/CircularProgressLiquid/CircularProgressLiquid.js.map +1 -0
  48. package/lib/esm/classes/CircularProgressLiquid/index.js +2 -0
  49. package/lib/esm/classes/CircularProgressLiquid/index.js.map +1 -0
  50. package/lib/esm/classes/CircularProgressLiquid/shaders/fragment.frag.js +4 -0
  51. package/lib/esm/classes/CircularProgressLiquid/shaders/fragment.frag.js.map +1 -0
  52. package/lib/esm/classes/CircularProgressLiquid/shaders/vertex.vert.js +4 -0
  53. package/lib/esm/classes/CircularProgressLiquid/shaders/vertex.vert.js.map +1 -0
  54. package/lib/esm/index.js +3 -0
  55. package/lib/esm/index.js.map +1 -0
  56. package/lib/esm/utils/hexToCss/hexToCss.js +20 -0
  57. package/lib/esm/utils/hexToCss/hexToCss.js.map +1 -0
  58. package/lib/types/classes/BaseCircularProgress/BaseCircularProgress.d.ts +113 -0
  59. package/lib/types/classes/BaseCircularProgress/BaseCircularProgress.d.ts.map +1 -0
  60. package/lib/types/classes/BaseCircularProgress/constants.d.ts +21 -0
  61. package/lib/types/classes/BaseCircularProgress/constants.d.ts.map +1 -0
  62. package/lib/types/classes/BaseCircularProgress/index.d.ts +3 -0
  63. package/lib/types/classes/BaseCircularProgress/index.d.ts.map +1 -0
  64. package/lib/types/classes/BaseCircularProgress/types.d.ts +40 -0
  65. package/lib/types/classes/BaseCircularProgress/types.d.ts.map +1 -0
  66. package/lib/types/classes/CircularProgressFire/CircularProgressFire.d.ts +98 -0
  67. package/lib/types/classes/CircularProgressFire/CircularProgressFire.d.ts.map +1 -0
  68. package/lib/types/classes/CircularProgressFire/index.d.ts +3 -0
  69. package/lib/types/classes/CircularProgressFire/index.d.ts.map +1 -0
  70. package/lib/types/classes/CircularProgressFire/types.d.ts +12 -0
  71. package/lib/types/classes/CircularProgressFire/types.d.ts.map +1 -0
  72. package/lib/types/classes/CircularProgressLiquid/CircularProgressLiquid.d.ts +99 -0
  73. package/lib/types/classes/CircularProgressLiquid/CircularProgressLiquid.d.ts.map +1 -0
  74. package/lib/types/classes/CircularProgressLiquid/index.d.ts +3 -0
  75. package/lib/types/classes/CircularProgressLiquid/index.d.ts.map +1 -0
  76. package/lib/types/classes/CircularProgressLiquid/types.d.ts +13 -0
  77. package/lib/types/classes/CircularProgressLiquid/types.d.ts.map +1 -0
  78. package/lib/types/index.d.ts +3 -0
  79. package/lib/types/index.d.ts.map +1 -0
  80. package/lib/types/types/core.d.ts +4 -0
  81. package/lib/types/types/core.d.ts.map +1 -0
  82. package/lib/types/utils/hexToCss/hexToCss.d.ts +16 -0
  83. package/lib/types/utils/hexToCss/hexToCss.d.ts.map +1 -0
  84. package/lib/types/utils/hexToCss/index.d.ts +2 -0
  85. package/lib/types/utils/hexToCss/index.d.ts.map +1 -0
  86. package/package.json +121 -0
package/LICENSE ADDED
@@ -0,0 +1,5 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Ruslan Martynov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy...
package/README.md ADDED
@@ -0,0 +1,118 @@
1
+ <div align="center">
2
+ <img alt="gl-circular-progress" src="./assets/logo.svg" height="96">
3
+ <br><br><br>
4
+ <p>
5
+ <a href="https://www.npmjs.com/package/@webeach/gl-circular-progress">
6
+ <img src="https://img.shields.io/npm/v/@webeach/gl-circular-progress.svg?color=646fe1&labelColor=9B7AEF" alt="npm package" />
7
+ </a>
8
+ <a href="https://github.com/webeach/gl-circular-progress/actions">
9
+ <img src="https://img.shields.io/github/actions/workflow/status/webeach/gl-circular-progress/ci.yml?color=646fe1&labelColor=9B7AEF" alt="build" />
10
+ </a>
11
+ <a href="https://www.npmjs.com/package/@webeach/gl-circular-progress">
12
+ <img src="https://img.shields.io/npm/dm/@webeach/gl-circular-progress.svg?color=646fe1&labelColor=9B7AEF" alt="npm downloads" />
13
+ </a>
14
+ </p>
15
+ <p><a href="./README.md">🇺🇸 English version</a> | <a href="./README.ru.md">🇷🇺 Русская версия</a></p>
16
+ <p>Beautiful WebGL circular progress bars library (Fire and Liquid effects).</p>
17
+ <br>
18
+ <p><a href="https://webeach.github.io/gl-circular-progress">👀 View Demo</a></p>
19
+ </div>
20
+
21
+ ---
22
+
23
+ ## 💎 Features
24
+
25
+ - **WebGL Rendering.** High performance and smooth shader animations.
26
+ - **Stunning Effects.** Ready-to-use presets for `Fire` and `Liquid` simulation.
27
+ - **Fully Customizable.** Configure colors, thickness, speed, intensity, and other parameters.
28
+ - **Lightweight.** **Zero dependencies**, optimized code.
29
+ - **TypeScript.** Full typing out of the box.
30
+
31
+ ---
32
+
33
+ ## 📦 Installation
34
+
35
+ ```bash
36
+ npm install @webeach/gl-circular-progress
37
+ ```
38
+
39
+ or
40
+
41
+ ```bash
42
+ pnpm install @webeach/gl-circular-progress
43
+ ```
44
+
45
+ or
46
+
47
+ ```bash
48
+ yarn add @webeach/gl-circular-progress
49
+ ```
50
+
51
+ ---
52
+
53
+ ## 📥 Usage
54
+
55
+ ```ts
56
+ import { CircularProgressFire } from '@webeach/gl-circular-progress';
57
+
58
+ // Find canvas element
59
+ const canvas = document.getElementById('my-canvas');
60
+
61
+ // Initialize progress bar
62
+ const instance = new CircularProgressFire(canvas, {
63
+ colors: [0xff5a00, 0xff9a00],
64
+ progress: 0.5, // Initial value
65
+ speed: 1.5,
66
+ thickness: 15,
67
+ });
68
+
69
+ // Don't forget to clean up when removing the component
70
+ // instance.destroy();
71
+ ```
72
+
73
+ ---
74
+
75
+ ## 🛠 Classes and Documentation
76
+
77
+ The library provides two main classes with different visual effects:
78
+
79
+ ### 🔥 [CircularProgressFire](./docs/en/CircularProgressFire.md)
80
+ Circular progress with a dynamic fire effect. Supports configuration of fire intensity and color gradients.
81
+
82
+ ### 💧 [CircularProgressLiquid](./docs/en/CircularProgressLiquid.md)
83
+ Circular progress with a fluid liquid and metaballs effect. Supports "volume" configuration for creating a 3D lens effect.
84
+
85
+ ---
86
+
87
+ ## 🧩 Dependencies
88
+
89
+ The library has **Zero external dependencies** and is written in native WebGL.
90
+
91
+ ---
92
+
93
+ ## 🔖 Releasing
94
+
95
+ Releases are automated with `semantic-release`.
96
+
97
+ Before publishing a new version, make sure that:
98
+
99
+ 1. All changes are committed and pushed to `main`.
100
+ 2. Commit messages follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/):
101
+ - `feat: ...` — new features
102
+ - `fix: ...` — bug fixes
103
+ - `chore: ...`, `refactor: ...`, etc. — as needed
104
+ 3. The next version (`patch`, `minor`, `major`) is derived automatically from the commit types.
105
+
106
+ ---
107
+
108
+ ## 👤 Author
109
+
110
+ Developed and maintained by [Ruslan Martynov](https://github.com/ruslan-mart).
111
+
112
+ Have an idea or found a bug? Open an issue or send a pull request.
113
+
114
+ ---
115
+
116
+ ## 📄 License
117
+
118
+ This package is distributed under the [MIT License](./LICENSE).
package/README.ru.md ADDED
@@ -0,0 +1,120 @@
1
+ <div align="center">
2
+ <img alt="gl-circular-progress" src="./assets/logo.svg" height="96">
3
+ <br><br><br>
4
+ <p>
5
+ <a href="https://www.npmjs.com/package/@webeach/gl-circular-progress">
6
+ <img src="https://img.shields.io/npm/v/@webeach/gl-circular-progress.svg?color=646fe1&labelColor=9B7AEF" alt="npm package" />
7
+ </a>
8
+ <a href="https://github.com/webeach/gl-circular-progress/actions">
9
+ <img src="https://img.shields.io/github/actions/workflow/status/webeach/gl-circular-progress/ci.yml?color=646fe1&labelColor=9B7AEF" alt="build" />
10
+ </a>
11
+ <a href="https://www.npmjs.com/package/@webeach/gl-circular-progress">
12
+ <img src="https://img.shields.io/npm/dm/@webeach/gl-circular-progress.svg?color=646fe1&labelColor=9B7AEF" alt="npm downloads" />
13
+ </a>
14
+ </p>
15
+ <p><a href="./README.md">🇺🇸 English version</a> | <a href="./README.ru.md">🇷🇺 Русская версия</a></p>
16
+ <p>Библиотека красивых круговых прогресс-баров на WebGL (эффекты огня и жидкости).</p>
17
+ <br>
18
+ <p><a href="https://webeach.github.io/gl-circular-progress">👀 Смотреть Демо</a></p>
19
+ </div>
20
+
21
+ ---
22
+
23
+ ## 💎 Особенности
24
+
25
+ - **WebGL Рендеринг.** Высокая производительность и плавные анимации шейдеров.
26
+ - **Эффектные стили.** Готовые пресеты для имитации огня (`Fire`) и жидкости (`Liquid`).
27
+ - **Полная кастомизация.** Настройка цветов, толщины, скорости, интенсивности и других параметров.
28
+ - **Легковесность.** Полное отсутствие зависимостей (Zero dependencies), оптимизированный код.
29
+ - **TypeScript.** Полная типизация "из коробки".
30
+
31
+ ---
32
+
33
+ ## 📦 Установка
34
+
35
+ ```bash
36
+ npm install @webeach/gl-circular-progress
37
+ ```
38
+
39
+ или
40
+
41
+ ```bash
42
+ pnpm install @webeach/gl-circular-progress
43
+ ```
44
+
45
+ или
46
+
47
+ ```bash
48
+ yarn add @webeach/gl-circular-progress
49
+ ```
50
+
51
+ ---
52
+
53
+ ## 📥 Использование
54
+
55
+ ```ts
56
+ import { CircularProgressFire } from '@webeach/gl-circular-progress';
57
+
58
+ // Находим canvas элемент
59
+ const canvas = document.getElementById('my-canvas');
60
+
61
+ // Инициализируем прогресс-бар
62
+ const instance = new CircularProgressFire(canvas, {
63
+ colors: [0xff5a00, 0xff9a00],
64
+ progress: 0.5, // Начальное значение
65
+ speed: 1.5,
66
+ thickness: 15,
67
+ });
68
+
69
+ // Не забываем очищать при удалении компонента
70
+ // instance.destroy();
71
+ ```
72
+
73
+ ---
74
+
75
+ ## 🛠 Классы и Документация
76
+
77
+ Библиотека предоставляет два основных класса с различными визуальными эффектами:
78
+
79
+ ### 🔥 [CircularProgressFire](./docs/ru/CircularProgressFire.md)
80
+ Круговой прогресс с динамичным эффектом пламени. Поддерживает настройку интенсивности огня и цветовых градиентов.
81
+
82
+ ### 💧 [CircularProgressLiquid](./docs/ru/CircularProgressLiquid.md)
83
+ Круговой прогресс с эффектом текучей жидкости и метаболлов. Поддерживает настройку "объема" (volume) для создания 3D-эффекта линзы.
84
+
85
+ ---
86
+
87
+ ## 🧩 Зависимости
88
+
89
+ Библиотека не имеет внешних зависимостей (**Zero dependencies**) и написана на нативном WebGL.
90
+
91
+ ---
92
+
93
+ ## 🔖 Выпуск новой версии
94
+
95
+ Релизы обрабатываются автоматически с помощью `semantic-release`.
96
+
97
+ Перед публикацией новой версии убедись, что:
98
+
99
+ 1. Все изменения закоммичены и запушены в ветку `main`.
100
+ 2. Сообщения коммитов соответствуют формату [Conventional Commits](https://www.conventionalcommits.org/ru/v1.0.0/):
101
+ - `feat: ...` — для новых фич
102
+ - `fix: ...` — для исправлений багов
103
+ - `chore: ...`, `refactor: ...` и другие типы — по необходимости
104
+ 3. Версионирование определяется автоматически на основе типа коммитов (`patch`, `minor`, `major`).
105
+
106
+ ---
107
+
108
+ ## 👨‍💻 Автор
109
+
110
+ Разработка и поддержка: [Руслан Мартынов](https://github.com/ruslan-mart)
111
+
112
+ Если у тебя есть предложения или найден баг, открывай issue или отправляй pull request.
113
+
114
+ ---
115
+
116
+ ## 📄 Лицензия
117
+
118
+ Этот пакет распространяется под [лицензией MIT](./LICENSE).
119
+
120
+
@@ -0,0 +1,105 @@
1
+ # CircularProgressFire
2
+
3
+ ## Description
4
+
5
+ `CircularProgressFire` is a class for creating a circular progress bar with a **fire** effect using WebGL.
6
+ It allows flexible customization of colors, speed, and intensity of the flame.
7
+
8
+ The effect is rendered on the provided HTML `<canvas>` element.
9
+
10
+ [👀 View Demo](https://webeach.github.io/gl-circular-progress/CircularProgressFire.html)
11
+
12
+ ---
13
+
14
+ ## Signature
15
+
16
+ ```ts
17
+ new CircularProgressFire(container: HTMLCanvasElement, options: CircularProgressFireOptions)
18
+ ```
19
+
20
+ - **Parameters**
21
+ - `container: HTMLCanvasElement` — the canvas element where the progress will be rendered.
22
+ - `options: CircularProgressFireOptions` — configuration object.
23
+
24
+ ---
25
+
26
+ ## Examples
27
+
28
+ ### Basic Usage
29
+
30
+ ```ts
31
+ import { CircularProgressFire } from '@webeach/gl-circular-progress';
32
+
33
+ const canvas = document.getElementById('canvas') as HTMLCanvasElement;
34
+
35
+ const instance = new CircularProgressFire(canvas, {
36
+ colors: [0xff5a00, 0xff9a00, 0xffce00], // Fire colors
37
+ intensity: 1.0,
38
+ progress: 0.75, // Initial value
39
+ speed: 1.5,
40
+ thickness: 20,
41
+ });
42
+ ```
43
+
44
+ ### Dynamic Updates
45
+
46
+ All properties can be changed on the fly using the instance setters.
47
+
48
+ ```ts
49
+ instance.colors = [0xff0000, 0x00ff00]; // Change gradient
50
+ instance.intensity = 0.5; // Reduce fire intensity
51
+ instance.speed = 2.0; // Speed up animation
52
+ ```
53
+
54
+ ---
55
+
56
+ ## API
57
+
58
+ ### Options (`CircularProgressFireOptions`)
59
+
60
+ Configuration object passed to the constructor.
61
+
62
+ | Property | Type | Default | Description |
63
+ |---|---|---|---|
64
+ | `colors` | `number[]` | `[0x000000]` | **Required.** Array of HEX colors (e.g. `0xff5a00`). Used for the gradient. |
65
+ | `intensity` | `number` | `1.0` | Intensity of the fire effect. |
66
+ | `progress` | `number` | `0` | Initial progress value (0.0 to 1.0). |
67
+ | `reversed` | `boolean` | `false` | Fill direction. If `true`, progress fills counter-clockwise. |
68
+ | `speed` | `number` | `1.0` | Animation speed of the flame. |
69
+ | `startAngle` | `number` | `0` | Starting angle of the progress in degrees. |
70
+ | `thickness` | `number` | `10` | Thickness of the progress ring in pixels. |
71
+
72
+ ### Instance Methods and Properties
73
+
74
+ After creating an instance, the following methods and properties are available:
75
+
76
+ #### `destroy(): void`
77
+
78
+ Cleans up WebGL resources, removes event listeners (resize), and stops the animation. Must be called before removing the component.
79
+
80
+ #### Properties
81
+
82
+ The following properties can be read and written for dynamic updates:
83
+
84
+ - `colors`: `number[]`
85
+ - `intensity`: `number`
86
+ - `progress`: `number`
87
+ - `reversed`: `boolean`
88
+ - `speed`: `number`
89
+ - `startAngle`: `number`
90
+ - `thickness`: `number`
91
+
92
+ ---
93
+
94
+ ## Typing
95
+
96
+ ```ts
97
+ import type { CircularProgressFireOptions } from '@webeach/gl-circular-progress';
98
+ ```
99
+
100
+ ---
101
+
102
+ ## See Also
103
+
104
+ - [CircularProgressLiquid](./CircularProgressLiquid.md) — liquid effect.
105
+
@@ -0,0 +1,106 @@
1
+ # CircularProgressLiquid
2
+
3
+ ## Description
4
+
5
+ `CircularProgressLiquid` is a class for creating a circular progress bar with a **liquid** (metaballs) effect using WebGL.
6
+ It allows creating smooth animations with customizable volume distortion (lens effect).
7
+
8
+ The effect is rendered on the provided HTML `<canvas>` element.
9
+
10
+ [👀 View Demo](https://webeach.github.io/gl-circular-progress/CircularProgressLiquid.html)
11
+
12
+ ---
13
+
14
+ ## Signature
15
+
16
+ ```ts
17
+ new CircularProgressLiquid(container: HTMLCanvasElement, options: CircularProgressLiquidOptions)
18
+ ```
19
+
20
+ - **Parameters**
21
+ - `container: HTMLCanvasElement` — the canvas element where the progress will be rendered.
22
+ - `options: CircularProgressLiquidOptions` — configuration object.
23
+
24
+ ---
25
+
26
+ ## Examples
27
+
28
+ ### Basic Usage
29
+
30
+ ```ts
31
+ import { CircularProgressLiquid } from '@webeach/gl-circular-progress/CircularProgressLiquid';
32
+
33
+ const canvas = document.getElementById('canvas') as HTMLCanvasElement;
34
+
35
+ const instance = new CircularProgressLiquid(canvas, {
36
+ colors: [0x00c6ff, 0x0072ff], // Liquid colors
37
+ progress: 0.6, // Initial value
38
+ speed: 0.5,
39
+ startAngle: -90, // Start from left
40
+ thickness: 30,
41
+ volume: 0.5, // Volume/Lens effect
42
+ });
43
+ ```
44
+
45
+ ### Dynamic Updates
46
+
47
+ All properties can be changed on the fly using the instance setters.
48
+
49
+ ```ts
50
+ instance.speed = 1.2; // Speed up flow
51
+ instance.volume = 0.8; // Increase lens effect
52
+ instance.reversed = true; // Change direction
53
+ ```
54
+
55
+ ---
56
+
57
+ ## API
58
+
59
+ ### Options (`CircularProgressLiquidOptions`)
60
+
61
+ Configuration object passed to the constructor.
62
+
63
+ | Property | Type | Default | Description |
64
+ |---|---|---|---|
65
+ | `colors` | `number[]` | `[0x000000]` | **Required.** Array of HEX colors. Used for the liquid gradient. |
66
+ | `progress` | `number` | `0` | Initial progress value (0.0 to 1.0). |
67
+ | `reversed` | `boolean` | `false` | Fill direction. If `true`, progress fills counter-clockwise. |
68
+ | `speed` | `number` | `1.0` | Animation speed of the liquid waves. |
69
+ | `startAngle` | `number` | `0` | Starting angle of the progress in degrees. |
70
+ | `thickness` | `number` | `10` | Thickness of the progress ring in pixels. |
71
+ | `volume` | `number` | `0` | Volume effect (lens/3D). Value from `0.0` (flat) to `1.0` (strong effect). |
72
+
73
+ ### Instance Methods and Properties
74
+
75
+ After creating an instance, the following methods and properties are available:
76
+
77
+ #### `destroy(): void`
78
+
79
+ Cleans up WebGL resources, removes event listeners, and stops the animation. Must be called before removing the component.
80
+
81
+ #### Properties
82
+
83
+ The following properties can be read and written for dynamic updates:
84
+
85
+ - `colors`: `number[]`
86
+ - `progress`: `number`
87
+ - `reversed`: `boolean`
88
+ - `speed`: `number`
89
+ - `startAngle`: `number`
90
+ - `thickness`: `number`
91
+ - `volume`: `number`
92
+
93
+ ---
94
+
95
+ ## Typing
96
+
97
+ ```ts
98
+ import type { CircularProgressLiquidOptions } from '@webeach/gl-circular-progress/CircularProgressLiquid';
99
+ ```
100
+
101
+ ---
102
+
103
+ ## See Also
104
+
105
+ - [CircularProgressFire](./CircularProgressFire.md) — fire effect.
106
+
@@ -0,0 +1,151 @@
1
+ 'use strict';
2
+
3
+ var constants = require('./constants.js');
4
+
5
+ /**
6
+ * Abstract base class for circular progress indicators.
7
+ * Handles common state and lifecycle management.
8
+ */
9
+ class BaseCircularProgress {
10
+ state;
11
+ canvas;
12
+ canvasHeight = 0;
13
+ canvasWidth = 0;
14
+ dpr = 1;
15
+ isDestroyed = false;
16
+ resizeObserver = null;
17
+ /**
18
+ * Creates an instance of BaseCircularProgress.
19
+ *
20
+ * @param canvas - The HTMLCanvasElement to render on.
21
+ * @param options - Configuration options.
22
+ */
23
+ constructor(canvas, options) {
24
+ this.canvas = canvas;
25
+ this.dpr = window.devicePixelRatio;
26
+ this.state = {
27
+ colors: [...options.colors],
28
+ progress: options.progress ?? 0,
29
+ reversed: options.reversed ?? constants.DEFAULT_REVERSED,
30
+ speed: options.speed ?? constants.DEFAULT_SPEED,
31
+ startAngle: options.startAngle ?? constants.DEFAULT_START_ANGLE,
32
+ thickness: options.thickness ?? constants.DEFAULT_THICKNESS,
33
+ };
34
+ this.handleResize = this.handleResize.bind(this);
35
+ this.resizeObserver = new ResizeObserver(this.handleResize);
36
+ this.resizeObserver.observe(this.canvas);
37
+ window.addEventListener('resize', this.handleResize);
38
+ }
39
+ /**
40
+ * Cleans up resources, event listeners, and stops animations.
41
+ * Must be called when the instance is no longer needed.
42
+ */
43
+ destroy() {
44
+ this.isDestroyed = true;
45
+ if (this.resizeObserver) {
46
+ this.resizeObserver.disconnect();
47
+ this.resizeObserver = null;
48
+ }
49
+ window.removeEventListener('resize', this.handleResize);
50
+ }
51
+ /**
52
+ * Gets the current colors array.
53
+ */
54
+ get colors() {
55
+ return [...this.state.colors];
56
+ }
57
+ /**
58
+ * Sets the colors array and updates rendering.
59
+ */
60
+ set colors(value) {
61
+ this.state.colors = [...value];
62
+ this.updateColors();
63
+ }
64
+ /**
65
+ * Gets the current progress value.
66
+ */
67
+ get progress() {
68
+ return this.state.progress;
69
+ }
70
+ /**
71
+ * Sets the progress value.
72
+ */
73
+ set progress(value) {
74
+ const clamped = Math.max(0, Math.min(1, value));
75
+ this.state.progress = clamped;
76
+ this.updateProgress(clamped);
77
+ }
78
+ /**
79
+ * Gets whether the progress fills in reverse direction.
80
+ */
81
+ get reversed() {
82
+ return this.state.reversed;
83
+ }
84
+ /**
85
+ * Sets the reverse direction flag and updates rendering.
86
+ */
87
+ set reversed(value) {
88
+ this.state.reversed = value;
89
+ this.updateReversed();
90
+ }
91
+ /**
92
+ * Gets the current animation speed.
93
+ */
94
+ get speed() {
95
+ return this.state.speed;
96
+ }
97
+ /**
98
+ * Sets the animation speed and updates rendering.
99
+ */
100
+ set speed(value) {
101
+ this.state.speed = value;
102
+ this.updateSpeed();
103
+ }
104
+ /**
105
+ * Gets the current start angle in degrees.
106
+ */
107
+ get startAngle() {
108
+ return this.state.startAngle;
109
+ }
110
+ /**
111
+ * Sets the start angle and updates rendering.
112
+ */
113
+ set startAngle(value) {
114
+ this.state.startAngle = value;
115
+ this.updateStartAngle();
116
+ }
117
+ /**
118
+ * Gets the current thickness in pixels.
119
+ */
120
+ get thickness() {
121
+ return this.state.thickness;
122
+ }
123
+ /**
124
+ * Sets the thickness and updates rendering.
125
+ */
126
+ set thickness(value) {
127
+ this.state.thickness = value;
128
+ this.updateThickness();
129
+ }
130
+ /**
131
+ * Handles canvas resize events from ResizeObserver.
132
+ * Updates canvas dimensions with devicePixelRatio and calls resize().
133
+ */
134
+ handleResize() {
135
+ const dpr = window.devicePixelRatio || 1;
136
+ const displayWidth = this.canvas.clientWidth;
137
+ const displayHeight = this.canvas.clientHeight;
138
+ this.canvasWidth = Math.floor(displayWidth * dpr);
139
+ this.canvasHeight = Math.floor(displayHeight * dpr);
140
+ this.dpr = dpr;
141
+ if (this.canvas.width !== this.canvasWidth ||
142
+ this.canvas.height !== this.canvasHeight) {
143
+ this.canvas.width = this.canvasWidth;
144
+ this.canvas.height = this.canvasHeight;
145
+ }
146
+ this.resize();
147
+ }
148
+ }
149
+
150
+ exports.BaseCircularProgress = BaseCircularProgress;
151
+ //# sourceMappingURL=BaseCircularProgress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseCircularProgress.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Default colors (Black).
5
+ */
6
+ /**
7
+ * Default reversed state (false).
8
+ */
9
+ const DEFAULT_REVERSED = false;
10
+ /**
11
+ * Default animation speed (1.0).
12
+ */
13
+ const DEFAULT_SPEED = 1.0;
14
+ /**
15
+ * Default start angle (0 degrees).
16
+ */
17
+ const DEFAULT_START_ANGLE = 0;
18
+ /**
19
+ * Default thickness (10px).
20
+ */
21
+ const DEFAULT_THICKNESS = 10;
22
+
23
+ exports.DEFAULT_REVERSED = DEFAULT_REVERSED;
24
+ exports.DEFAULT_SPEED = DEFAULT_SPEED;
25
+ exports.DEFAULT_START_ANGLE = DEFAULT_START_ANGLE;
26
+ exports.DEFAULT_THICKNESS = DEFAULT_THICKNESS;
27
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ var BaseCircularProgress = require('./BaseCircularProgress.js');
4
+
5
+
6
+
7
+ exports.BaseCircularProgress = BaseCircularProgress.BaseCircularProgress;
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}