@next2d/filters 2.13.1 → 3.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 (2) hide show
  1. package/README.md +249 -5
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,11 +1,255 @@
1
- @next2d/filters
2
- =============
1
+ # @next2d/filters
3
2
 
4
- ## Installation
3
+ **Important**: `@next2d/filters` prohibits importing other packages. This package is a foundational module that must remain independent to avoid circular dependencies.
5
4
 
6
- ```
5
+ **重要**: `@next2d/filters` は他の packages の import を禁止しています。このパッケージは基盤モジュールであり、循環依存を避けるために独立を維持する必要があります。
6
+
7
+ ## Overview / 概要
8
+
9
+ **English:**
10
+ The `@next2d/filters` package provides GPU-accelerated visual effect filters for DisplayObjects in the Next2D player. This package includes a comprehensive set of bitmap filter effects that can be applied to any display object, offering high-performance image processing capabilities powered by WebGL/WebGPU.
11
+
12
+ **日本語:**
13
+ `@next2d/filters` パッケージは、Next2D プレイヤーの DisplayObject に対して GPU アクセラレーションによる視覚エフェクトフィルターを提供します。このパッケージには、任意の表示オブジェクトに適用可能なビットマップフィルター効果の包括的なセットが含まれており、WebGL/WebGPU によって高速化された画像処理機能を提供します。
14
+
15
+ ## Installation / インストール
16
+
17
+ ```bash
7
18
  npm install @next2d/filters
8
19
  ```
9
20
 
10
- ## License
21
+ ## Directory Structure / ディレクトリ構造
22
+
23
+ ```
24
+ src/
25
+ ├── BitmapFilter.ts # Base class for all filters / すべてのフィルターの基底クラス
26
+ ├── BlurFilter.ts # Blur effect filter / ぼかし効果フィルター
27
+ ├── GlowFilter.ts # Glow effect filter / グロー効果フィルター
28
+ ├── DropShadowFilter.ts # Drop shadow effect filter / ドロップシャドウ効果フィルター
29
+ ├── BevelFilter.ts # Bevel effect filter / ベベル効果フィルター
30
+ ├── ColorMatrixFilter.ts # Color matrix transformation filter / カラーマトリックス変換フィルター
31
+ ├── ConvolutionFilter.ts # Convolution matrix filter / 畳み込みマトリックスフィルター
32
+ ├── DisplacementMapFilter.ts # Displacement map filter / ディスプレイスメントマップフィルター
33
+ ├── GradientBevelFilter.ts # Gradient bevel effect filter / グラデーションベベル効果フィルター
34
+ ├── GradientGlowFilter.ts # Gradient glow effect filter / グラデーショングロー効果フィルター
35
+ ├── FilterUtil.ts # Utility functions for filters / フィルター用ユーティリティ関数
36
+ │
37
+ ├── interface/ # Type definitions / 型定義
38
+ │ ├── IBitmapDataChannel.ts
39
+ │ ├── IBitmapFilterType.ts
40
+ │ ├── IBounds.ts
41
+ │ ├── IDisplacementMapFilterMode.ts
42
+ │ └── IFilterQuality.ts
43
+ │
44
+ ├── BlurFilter/
45
+ │ ├── service/ # Business logic services / ビジネスロジックサービス
46
+ │ │ ├── BlurFilterCanApplyFilterService.ts
47
+ │ │ ├── BlurFilterToArrayService.ts
48
+ │ │ └── BlurFilterToNumberArrayService.ts
49
+ │ └── usecase/ # Use case implementations / ユースケース実装
50
+ │ └── BlurFilterGetBoundsUseCase.ts
51
+ │
52
+ ├── GlowFilter/
53
+ │ ├── service/
54
+ │ │ ├── GlowFilterCanApplyFilterService.ts
55
+ │ │ ├── GlowFilterToArrayService.ts
56
+ │ │ └── GlowFilterToNumberArrayService.ts
57
+ │ └── usecase/
58
+ │ └── GlowFilterGetBoundsUseCase.ts
59
+ │
60
+ ├── DropShadowFilter/
61
+ │ ├── service/
62
+ │ │ ├── DropShadowFilterCanApplyFilterService.ts
63
+ │ │ ├── DropShadowFilterToArrayService.ts
64
+ │ │ └── DropShadowFilterToNumberArrayService.ts
65
+ │ └── usecase/
66
+ │ └── DropShadowFilterGetBoundsUseCase.ts
67
+ │
68
+ ├── BevelFilter/
69
+ │ ├── service/
70
+ │ │ ├── BevelFilterCanApplyFilterService.ts
71
+ │ │ ├── BevelFilterToArrayService.ts
72
+ │ │ └── BevelFilterToNumberArrayService.ts
73
+ │ └── usecase/
74
+ │ └── BevelFilterGetBoundsUseCase.ts
75
+ │
76
+ ├── ColorMatrixFilter/
77
+ │ └── service/
78
+ │ ├── ColorMatrixFilterToArrayService.ts
79
+ │ └── ColorMatrixFilterToNumberArrayService.ts
80
+ │
81
+ ├── ConvolutionFilter/
82
+ │ └── service/
83
+ │ ├── ConvolutionFilterCanApplyFilterService.ts
84
+ │ ├── ConvolutionFilterToArrayService.ts
85
+ │ └── ConvolutionFilterToNumberArrayService.ts
86
+ │
87
+ ├── DisplacementMapFilter/
88
+ │ └── service/
89
+ │ ├── DisplacementMapFilterCanApplyFilterService.ts
90
+ │ ├── DisplacementMapFilterToArrayService.ts
91
+ │ └── DisplacementMapFilterToNumberArrayService.ts
92
+ │
93
+ ├── GradientBevelFilter/
94
+ │ ├── service/
95
+ │ │ ├── GradientBevelFilterCanApplyFilterService.ts
96
+ │ │ ├── GradientBevelFilterToArrayService.ts
97
+ │ │ └── GradientBevelFilterToNumberArrayService.ts
98
+ │ └── usecase/
99
+ │ └── GradientBevelFilterGetBoundsUseCase.ts
100
+ │
101
+ └── GradientGlowFilter/
102
+ ├── service/
103
+ │ ├── GradientGlowFilterCanApplyFilterService.ts
104
+ │ ├── GradientGlowFilterToArrayService.ts
105
+ │ └── GradientGlowFilterToNumberArrayService.ts
106
+ └── usecase/
107
+ └── GradientGlowFilterGetBoundsUseCase.ts
108
+ ```
109
+
110
+ ## Available Filters / 利用可能なフィルター
111
+
112
+ ### BitmapFilter
113
+ **English:** Base class for all image filter effects. All filter classes extend this base class.
114
+ **日本語:** すべてのイメージフィルター効果の基底クラス。すべてのフィルタークラスはこの基底クラスを継承します。
115
+
116
+ ### BlurFilter
117
+ **English:** Applies a blur visual effect to display objects. Softens image details, ranging from a soft focus to a Gaussian blur effect.
118
+ **日本語:** 表示オブジェクトにぼかし効果を適用します。ソフトフォーカスからガウスぼかしまで、イメージの細部をぼかします。
119
+
120
+ ### GlowFilter
121
+ **English:** Applies a glow effect to display objects. Supports inner glow, outer glow, and knockout modes.
122
+ **日本語:** 表示オブジェクトにグロー効果を適用します。内側グロー、外側グロー、ノックアウトモードをサポートします。
123
+
124
+ ### DropShadowFilter
125
+ **English:** Adds a drop shadow effect to display objects. Creates the visual effect of an object casting a shadow.
126
+ **日本語:** 表示オブジェクトにドロップシャドウ効果を追加します。オブジェクトが影を落とす視覚効果を作成します。
127
+
128
+ ### BevelFilter
129
+ **English:** Adds a bevel effect that gives objects a three-dimensional appearance with highlights and shadows.
130
+ **日本語:** ハイライトとシャドウを使用してオブジェクトに立体的な外観を与えるベベル効果を追加します。
131
+
132
+ ### ColorMatrixFilter
133
+ **English:** Applies color transformation using a 4x5 matrix. Enables advanced color manipulation and effects.
134
+ **日本語:** 4x5 マトリックスを使用してカラー変換を適用します。高度なカラー操作とエフェクトを可能にします。
135
+
136
+ ### ConvolutionFilter
137
+ **English:** Applies a convolution matrix filter for custom image processing effects like sharpening, edge detection, and embossing.
138
+ **日本語:** 鮮鋭化、エッジ検出、エンボスなどのカスタム画像処理効果のための畳み込みマトリックスフィルターを適用します。
139
+
140
+ ### DisplacementMapFilter
141
+ **English:** Uses pixel values from a BitmapData object to displace pixels in the filtered object, creating distortion effects.
142
+ **日本語:** BitmapData オブジェクトのピクセル値を使用してフィルター適用オブジェクトのピクセルを変位させ、歪み効果を作成します。
143
+
144
+ ### GradientBevelFilter
145
+ **English:** Produces a bevel effect with gradient color transitions for more sophisticated three-dimensional appearances.
146
+ **日本語:** グラデーションカラー遷移を使用したベベル効果を生成し、より洗練された立体的な外観を作成します。
147
+
148
+ ### GradientGlowFilter
149
+ **English:** Applies a glow effect with gradient color transitions for enhanced visual depth and richness.
150
+ **日本語:** グラデーションカラー遷移を使用したグロー効果を適用し、視覚的な深みと豊かさを向上させます。
151
+
152
+ ## Filter Application Pipeline / フィルター適用パイプライン
153
+
154
+ ```mermaid
155
+ flowchart TD
156
+ Start([DisplayObject with filters]) --> Check{canApplyFilter?}
157
+ Check -->|No| Skip[Skip filter]
158
+ Check -->|Yes| GetBounds[Calculate filter bounds]
159
+
160
+ GetBounds --> ToArray[Convert filter to array]
161
+ ToArray --> ToNumberArray[Convert to number array]
162
+
163
+ ToNumberArray --> GPU[GPU Processing]
164
+
165
+ GPU --> BlurType{Filter Type}
166
+
167
+ BlurType -->|BlurFilter| Blur[Apply Blur Shader]
168
+ BlurType -->|GlowFilter| Glow[Apply Glow Shader]
169
+ BlurType -->|DropShadowFilter| Shadow[Apply Shadow Shader]
170
+ BlurType -->|BevelFilter| Bevel[Apply Bevel Shader]
171
+ BlurType -->|ColorMatrixFilter| ColorMatrix[Apply Color Matrix Shader]
172
+ BlurType -->|ConvolutionFilter| Convolution[Apply Convolution Shader]
173
+ BlurType -->|DisplacementMapFilter| Displacement[Apply Displacement Shader]
174
+ BlurType -->|GradientBevelFilter| GradientBevel[Apply Gradient Bevel Shader]
175
+ BlurType -->|GradientGlowFilter| GradientGlow[Apply Gradient Glow Shader]
176
+
177
+ Blur --> Render[Render to texture]
178
+ Glow --> Render
179
+ Shadow --> Render
180
+ Bevel --> Render
181
+ ColorMatrix --> Render
182
+ Convolution --> Render
183
+ Displacement --> Render
184
+ GradientBevel --> Render
185
+ GradientGlow --> Render
186
+ Skip --> End
187
+
188
+ Render --> End([Filtered DisplayObject])
189
+
190
+ style Start fill:#e1f5ff
191
+ style End fill:#e1f5ff
192
+ style GPU fill:#fff4e1
193
+ style Render fill:#f0e1ff
194
+ style Check fill:#ffe1e1
195
+ ```
196
+
197
+ ## Architecture / アーキテクチャ
198
+
199
+ **English:**
200
+ Each filter follows a clean architecture pattern with separation of concerns:
201
+
202
+ - **Filter Class**: Main filter implementation extending `BitmapFilter`
203
+ - **Service Layer**: Business logic for filter operations (validation, conversion, serialization)
204
+ - **UseCase Layer**: Specific use cases like bounds calculation
205
+ - **Interface Layer**: Type definitions and contracts
206
+
207
+ This architecture ensures maintainability, testability, and scalability of the filter system.
208
+
209
+ **日本語:**
210
+ 各フィルターは、関心の分離を伴うクリーンアーキテクチャパターンに従っています:
211
+
212
+ - **フィルタークラス**: `BitmapFilter` を継承するメインのフィルター実装
213
+ - **サービス層**: フィルター操作のビジネスロジック(検証、変換、シリアライゼーション)
214
+ - **ユースケース層**: バウンズ計算などの特定のユースケース
215
+ - **インターフェース層**: 型定義と契約
216
+
217
+ このアーキテクチャにより、フィルターシステムの保守性、テスト可能性、スケーラビリティが保証されます。
218
+
219
+ ## Usage Example / 使用例
220
+
221
+ ```typescript
222
+ import { BlurFilter, GlowFilter, DropShadowFilter } from '@next2d/filters';
223
+
224
+ // Create a blur filter / ぼかしフィルターを作成
225
+ const blur = new BlurFilter(4, 4, 3);
226
+
227
+ // Create a glow filter / グローフィルターを作成
228
+ const glow = new GlowFilter(0xff0000, 0.8, 10, 10, 2, 3);
229
+
230
+ // Create a drop shadow filter / ドロップシャドウフィルターを作成
231
+ const shadow = new DropShadowFilter(4, 45, 0x000000, 0.8, 4, 4, 1, 3);
232
+
233
+ // Apply to display object / 表示オブジェクトに適用
234
+ displayObject.filters = [blur, glow, shadow];
235
+ ```
236
+
237
+ ## Performance Considerations / パフォーマンスに関する考慮事項
238
+
239
+ **English:**
240
+ - All filters are GPU-accelerated using WebGL/WebGPU shaders
241
+ - Filter quality settings affect performance and visual output
242
+ - Multiple filters are processed in sequence
243
+ - Bounds calculation is optimized for minimal overhead
244
+
245
+ **日本語:**
246
+ - すべてのフィルターは WebGL/WebGPU シェーダーを使用して GPU アクセラレーションされています
247
+ - フィルターの品質設定はパフォーマンスと視覚出力に影響します
248
+ - 複数のフィルターは順番に処理されます
249
+ - バウンズ計算は最小限のオーバーヘッドに最適化されています
250
+
251
+ ## License / ライセンス
252
+
11
253
  This project is licensed under the [MIT License](https://opensource.org/licenses/MIT) - see the [LICENSE](LICENSE) file for details.
254
+
255
+ このプロジェクトは [MIT ライセンス](https://opensource.org/licenses/MIT)の下でライセンスされています - 詳細については [LICENSE](LICENSE) ファイルを参照してください。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next2d/filters",
3
- "version": "2.13.1",
3
+ "version": "3.0.1",
4
4
  "description": "Next2D Filters Package",
5
5
  "author": "Toshiyuki Ienaga<ienaga@next2d.app> (https://github.com/ienaga/)",
6
6
  "license": "MIT",