@next2d/ui 2.13.0 → 3.0.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 (2) hide show
  1. package/README.md +292 -5
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,11 +1,298 @@
1
- @next2d/ui
2
- =============
1
+ # @next2d/ui
3
2
 
4
- ## Installation
3
+ Animation utilities package for Next2D Player / Next2Dプレイヤー向けアニメーションユーティリティパッケージ
5
4
 
6
- ```
5
+ ## Overview / 概要
6
+
7
+ `@next2d/ui` provides a powerful animation system with Tween and comprehensive Easing functions for creating smooth, professional animations in your Next2D applications.
8
+
9
+ `@next2d/ui` は、Next2Dアプリケーションでスムーズでプロフェッショナルなアニメーションを作成するための、TweenとEasing機能を備えた強力なアニメーションシステムを提供します。
10
+
11
+ ### Key Features / 主な機能
12
+
13
+ - **Tween System**: Easy-to-use tweening API for animating object properties / オブジェクトプロパティをアニメーションするための使いやすいトゥイーンAPI
14
+ - **Easing Functions**: 32 built-in easing functions for natural motion / 自然な動きのための32種類のイージング関数
15
+ - **Job Chaining**: Chain multiple animations sequentially / 複数のアニメーションを連続して実行
16
+ - **Event-Driven**: EventDispatcher-based architecture for animation lifecycle events / アニメーションライフサイクルイベント用のEventDispatcherベースアーキテクチャ
17
+
18
+ ## Installation / インストール
19
+
20
+ ```bash
7
21
  npm install @next2d/ui
8
22
  ```
9
23
 
10
- ## License
24
+ ## Usage / 使い方
25
+
26
+ ### Basic Tween Animation / 基本的なトゥイーンアニメーション
27
+
28
+ ```typescript
29
+ import { Tween, Easing } from "@next2d/ui";
30
+
31
+ // Create a target object / 対象オブジェクトを作成
32
+ const sprite = { x: 0, y: 0, alpha: 1 };
33
+
34
+ // Create a tween animation / トゥイーンアニメーションを作成
35
+ const job = Tween.add(
36
+ sprite, // Target object / 対象オブジェクト
37
+ { x: 0, y: 0, alpha: 0 }, // Start values / 開始値
38
+ { x: 100, y: 100, alpha: 1 }, // End values / 終了値
39
+ 0, // Delay (seconds) / 遅延時間(秒)
40
+ 2, // Duration (seconds) / 実行時間(秒)
41
+ Easing.inOutQuad // Easing function / イージング関数
42
+ );
43
+
44
+ // Start the animation / アニメーションを開始
45
+ job.start();
46
+ ```
47
+
48
+ ### Chaining Animations / アニメーションの連結
49
+
50
+ ```typescript
51
+ const job1 = Tween.add(sprite, { x: 0 }, { x: 100 }, 0, 1, Easing.outQuad);
52
+ const job2 = Tween.add(sprite, { x: 100 }, { x: 200 }, 0, 1, Easing.inQuad);
53
+
54
+ // Chain animations / アニメーションを連結
55
+ job1.chain(job2);
56
+ job1.start();
57
+ ```
58
+
59
+ ## Directory Structure / ディレクトリ構造
60
+
61
+ ```
62
+ src/
63
+ ├── Tween.ts # Tween class / Tweenクラス
64
+ ├── Job.ts # Job class / Jobクラス
65
+ │ ├── service/ # Job service layer / Jobサービスレイヤー
66
+ │ │ ├── JobStopService.ts # Stop animation / アニメーション停止
67
+ │ │ ├── JobEntriesService.ts # Property entries management / プロパティエントリ管理
68
+ │ │ ├── JobUpdateFrameService.ts # Frame update processing / フレーム更新処理
69
+ │ │ └── JobUpdatePropertyService.ts # Property update processing / プロパティ更新処理
70
+ │ └── usecase/ # Job use case layer / Jobユースケースレイヤー
71
+ │ ├── JobStartUseCase.ts # Start animation / アニメーション開始
72
+ │ └── JobBootUseCase.ts # Boot animation loop / アニメーションループ起動
73
+ ├── Easing.ts # Easing class / Easingクラス
74
+ │ └── service/ # All easing implementations (32 functions) / 全イージング実装(32関数)
75
+ │ ├── EasingLinearService.ts
76
+ │ ├── EasingInQuadService.ts / EasingOutQuadService.ts / EasingInOutQuadService.ts
77
+ │ ├── EasingInCubicService.ts / EasingOutCubicService.ts / EasingInOutCubicService.ts
78
+ │ ├── EasingInQuartService.ts / EasingOutQuartService.ts / EasingInOutQuartService.ts
79
+ │ ├── EasingInQuintService.ts / EasingOutQuintService.ts / EasingInOutQuintService.ts
80
+ │ ├── EasingInSineService.ts / EasingOutSineService.ts / EasingInOutSineService.ts
81
+ │ ├── EasingInExpoService.ts / EasingOutExpoService.ts / EasingInOutExpoService.ts
82
+ │ ├── EasingInCircService.ts / EasingOutCircService.ts / EasingInOutCircService.ts
83
+ │ ├── EasingInElasticService.ts / EasingOutElasticService.ts / EasingInOutElasticService.ts
84
+ │ ├── EasingInBackService.ts / EasingOutBackService.ts / EasingInOutBackService.ts
85
+ │ └── EasingInBounceService.ts / EasingOutBounceService.ts / EasingInOutBounceService.ts
86
+ ├── interface/ # TypeScript interfaces / TypeScriptインターフェース
87
+ │ ├── IObject.ts
88
+ │ └── IEntriesObject.ts
89
+ └── index.ts # Package exports / パッケージエクスポート
90
+ ```
91
+
92
+ ## Available Easing Functions / 利用可能なイージング関数
93
+
94
+ The `Easing` class provides 32 easing functions across 11 easing types with In, Out, and InOut variants.
95
+
96
+ `Easing`クラスは、11種類のイージングタイプでIn、Out、InOutのバリエーションを含む32種類のイージング関数を提供します。
97
+
98
+ ### Linear / リニア
99
+ - `Easing.linear` - Constant speed / 一定速度
100
+
101
+ ### Quadratic (Quad) / 二次関数
102
+ - `Easing.inQuad` - Accelerating from zero velocity / ゼロ速度から加速
103
+ - `Easing.outQuad` - Decelerating to zero velocity / ゼロ速度まで減速
104
+ - `Easing.inOutQuad` - Acceleration until halfway, then deceleration / 中間まで加速、その後減速
105
+
106
+ ### Cubic / 三次関数
107
+ - `Easing.inCubic` - Accelerating from zero velocity / ゼロ速度から加速
108
+ - `Easing.outCubic` - Decelerating to zero velocity / ゼロ速度まで減速
109
+ - `Easing.inOutCubic` - Acceleration until halfway, then deceleration / 中間まで加速、その後減速
110
+
111
+ ### Quartic (Quart) / 四次関数
112
+ - `Easing.inQuart` - Accelerating from zero velocity / ゼロ速度から加速
113
+ - `Easing.outQuart` - Decelerating to zero velocity / ゼロ速度まで減速
114
+ - `Easing.inOutQuart` - Acceleration until halfway, then deceleration / 中間まで加速、その後減速
115
+
116
+ ### Quintic (Quint) / 五次関数
117
+ - `Easing.inQuint` - Accelerating from zero velocity / ゼロ速度から加速
118
+ - `Easing.outQuint` - Decelerating to zero velocity / ゼロ速度まで減速
119
+ - `Easing.inOutQuint` - Acceleration until halfway, then deceleration / 中間まで加速、その後減速
120
+
121
+ ### Sinusoidal (Sine) / 正弦波
122
+ - `Easing.inSine` - Accelerating from zero velocity / ゼロ速度から加速
123
+ - `Easing.outSine` - Decelerating to zero velocity / ゼロ速度まで減速
124
+ - `Easing.inOutSine` - Acceleration until halfway, then deceleration / 中間まで加速、その後減速
125
+
126
+ ### Exponential (Expo) / 指数関数
127
+ - `Easing.inExpo` - Accelerating from zero velocity / ゼロ速度から加速
128
+ - `Easing.outExpo` - Decelerating to zero velocity / ゼロ速度まで減速
129
+ - `Easing.inOutExpo` - Acceleration until halfway, then deceleration / 中間まで加速、その後減速
130
+
131
+ ### Circular (Circ) / 円形
132
+ - `Easing.inCirc` - Accelerating from zero velocity / ゼロ速度から加速
133
+ - `Easing.outCirc` - Decelerating to zero velocity / ゼロ速度まで減速
134
+ - `Easing.inOutCirc` - Acceleration until halfway, then deceleration / 中間まで加速、その後減速
135
+
136
+ ### Elastic / 弾性
137
+ - `Easing.inElastic` - Elastic effect at the beginning / 開始時に弾性効果
138
+ - `Easing.outElastic` - Elastic effect at the end / 終了時に弾性効果
139
+ - `Easing.inOutElastic` - Elastic effect at both ends / 両端で弾性効果
140
+
141
+ ### Back / バック
142
+ - `Easing.inBack` - Back up before moving forward / 前進する前に後退
143
+ - `Easing.outBack` - Overshoot and settle / オーバーシュートして落ち着く
144
+ - `Easing.inOutBack` - Back up and overshoot / 後退とオーバーシュート
145
+
146
+ ### Bounce / バウンス
147
+ - `Easing.inBounce` - Bounce at the beginning / 開始時にバウンス
148
+ - `Easing.outBounce` - Bounce at the end / 終了時にバウンス
149
+ - `Easing.inOutBounce` - Bounce at both ends / 両端でバウンス
150
+
151
+ ### Easing Function Parameters / イージング関数のパラメータ
152
+
153
+ All easing functions accept four parameters: / すべてのイージング関数は4つのパラメータを受け取ります:
154
+
155
+ ```typescript
156
+ ease(t: number, b: number, c: number, d: number): number
157
+ ```
158
+
159
+ - `t`: Current time / 現在の時間 (0 to d)
160
+ - `b`: Beginning value / 開始値
161
+ - `c`: Change in value / 変化量 (end value - beginning value)
162
+ - `d`: Duration / 継続時間
163
+
164
+ ## Animation Flow / アニメーションフロー
165
+
166
+ ```mermaid
167
+ sequenceDiagram
168
+ participant User
169
+ participant Tween
170
+ participant Job
171
+ participant JobStartUseCase
172
+ participant JobStopService
173
+ participant Easing
174
+ participant Target
175
+
176
+ User->>Tween: Tween.add(target, from, to, delay, duration, ease)
177
+ Tween->>Job: new Job(target, from, to, delay, duration, ease)
178
+ Job-->>User: Return Job instance
179
+
180
+ User->>Job: job.start()
181
+ Job->>JobStartUseCase: execute(job)
182
+
183
+ alt Has delay
184
+ JobStartUseCase->>JobStartUseCase: setTimeout(delay)
185
+ JobStartUseCase->>JobStartUseCase: Wait for delay
186
+ end
187
+
188
+ JobStartUseCase->>JobStartUseCase: Initialize entries
189
+ JobStartUseCase->>JobStartUseCase: Set startTime
190
+
191
+ loop Animation loop (requestAnimationFrame)
192
+ JobStartUseCase->>JobStartUseCase: Calculate currentTime
193
+
194
+ alt currentTime < duration
195
+ JobStartUseCase->>Easing: Calculate eased value
196
+ Easing-->>JobStartUseCase: Return eased value
197
+ JobStartUseCase->>Target: Update target properties
198
+ JobStartUseCase->>Job: Dispatch "enterFrame" event
199
+ else currentTime >= duration
200
+ JobStartUseCase->>Target: Set final values
201
+ JobStartUseCase->>Job: Dispatch "complete" event
202
+
203
+ alt Has nextJob
204
+ JobStartUseCase->>Job: Start nextJob
205
+ end
206
+
207
+ JobStartUseCase->>JobStartUseCase: Exit loop
208
+ end
209
+ end
210
+
211
+ opt User stops animation
212
+ User->>Job: job.stop()
213
+ Job->>JobStopService: execute(job)
214
+ JobStopService->>JobStopService: Clear timer
215
+ JobStopService->>JobStopService: Set stopFlag
216
+ end
217
+ ```
218
+
219
+ ## API Reference / APIリファレンス
220
+
221
+ ### Tween Class
222
+
223
+ #### `Tween.add(target, from, to, delay, duration, ease): Job`
224
+
225
+ Creates and returns a new Job instance for animation.
226
+
227
+ アニメーション用の新しいJobインスタンスを作成して返します。
228
+
229
+ **Parameters / パラメータ:**
230
+ - `target: any` - Target object to animate / アニメーション対象オブジェクト
231
+ - `from: IObject` - Starting property values / 開始プロパティ値
232
+ - `to: IObject` - Ending property values / 終了プロパティ値
233
+ - `delay: number = 0` - Delay before animation starts (seconds) / アニメーション開始前の遅延(秒)
234
+ - `duration: number = 1` - Animation duration (seconds) / アニメーション継続時間(秒)
235
+ - `ease: Function | null = null` - Easing function (defaults to linear) / イージング関数(デフォルトはlinear)
236
+
237
+ **Returns / 戻り値:**
238
+ - `Job` - Job instance / Jobインスタンス
239
+
240
+ ### Job Class
241
+
242
+ Job class extends EventDispatcher and manages individual animation jobs.
243
+
244
+ JobクラスはEventDispatcherを継承し、個別のアニメーションジョブを管理します。
245
+
246
+ #### `job.start(): void`
247
+
248
+ Starts the animation. / アニメーションを開始します。
249
+
250
+ #### `job.stop(): void`
251
+
252
+ Stops the animation. / アニメーションを停止します。
253
+
254
+ #### `job.chain(nextJob: Job | null): Job | null`
255
+
256
+ Chains another job to start after this one completes.
257
+
258
+ このジョブの完了後に別のジョブを連結します。
259
+
260
+ **Parameters / パラメータ:**
261
+ - `nextJob: Job | null` - Next job to execute, or null to clear / 実行する次のジョブ、またはクリアするnull
262
+
263
+ **Returns / 戻り値:**
264
+ - `Job | null` - The chained job / 連結されたジョブ
265
+
266
+ #### Properties / プロパティ
267
+
268
+ - `target: any` - Target object / 対象オブジェクト
269
+ - `from: IObject` - Start values / 開始値
270
+ - `to: IObject` - End values / 終了値
271
+ - `delay: number` - Delay time / 遅延時間
272
+ - `duration: number` - Duration time / 継続時間
273
+ - `ease: Function` - Easing function / イージング関数
274
+ - `currentTime: number` - Current animation time / 現在のアニメーション時間
275
+ - `nextJob: Job | null` - Next chained job / 次の連結ジョブ
276
+
277
+ ## Events / イベント
278
+
279
+ Job class dispatches the following events: / Jobクラスは以下のイベントを発行します:
280
+
281
+ - `enterFrame` - Dispatched on each animation frame / 各アニメーションフレームで発行
282
+ - `complete` - Dispatched when animation completes / アニメーション完了時に発行
283
+
284
+ ```typescript
285
+ job.addEventListener("complete", (event) => {
286
+ console.log("Animation completed!");
287
+ });
288
+
289
+ job.addEventListener("enterFrame", (event) => {
290
+ console.log("Current time:", job.currentTime);
291
+ });
292
+ ```
293
+
294
+ ## License / ライセンス
295
+
11
296
  This project is licensed under the [MIT License](https://opensource.org/licenses/MIT) - see the [LICENSE](LICENSE) file for details.
297
+
298
+ このプロジェクトは[MITライセンス](https://opensource.org/licenses/MIT)の下でライセンスされています - 詳細は[LICENSE](LICENSE)ファイルを参照してください。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next2d/ui",
3
- "version": "2.13.0",
3
+ "version": "3.0.0",
4
4
  "description": "Next2D UI Package",
5
5
  "author": "Toshiyuki Ienaga<ienaga@next2d.app> (https://github.com/ienaga/)",
6
6
  "license": "MIT",
@@ -24,6 +24,6 @@
24
24
  "url": "git+https://github.com/Next2D/Player.git"
25
25
  },
26
26
  "dependencies": {
27
- "@next2d/events": "2.13.0"
27
+ "@next2d/events": "3.0.0"
28
28
  }
29
29
  }