@next2d/filters 1.14.20

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 (37) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +11 -0
  3. package/dist/BevelFilter.d.ts +254 -0
  4. package/dist/BevelFilter.js +490 -0
  5. package/dist/BitmapFilter.d.ts +75 -0
  6. package/dist/BitmapFilter.js +95 -0
  7. package/dist/BlurFilter.d.ts +150 -0
  8. package/dist/BlurFilter.js +371 -0
  9. package/dist/ColorMatrixFilter.d.ts +116 -0
  10. package/dist/ColorMatrixFilter.js +179 -0
  11. package/dist/ConvolutionFilter.d.ts +210 -0
  12. package/dist/ConvolutionFilter.js +366 -0
  13. package/dist/DisplacementMapFilter.d.ts +211 -0
  14. package/dist/DisplacementMapFilter.js +368 -0
  15. package/dist/DropShadowFilter.d.ts +240 -0
  16. package/dist/DropShadowFilter.js +461 -0
  17. package/dist/GlowFilter.d.ts +204 -0
  18. package/dist/GlowFilter.js +356 -0
  19. package/dist/GradientBevelFilter.d.ts +243 -0
  20. package/dist/GradientBevelFilter.js +476 -0
  21. package/dist/GradientGlowFilter.d.ts +243 -0
  22. package/dist/GradientGlowFilter.js +466 -0
  23. package/dist/index.d.ts +10 -0
  24. package/dist/index.js +10 -0
  25. package/dist/interface/AttachmentImpl.d.ts +11 -0
  26. package/dist/interface/AttachmentImpl.js +1 -0
  27. package/dist/interface/BitmapDataChannelImpl.d.ts +1 -0
  28. package/dist/interface/BitmapDataChannelImpl.js +1 -0
  29. package/dist/interface/BitmapFilterTypeImpl.d.ts +1 -0
  30. package/dist/interface/BitmapFilterTypeImpl.js +1 -0
  31. package/dist/interface/BoundsImpl.d.ts +6 -0
  32. package/dist/interface/BoundsImpl.js +1 -0
  33. package/dist/interface/DisplacementMapFilterModeImpl.d.ts +1 -0
  34. package/dist/interface/DisplacementMapFilterModeImpl.js +1 -0
  35. package/dist/interface/FilterQualityImpl.d.ts +1 -0
  36. package/dist/interface/FilterQualityImpl.js +1 -0
  37. package/package.json +38 -0
@@ -0,0 +1,368 @@
1
+ import { BitmapFilter } from "./BitmapFilter";
2
+ import { $clamp, $getArray, $intToB, $intToG, $intToR, $Math, $toColorInt } from "@next2d/share";
3
+ /**
4
+ * DisplacementMapFilter クラスは、指定された BitmapData オブジェクト(置き換えマップイメージと言います)
5
+ * のピクセル値を使用して、オブジェクトの置き換え(変位)を実行します。
6
+ *
7
+ * The DisplacementMapFilter class uses the pixel values from the specified
8
+ * BitmapData object (called the displacement map image) to perform a displacement of an object.
9
+ *
10
+ * @class
11
+ * @memberOf next2d.filters
12
+ * @extends BitmapFilter
13
+ */
14
+ export class DisplacementMapFilter extends BitmapFilter {
15
+ /**
16
+ * @param {HTMLImageElement} [map_bitmap = null]
17
+ * @param {object} [map_point = null]
18
+ * @param {number} [component_x = 0]
19
+ * @param {number} [component_y = 0]
20
+ * @param {number} [scale_x = 0.0]
21
+ * @param {number} [scale_y = 0.0]
22
+ * @param {string} [mode = DisplacementMapFilterMode.WRAP]
23
+ * @param {number} [color = 0]
24
+ * @param {number} [alpha = 0.0]
25
+ *
26
+ * @constructor
27
+ * @public
28
+ */
29
+ constructor(map_bitmap = null, map_point = null, component_x = 0, component_y = 0, scale_x = 0, scale_y = 0, mode = "wrap", color = 0, alpha = 0) {
30
+ super();
31
+ /**
32
+ * @type {BitmapData}
33
+ * @default null
34
+ * @private
35
+ */
36
+ this._$mapBitmap = null;
37
+ /**
38
+ * @type {object}
39
+ * @default null
40
+ * @private
41
+ */
42
+ this._$mapPoint = null;
43
+ /**
44
+ * @type {number}
45
+ * @default 0
46
+ * @private
47
+ */
48
+ this._$componentX = 0;
49
+ /**
50
+ * @type {number}
51
+ * @default 0
52
+ * @private
53
+ */
54
+ this._$componentY = 0;
55
+ /**
56
+ * @type {number}
57
+ * @default 0
58
+ * @private
59
+ */
60
+ this._$scaleX = 0;
61
+ /**
62
+ * @type {number}
63
+ * @default 0
64
+ * @private
65
+ */
66
+ this._$scaleY = 0;
67
+ /**
68
+ * @type {string}
69
+ * @default DisplacementMapFilterMode.WRAP
70
+ * @private
71
+ */
72
+ this._$mode = "wrap";
73
+ /**
74
+ * @type {number}
75
+ * @default 0
76
+ * @private
77
+ */
78
+ this._$color = 0;
79
+ /**
80
+ * @type {number}
81
+ * @default 0
82
+ * @private
83
+ */
84
+ this._$alpha = 0;
85
+ // setup
86
+ this.mapBitmap = map_bitmap;
87
+ this.mapPoint = map_point;
88
+ this.componentX = component_x;
89
+ this.componentY = component_y;
90
+ this.scaleX = scale_x;
91
+ this.scaleY = scale_y;
92
+ this.mode = mode;
93
+ this.color = color;
94
+ this.alpha = alpha;
95
+ }
96
+ /**
97
+ * @description 指定されたクラスのストリングを返します。
98
+ * Returns the string representation of the specified class.
99
+ *
100
+ * @return {string}
101
+ * @default [class DisplacementMapFilter]
102
+ * @method
103
+ * @static
104
+ */
105
+ static toString() {
106
+ return "[class DisplacementMapFilter]";
107
+ }
108
+ /**
109
+ * @description 指定されたクラスの空間名を返します。
110
+ * Returns the space name of the specified class.
111
+ *
112
+ * @return {string}
113
+ * @default next2d.filters.DisplacementMapFilter
114
+ * @const
115
+ * @static
116
+ */
117
+ static get namespace() {
118
+ return "next2d.filters.DisplacementMapFilter";
119
+ }
120
+ /**
121
+ * @description 指定されたオブジェクトのストリングを返します。
122
+ * Returns the string representation of the specified object.
123
+ *
124
+ * @return {string}
125
+ * @default [object DisplacementMapFilter]
126
+ * @method
127
+ * @public
128
+ */
129
+ toString() {
130
+ return "[object DisplacementMapFilter]";
131
+ }
132
+ /**
133
+ * @description 指定されたオブジェクトの空間名を返します。
134
+ * Returns the space name of the specified object.
135
+ *
136
+ * @return {string}
137
+ * @default next2d.filters.DisplacementMapFilter
138
+ * @const
139
+ * @public
140
+ */
141
+ get namespace() {
142
+ return "next2d.filters.DisplacementMapFilter";
143
+ }
144
+ /**
145
+ * @description アルファ透明度の値です。
146
+ * The alpha transparency value for the color.
147
+ *
148
+ * @member {number}
149
+ * @default 0
150
+ * @public
151
+ */
152
+ get alpha() {
153
+ return this._$alpha;
154
+ }
155
+ set alpha(alpha) {
156
+ alpha = $clamp(+alpha, 0, 1, 0);
157
+ if (alpha !== this._$alpha) {
158
+ this._$alpha = alpha;
159
+ this._$doChanged();
160
+ }
161
+ }
162
+ /**
163
+ * @description 範囲外置き換えの場合に使用する色を指定します。
164
+ * Specifies what color to use for out-of-bounds displacements.
165
+ *
166
+ * @member {number}
167
+ * @default 0
168
+ * @public
169
+ */
170
+ get color() {
171
+ return this._$color;
172
+ }
173
+ set color(color) {
174
+ color = $clamp($toColorInt(color), 0, 0xffffff, 0);
175
+ if (color !== this._$color) {
176
+ this._$color = color;
177
+ this._$doChanged();
178
+ }
179
+ }
180
+ /**
181
+ * @description x の結果を変位させる場合にどのカラーチャンネルをマップイメージで使用するかを指定します。
182
+ * Describes which color channel to use in the map image to displace the x result.
183
+ *
184
+ * @member {number}
185
+ * @default 0
186
+ * @public
187
+ */
188
+ get componentX() {
189
+ return this._$componentX;
190
+ }
191
+ set componentX(component_x) {
192
+ if (component_x !== this._$componentX) {
193
+ this._$componentX = component_x;
194
+ this._$doChanged();
195
+ }
196
+ }
197
+ /**
198
+ * @description y の結果を変位させる場合にどのカラーチャンネルをマップイメージで使用するかを指定します。
199
+ * Describes which color channel to use in the map image to displace the y result.
200
+ *
201
+ * @member {number}
202
+ * @default 0
203
+ * @public
204
+ */
205
+ get componentY() {
206
+ return this._$componentY;
207
+ }
208
+ set componentY(component_y) {
209
+ if (component_y !== this._$componentY) {
210
+ this._$componentY = component_y;
211
+ this._$doChanged();
212
+ }
213
+ }
214
+ /**
215
+ * @description 置き換えマップデータが含まれる BitmapData オブジェクトです。
216
+ * A BitmapData object containing the displacement map data.
217
+ *
218
+ * @member {HTMLImageElement}
219
+ * @default null
220
+ * @public
221
+ */
222
+ get mapBitmap() {
223
+ return this._$mapBitmap;
224
+ }
225
+ set mapBitmap(map_bitmap) {
226
+ if (map_bitmap !== this._$mapBitmap) {
227
+ this._$mapBitmap = map_bitmap;
228
+ this._$doChanged();
229
+ }
230
+ }
231
+ /**
232
+ * @description マップイメージの左上隅を基準としたターゲット表示オブジェクトの
233
+ * 左上隅のオフセットが含まれる値です。
234
+ * A value that contains the offset of the upper-left corner
235
+ * of the target display object from the upper-left corner of the map image.
236
+ *
237
+ * @member {object}
238
+ * @default null
239
+ * @public
240
+ */
241
+ get mapPoint() {
242
+ return this._$mapPoint;
243
+ }
244
+ set mapPoint(map_point) {
245
+ if (map_point !== this._$mapPoint) {
246
+ this._$mapPoint = map_point;
247
+ this._$doChanged();
248
+ }
249
+ }
250
+ /**
251
+ * @description フィルターのモードです。
252
+ * The mode for the filter.
253
+ *
254
+ * @member {string}
255
+ * @default DisplacementMapFilterMode.WRAP
256
+ * @public
257
+ */
258
+ get mode() {
259
+ return this._$mode;
260
+ }
261
+ set mode(mode) {
262
+ if (mode !== this._$mode) {
263
+ this._$mode = mode;
264
+ this._$doChanged();
265
+ }
266
+ }
267
+ /**
268
+ * @description マップ計算の x 置き換え結果を拡大 / 縮小する場合に使用する乗数です。
269
+ * The multiplier to use to scale the x displacement result from the map calculation.
270
+ *
271
+ * @member {number}
272
+ * @default 0
273
+ * @public
274
+ */
275
+ get scaleX() {
276
+ return this._$scaleX;
277
+ }
278
+ set scaleX(scale_x) {
279
+ scale_x = $clamp(+scale_x, -0xffff, 0xffff, 0);
280
+ if (scale_x !== this._$scaleX) {
281
+ this._$scaleX = scale_x;
282
+ this._$doChanged();
283
+ }
284
+ }
285
+ /**
286
+ * @description マップ計算の y 置き換え結果を拡大 / 縮小する場合に使用する乗数です。
287
+ * The multiplier to use to scale the y displacement result from the map calculation.
288
+ *
289
+ * @member {number}
290
+ * @default 0
291
+ * @public
292
+ */
293
+ get scaleY() {
294
+ return this._$scaleY;
295
+ }
296
+ set scaleY(scale_y) {
297
+ scale_y = $clamp(+scale_y, -0xffff, 0xffff, 0);
298
+ if (scale_y !== this._$scaleY) {
299
+ this._$scaleY = scale_y;
300
+ this._$doChanged();
301
+ }
302
+ }
303
+ /**
304
+ * @description オブジェクトのコピーを返します。
305
+ * Returns a copy of this filter object.
306
+ *
307
+ * @return {DisplacementMapFilter}
308
+ * @method
309
+ * @public
310
+ */
311
+ clone() {
312
+ return new DisplacementMapFilter(this._$mapBitmap, this._$mapPoint, this._$componentX, this._$componentY, this._$scaleX, this._$scaleY, this._$mode, this._$color, this._$alpha);
313
+ }
314
+ /**
315
+ * @return {array}
316
+ * @method
317
+ * @public
318
+ */
319
+ _$toArray() {
320
+ return $getArray(4, this._$mapBitmap, this._$mapPoint, this._$componentX, this._$componentY, this._$scaleX, this._$scaleY, this._$mode, this._$color, this._$alpha);
321
+ }
322
+ /**
323
+ * @param {object} bounds
324
+ * @return {object}
325
+ * @method
326
+ * @private
327
+ */
328
+ _$generateFilterRect(bounds) {
329
+ return bounds;
330
+ }
331
+ /**
332
+ * @return {boolean}
333
+ * @method
334
+ * @private
335
+ */
336
+ _$canApply() {
337
+ return this._$mapBitmap !== null
338
+ && this._$componentX > 0 && this._$componentY > 0
339
+ && this._$scaleX !== 0 && this._$scaleY !== 0;
340
+ }
341
+ /**
342
+ * @param {CanvasToWebGLContext} context
343
+ * @param {Float32Array} matrix
344
+ * @return {WebGLTexture}
345
+ * @method
346
+ * @private
347
+ */
348
+ _$applyFilter(context, matrix) {
349
+ this._$updated = false;
350
+ const manager = context.frameBuffer;
351
+ const currentAttachment = manager.currentAttachment;
352
+ // reset
353
+ context.setTransform(1, 0, 0, 1, 0, 0);
354
+ const texture = manager
355
+ .getTextureFromCurrentAttachment();
356
+ if (!this._$canApply()
357
+ || !currentAttachment
358
+ || !this._$mapBitmap) {
359
+ return texture;
360
+ }
361
+ // matrix to scale
362
+ const xScale = $Math.sqrt(matrix[0] * matrix[0] + matrix[1] * matrix[1]);
363
+ const yScale = $Math.sqrt(matrix[2] * matrix[2] + matrix[3] * matrix[3]);
364
+ context._$applyDisplacementMapFilter(texture, this._$mapBitmap, texture.width / xScale, texture.height / yScale, this._$mapPoint, this._$componentX, this._$componentY, this._$scaleX, this._$scaleY, this._$mode, $intToR(this._$color, this._$alpha, true), $intToG(this._$color, this._$alpha, true), $intToB(this._$color, this._$alpha, true), this._$alpha);
365
+ manager.releaseAttachment(currentAttachment, true);
366
+ return manager.getTextureFromCurrentAttachment();
367
+ }
368
+ }
@@ -0,0 +1,240 @@
1
+ import { BitmapFilter } from "./BitmapFilter";
2
+ import type { CanvasToWebGLContext } from "@next2d/webgl";
3
+ import type { FilterQualityImpl } from "./interface/FilterQualityImpl";
4
+ import type { BoundsImpl } from "./interface/BoundsImpl";
5
+ /**
6
+ * DropShadowFilter クラスは、ドロップシャドウを表示オブジェクトに追加します。
7
+ * シャドウアルゴリズムは、ぼかしフィルターで使用するのと同じボックスフィルターに基づいています。
8
+ * ドロップシャドウのスタイルには複数のオプションがあり、内側シャドウ、外側シャドウ、ノックアウトモードなどがあります。
9
+ *
10
+ * The DropShadowFilter class lets you add a drop shadow to display objects.
11
+ * The shadow algorithm is based on the same box filter that the blur filter uses.
12
+ * You have several options for the style of the drop shadow, including inner
13
+ * or outer shadow and knockout mode.
14
+ *
15
+ * @class
16
+ * @memberOf next2d.filters
17
+ * @extends BitmapFilter
18
+ */
19
+ export declare class DropShadowFilter extends BitmapFilter {
20
+ private _$blurFilter;
21
+ private _$distance;
22
+ private _$angle;
23
+ private _$color;
24
+ private _$alpha;
25
+ private _$strength;
26
+ private _$inner;
27
+ private _$knockout;
28
+ private _$hideObject;
29
+ /**
30
+ * @param {number} [distance=4]
31
+ * @param {number} [angle=45]
32
+ * @param {number} [color=0]
33
+ * @param {number} [alpha=1]
34
+ * @param {number} [blur_x=4]
35
+ * @param {number} [blur_y=4]
36
+ * @param {number} [strength=1]
37
+ * @param {number} [quality=1]
38
+ * @param {boolean} [inner=false]
39
+ * @param {boolean} [knockout=false]
40
+ * @param {boolean} [hide_object=false]
41
+ *
42
+ * @constructor
43
+ * @public
44
+ */
45
+ constructor(distance?: number, angle?: number, color?: number, alpha?: number, blur_x?: number, blur_y?: number, strength?: number, quality?: FilterQualityImpl, inner?: boolean, knockout?: boolean, hide_object?: boolean);
46
+ /**
47
+ * @description 指定されたクラスのストリングを返します。
48
+ * Returns the string representation of the specified class.
49
+ *
50
+ * @return {string}
51
+ * @default [class DropShadowFilter]
52
+ * @method
53
+ * @static
54
+ */
55
+ static toString(): string;
56
+ /**
57
+ * @description 指定されたクラスの空間名を返します。
58
+ * Returns the space name of the specified class.
59
+ *
60
+ * @return {string}
61
+ * @default next2d.filters.DropShadowFilter
62
+ * @const
63
+ * @static
64
+ */
65
+ static get namespace(): string;
66
+ /**
67
+ * @description 指定されたオブジェクトのストリングを返します。
68
+ * Returns the string representation of the specified object.
69
+ *
70
+ * @return {string}
71
+ * @default [object DropShadowFilter]
72
+ * @method
73
+ * @public
74
+ */
75
+ toString(): string;
76
+ /**
77
+ * @description 指定されたオブジェクトの空間名を返します。
78
+ * Returns the space name of the specified object.
79
+ *
80
+ * @return {string}
81
+ * @default next2d.filters.DropShadowFilter
82
+ * @const
83
+ * @public
84
+ */
85
+ get namespace(): string;
86
+ /**
87
+ * @description アルファ透明度の値です。
88
+ * The alpha transparency value for the color.
89
+ *
90
+ * @member {number}
91
+ * @default 1
92
+ * @public
93
+ */
94
+ get alpha(): number;
95
+ set alpha(alpha: number);
96
+ /**
97
+ * @description シャドウの角度
98
+ * The angle of the shadow.
99
+ *
100
+ * @member {number}
101
+ * @default 45
102
+ * @public
103
+ */
104
+ get angle(): number;
105
+ set angle(angle: number);
106
+ /**
107
+ * @description 水平方向のぼかし量。
108
+ * The amount of horizontal blur.
109
+ *
110
+ * @member {number}
111
+ * @default 4
112
+ * @public
113
+ */
114
+ get blurX(): number;
115
+ set blurX(blur_x: number);
116
+ /**
117
+ * @description 垂直方向のぼかし量。
118
+ * The amount of vertical blur.
119
+ *
120
+ * @member {number}
121
+ * @default 4
122
+ * @public
123
+ */
124
+ get blurY(): number;
125
+ set blurY(blur_y: number);
126
+ /**
127
+ * @description グローのカラー
128
+ * The color of the glow.
129
+ *
130
+ * @member {number}
131
+ * @default 4
132
+ * @public
133
+ */
134
+ get color(): number;
135
+ set color(color: number);
136
+ /**
137
+ * @description シャドウのオフセット距離です。
138
+ * The offset distance for the shadow, in pixels.
139
+ *
140
+ * @member {number}
141
+ * @default 4
142
+ * @public
143
+ */
144
+ get distance(): number;
145
+ set distance(distance: number);
146
+ /**
147
+ * @description オブジェクトが非表示であるかどうかを示します。
148
+ * Indicates whether or not the object is hidden.
149
+ *
150
+ * @member {boolean}
151
+ * @default true
152
+ * @public
153
+ */
154
+ get hideObject(): boolean;
155
+ set hideObject(hide_object: boolean);
156
+ /**
157
+ * @description グローが内側グローであるかどうか
158
+ * Specifies whether the glow is an inner glow.
159
+ *
160
+ * @member {boolean}
161
+ * @default true
162
+ * @public
163
+ */
164
+ get inner(): boolean;
165
+ set inner(inner: boolean);
166
+ /**
167
+ * @description オブジェクトにノックアウト効果を適用するかどうか
168
+ * Specifies whether the object has a knockout effect.
169
+ *
170
+ * @member {boolean}
171
+ * @default true
172
+ * @public
173
+ */
174
+ get knockout(): boolean;
175
+ set knockout(knockout: boolean);
176
+ /**
177
+ * @description ぼかしの実行回数です。
178
+ * The number of times to perform the blur.
179
+ *
180
+ * @member {number}
181
+ * @default 1
182
+ * @public
183
+ */
184
+ get quality(): FilterQualityImpl;
185
+ set quality(quality: FilterQualityImpl);
186
+ /**
187
+ * @description インプリントの強さまたは広がりです。
188
+ * The strength of the imprint or spread.
189
+ *
190
+ * @member {number}
191
+ * @default 1
192
+ * @public
193
+ */
194
+ get strength(): number;
195
+ set strength(strength: number);
196
+ /**
197
+ * @description オブジェクトのコピーを返します。
198
+ * Returns a copy of this filter object.
199
+ *
200
+ * @return {DropShadowFilter}
201
+ * @method
202
+ * @public
203
+ */
204
+ clone(): DropShadowFilter;
205
+ /**
206
+ * @return {array}
207
+ * @method
208
+ * @public
209
+ */
210
+ _$toArray(): any[];
211
+ /**
212
+ * @return {boolean}
213
+ * @method
214
+ * @public
215
+ */
216
+ _$isUpdated(): boolean;
217
+ /**
218
+ * @param {object} bounds
219
+ * @param {number} [x_scale=null]
220
+ * @param {number} [y_scale=null]
221
+ * @return {object}
222
+ * @method
223
+ * @private
224
+ */
225
+ _$generateFilterRect(bounds: BoundsImpl, x_scale?: number, y_scale?: number): BoundsImpl;
226
+ /**
227
+ * @return {boolean}
228
+ * @method
229
+ * @private
230
+ */
231
+ _$canApply(): boolean;
232
+ /**
233
+ * @param {CanvasToWebGLContext} context
234
+ * @param {Float32Array} matrix
235
+ * @return {WebGLTexture}
236
+ * @method
237
+ * @private
238
+ */
239
+ _$applyFilter(context: CanvasToWebGLContext, matrix: Float32Array): WebGLTexture;
240
+ }