@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,366 @@
1
+ import { BitmapFilter } from "./BitmapFilter";
2
+ import { $Array, $clamp, $getArray, $poolArray, $toColorInt, $intToR, $intToG, $intToB } from "@next2d/share";
3
+ /**
4
+ * ConvolutionFilter クラスを使用すると、マトリックス畳み込みフィルター効果を適用できます。
5
+ * 畳み込みでは、入力イメージ内のピクセルを、隣接するピクセルと組み合わせて、イメージを作成します。
6
+ * 畳み込みを使用すると、ぼかし、エッジ検出、シャープ、エンボス、ベベルなど、幅広いイメージ効果を実現できます。
7
+ *
8
+ * The ConvolutionFilter class applies a matrix convolution filter effect.
9
+ * A convolution combines pixels in the input image with neighboring pixels to produce an image.
10
+ * A wide variety of image effects can be achieved through convolutions, including blurring,
11
+ * edge detection, sharpening, embossing, and beveling.
12
+ *
13
+ * @class
14
+ * @memberOf next2d.filters
15
+ * @extends BitmapFilter
16
+ */
17
+ export class ConvolutionFilter extends BitmapFilter {
18
+ /**
19
+ * @param {number} [matrix_x=0]
20
+ * @param {number} [matrix_y=0]
21
+ * @param {array} [matrix=null]
22
+ * @param {number} [divisor=1.0]
23
+ * @param {number} [bias=0.0]
24
+ * @param {boolean} [preserve_alpha=true]
25
+ * @param {boolean} [clamp=true]
26
+ * @param {number} [color=0]
27
+ * @param {number} [alpha=0.0]
28
+ *
29
+ * @constructor
30
+ * @public
31
+ */
32
+ constructor(matrix_x = 0, matrix_y = 0, matrix = null, divisor = 1, bias = 0, preserve_alpha = true, clamp = true, color = 0, alpha = 0) {
33
+ super();
34
+ /**
35
+ * @type {number}
36
+ * @default 0
37
+ * @private
38
+ */
39
+ this._$matrixX = 0;
40
+ /**
41
+ * @type {number}
42
+ * @default 0
43
+ * @private
44
+ */
45
+ this._$matrixY = 0;
46
+ /**
47
+ * @type {array}
48
+ * @default null
49
+ * @private
50
+ */
51
+ this._$matrix = null;
52
+ /**
53
+ * @type {number}
54
+ * @default 1
55
+ * @private
56
+ */
57
+ this._$divisor = 1;
58
+ /**
59
+ * @type {number}
60
+ * @default 0
61
+ * @private
62
+ */
63
+ this._$bias = 0;
64
+ /**
65
+ * @type {boolean}
66
+ * @default true
67
+ * @private
68
+ */
69
+ this._$preserveAlpha = true;
70
+ /**
71
+ * @type {boolean}
72
+ * @default true
73
+ * @private
74
+ */
75
+ this._$clamp = true;
76
+ /**
77
+ * @type {number}
78
+ * @default 0
79
+ * @private
80
+ */
81
+ this._$color = 0;
82
+ /**
83
+ * @type {number}
84
+ * @default 0
85
+ * @private
86
+ */
87
+ this._$alpha = 0;
88
+ // setup
89
+ this.matrixX = matrix_x;
90
+ this.matrixY = matrix_y;
91
+ this.matrix = matrix;
92
+ this.divisor = divisor;
93
+ this.bias = bias;
94
+ this.preserveAlpha = preserve_alpha;
95
+ this.clamp = clamp;
96
+ this.color = color;
97
+ this.alpha = alpha;
98
+ }
99
+ /**
100
+ * @description 指定されたクラスのストリングを返します。
101
+ * Returns the string representation of the specified class.
102
+ *
103
+ * @return {string}
104
+ * @default [class ConvolutionFilter]
105
+ * @method
106
+ * @static
107
+ */
108
+ static toString() {
109
+ return "[class ConvolutionFilter]";
110
+ }
111
+ /**
112
+ * @description 指定されたクラスの空間名を返します。
113
+ * Returns the space name of the specified class.
114
+ *
115
+ * @return {string}
116
+ * @default next2d.filters.ConvolutionFilter
117
+ * @const
118
+ * @static
119
+ */
120
+ static get namespace() {
121
+ return "next2d.filters.ConvolutionFilter";
122
+ }
123
+ /**
124
+ * @description 指定されたオブジェクトのストリングを返します。
125
+ * Returns the string representation of the specified object.
126
+ *
127
+ * @return {string}
128
+ * @default [object ConvolutionFilter]
129
+ * @method
130
+ * @public
131
+ */
132
+ toString() {
133
+ return "[object ConvolutionFilter]";
134
+ }
135
+ /**
136
+ * @description 指定されたオブジェクトの空間名を返します。
137
+ * Returns the space name of the specified object.
138
+ *
139
+ * @return {string}
140
+ * @default next2d.filters.ConvolutionFilter
141
+ * @const
142
+ * @public
143
+ */
144
+ get namespace() {
145
+ return "next2d.filters.ConvolutionFilter";
146
+ }
147
+ /**
148
+ * @description アルファ透明度の値です。
149
+ * The alpha transparency value for the color.
150
+ *
151
+ * @member {number}
152
+ * @default 4
153
+ * @public
154
+ */
155
+ get alpha() {
156
+ return this._$alpha;
157
+ }
158
+ set alpha(alpha) {
159
+ alpha = $clamp(+alpha, 0, 1, 0);
160
+ if (alpha !== this._$alpha) {
161
+ this._$alpha = alpha;
162
+ this._$doChanged();
163
+ }
164
+ }
165
+ /**
166
+ * @description マトリックス変換の結果に加算するバイアス量です。
167
+ * The amount of bias to add to the result of the matrix transformation.
168
+ *
169
+ * @member {number}
170
+ * @default 0
171
+ * @public
172
+ */
173
+ get bias() {
174
+ return this._$bias;
175
+ }
176
+ set bias(bias) {
177
+ if (bias !== this._$bias) {
178
+ this._$bias = bias | 0;
179
+ this._$doChanged();
180
+ }
181
+ }
182
+ /**
183
+ * @description イメージをクランプする必要があるかどうかを示します。
184
+ * Indicates whether the image should be clamped.
185
+ *
186
+ * @member {boolean}
187
+ * @default true
188
+ * @public
189
+ */
190
+ get clamp() {
191
+ return this._$clamp;
192
+ }
193
+ set clamp(clamp) {
194
+ if (clamp !== this._$clamp) {
195
+ this._$clamp = !!clamp;
196
+ this._$doChanged();
197
+ }
198
+ }
199
+ /**
200
+ * @description ソースイメージの外にあるピクセルを置換する 16 進数のカラー値です。
201
+ * The hexadecimal color to substitute for pixels that are off the source image.
202
+ *
203
+ * @member {number}
204
+ * @default 0
205
+ * @public
206
+ */
207
+ get color() {
208
+ return this._$color;
209
+ }
210
+ set color(color) {
211
+ color = $clamp($toColorInt(color), 0, 0xffffff, 0);
212
+ if (color !== this._$color) {
213
+ this._$color = color;
214
+ this._$doChanged();
215
+ }
216
+ }
217
+ /**
218
+ * @description マトリックス変換中に使用する除数です。
219
+ * The divisor used during matrix transformation.
220
+ *
221
+ * @member {number}
222
+ * @default 1
223
+ * @public
224
+ */
225
+ get divisor() {
226
+ return this._$divisor;
227
+ }
228
+ set divisor(divisor) {
229
+ if (divisor !== this._$divisor) {
230
+ this._$divisor = divisor | 0;
231
+ this._$doChanged();
232
+ }
233
+ }
234
+ /**
235
+ * @description マトリックス変換に使用する値の配列です。
236
+ * An array of values used for matrix transformation.
237
+ *
238
+ * @member {array}
239
+ * @default null
240
+ * @public
241
+ */
242
+ get matrix() {
243
+ return this._$matrix;
244
+ }
245
+ set matrix(matrix) {
246
+ if ($Array.isArray(this._$matrix)) {
247
+ $poolArray(this._$matrix);
248
+ }
249
+ // default
250
+ this._$matrix = $Array.isArray(matrix) ? matrix : null;
251
+ this._$doChanged();
252
+ }
253
+ /**
254
+ * @description マトリックスの x 次元 (マトリックスの列数) です。
255
+ * The x dimension of the matrix (the number of columns in the matrix).
256
+ *
257
+ * @member {number}
258
+ * @default 0
259
+ * @public
260
+ */
261
+ get matrixX() {
262
+ return this._$matrixX;
263
+ }
264
+ set matrixX(matrix_x) {
265
+ matrix_x = $clamp(matrix_x | 0, 0, 15, 0) | 0;
266
+ if (matrix_x !== this._$matrixX) {
267
+ this._$matrixX = matrix_x;
268
+ this._$doChanged();
269
+ }
270
+ }
271
+ /**
272
+ * @description マトリックスの y 次元(マトリックスの行数)です。
273
+ * The y dimension of the matrix (the number of rows in the matrix).
274
+ *
275
+ * @member {number}
276
+ * @default 0
277
+ * @public
278
+ */
279
+ get matrixY() {
280
+ return this._$matrixY;
281
+ }
282
+ set matrixY(matrix_y) {
283
+ matrix_y = $clamp(matrix_y | 0, 0, 15, 0) | 0;
284
+ if (matrix_y !== this._$matrixY) {
285
+ this._$matrixY = matrix_y;
286
+ this._$doChanged();
287
+ }
288
+ }
289
+ /**
290
+ * @description アルファチャンネルがフィルター効果なしで維持されるかどうか、またはカラーチャンネルだけではなく
291
+ * アルファチャンネルにも畳み込みフィルターが適用されるかどうかを示します。
292
+ * Indicates if the alpha channel is preserved without the filter effect or
293
+ * if the convolution filter is applied to the alpha channel as well as the color channels.
294
+ *
295
+ * @member {boolean}
296
+ * @default true
297
+ * @public
298
+ */
299
+ get preserveAlpha() {
300
+ return this._$preserveAlpha;
301
+ }
302
+ set preserveAlpha(preserve_alpha) {
303
+ if (preserve_alpha !== this._$preserveAlpha) {
304
+ this._$preserveAlpha = !!preserve_alpha;
305
+ this._$doChanged();
306
+ }
307
+ }
308
+ /**
309
+ * @description オブジェクトのコピーを返します。
310
+ * Returns a copy of this filter object.
311
+ *
312
+ * @return {ConvolutionFilter}
313
+ * @method
314
+ * @public
315
+ */
316
+ clone() {
317
+ return new ConvolutionFilter(this._$matrixX, this._$matrixY, this._$matrix ? this._$matrix.slice() : null, this._$divisor, this._$bias, this._$preserveAlpha, this._$clamp, this._$color, this._$alpha);
318
+ }
319
+ /**
320
+ * @return {array}
321
+ * @method
322
+ * @public
323
+ */
324
+ _$toArray() {
325
+ return $getArray(3, this._$matrixX, this._$matrixY, this._$matrix, this._$divisor, this._$bias, this._$preserveAlpha, this._$clamp, this._$color, this._$alpha);
326
+ }
327
+ /**
328
+ * @param {object} rect
329
+ * @return {object}
330
+ * @method
331
+ * @private
332
+ */
333
+ _$generateFilterRect(rect) {
334
+ return rect;
335
+ }
336
+ /**
337
+ * @return {boolean}
338
+ * @method
339
+ * @private
340
+ */
341
+ _$canApply() {
342
+ return this._$matrix !== null
343
+ && this._$matrixX * this._$matrixY === this._$matrix.length;
344
+ }
345
+ /**
346
+ * @param {CanvasToWebGLContext} context
347
+ * @return {WebGLTexture}
348
+ * @method
349
+ * @private
350
+ */
351
+ _$applyFilter(context) {
352
+ this._$updated = false;
353
+ const manager = context.frameBuffer;
354
+ const currentAttachment = manager.currentAttachment;
355
+ // reset
356
+ context.setTransform(1, 0, 0, 1, 0, 0);
357
+ const texture = manager
358
+ .getTextureFromCurrentAttachment();
359
+ if (!this._$canApply() || !this._$matrix) {
360
+ return texture;
361
+ }
362
+ context._$applyConvolutionFilter(texture, this._$matrixX, this._$matrixY, this._$matrix, this._$divisor, this._$bias, this._$preserveAlpha, this._$clamp, $intToR(this._$color, this._$alpha, false), $intToG(this._$color, this._$alpha, false), $intToB(this._$color, this._$alpha, false), this._$alpha);
363
+ manager.releaseAttachment(currentAttachment, true);
364
+ return manager.getTextureFromCurrentAttachment();
365
+ }
366
+ }
@@ -0,0 +1,211 @@
1
+ import { BitmapFilter } from "./BitmapFilter";
2
+ import type { CanvasToWebGLContext } from "@next2d/webgl";
3
+ import type { DisplacementMapFilterModeImpl } from "./interface/DisplacementMapFilterModeImpl";
4
+ import type { BitmapDataChannelImpl } from "./interface/BitmapDataChannelImpl";
5
+ import type { BoundsImpl } from "./interface/BoundsImpl";
6
+ import type { PointImpl } from "@next2d/interface";
7
+ /**
8
+ * DisplacementMapFilter クラスは、指定された BitmapData オブジェクト(置き換えマップイメージと言います)
9
+ * のピクセル値を使用して、オブジェクトの置き換え(変位)を実行します。
10
+ *
11
+ * The DisplacementMapFilter class uses the pixel values from the specified
12
+ * BitmapData object (called the displacement map image) to perform a displacement of an object.
13
+ *
14
+ * @class
15
+ * @memberOf next2d.filters
16
+ * @extends BitmapFilter
17
+ */
18
+ export declare class DisplacementMapFilter extends BitmapFilter {
19
+ private _$mapBitmap;
20
+ private _$mapPoint;
21
+ private _$componentX;
22
+ private _$componentY;
23
+ private _$scaleX;
24
+ private _$scaleY;
25
+ private _$mode;
26
+ private _$color;
27
+ private _$alpha;
28
+ /**
29
+ * @param {HTMLImageElement} [map_bitmap = null]
30
+ * @param {object} [map_point = null]
31
+ * @param {number} [component_x = 0]
32
+ * @param {number} [component_y = 0]
33
+ * @param {number} [scale_x = 0.0]
34
+ * @param {number} [scale_y = 0.0]
35
+ * @param {string} [mode = DisplacementMapFilterMode.WRAP]
36
+ * @param {number} [color = 0]
37
+ * @param {number} [alpha = 0.0]
38
+ *
39
+ * @constructor
40
+ * @public
41
+ */
42
+ constructor(map_bitmap?: HTMLImageElement | null, map_point?: PointImpl | null, component_x?: BitmapDataChannelImpl, component_y?: BitmapDataChannelImpl, scale_x?: number, scale_y?: number, mode?: DisplacementMapFilterModeImpl, color?: number, alpha?: number);
43
+ /**
44
+ * @description 指定されたクラスのストリングを返します。
45
+ * Returns the string representation of the specified class.
46
+ *
47
+ * @return {string}
48
+ * @default [class DisplacementMapFilter]
49
+ * @method
50
+ * @static
51
+ */
52
+ static toString(): string;
53
+ /**
54
+ * @description 指定されたクラスの空間名を返します。
55
+ * Returns the space name of the specified class.
56
+ *
57
+ * @return {string}
58
+ * @default next2d.filters.DisplacementMapFilter
59
+ * @const
60
+ * @static
61
+ */
62
+ static get namespace(): string;
63
+ /**
64
+ * @description 指定されたオブジェクトのストリングを返します。
65
+ * Returns the string representation of the specified object.
66
+ *
67
+ * @return {string}
68
+ * @default [object DisplacementMapFilter]
69
+ * @method
70
+ * @public
71
+ */
72
+ toString(): string;
73
+ /**
74
+ * @description 指定されたオブジェクトの空間名を返します。
75
+ * Returns the space name of the specified object.
76
+ *
77
+ * @return {string}
78
+ * @default next2d.filters.DisplacementMapFilter
79
+ * @const
80
+ * @public
81
+ */
82
+ get namespace(): string;
83
+ /**
84
+ * @description アルファ透明度の値です。
85
+ * The alpha transparency value for the color.
86
+ *
87
+ * @member {number}
88
+ * @default 0
89
+ * @public
90
+ */
91
+ get alpha(): number;
92
+ set alpha(alpha: number);
93
+ /**
94
+ * @description 範囲外置き換えの場合に使用する色を指定します。
95
+ * Specifies what color to use for out-of-bounds displacements.
96
+ *
97
+ * @member {number}
98
+ * @default 0
99
+ * @public
100
+ */
101
+ get color(): number;
102
+ set color(color: number);
103
+ /**
104
+ * @description x の結果を変位させる場合にどのカラーチャンネルをマップイメージで使用するかを指定します。
105
+ * Describes which color channel to use in the map image to displace the x result.
106
+ *
107
+ * @member {number}
108
+ * @default 0
109
+ * @public
110
+ */
111
+ get componentX(): BitmapDataChannelImpl;
112
+ set componentX(component_x: BitmapDataChannelImpl);
113
+ /**
114
+ * @description y の結果を変位させる場合にどのカラーチャンネルをマップイメージで使用するかを指定します。
115
+ * Describes which color channel to use in the map image to displace the y result.
116
+ *
117
+ * @member {number}
118
+ * @default 0
119
+ * @public
120
+ */
121
+ get componentY(): BitmapDataChannelImpl;
122
+ set componentY(component_y: BitmapDataChannelImpl);
123
+ /**
124
+ * @description 置き換えマップデータが含まれる BitmapData オブジェクトです。
125
+ * A BitmapData object containing the displacement map data.
126
+ *
127
+ * @member {HTMLImageElement}
128
+ * @default null
129
+ * @public
130
+ */
131
+ get mapBitmap(): HTMLImageElement | null;
132
+ set mapBitmap(map_bitmap: HTMLImageElement | null);
133
+ /**
134
+ * @description マップイメージの左上隅を基準としたターゲット表示オブジェクトの
135
+ * 左上隅のオフセットが含まれる値です。
136
+ * A value that contains the offset of the upper-left corner
137
+ * of the target display object from the upper-left corner of the map image.
138
+ *
139
+ * @member {object}
140
+ * @default null
141
+ * @public
142
+ */
143
+ get mapPoint(): PointImpl | null;
144
+ set mapPoint(map_point: PointImpl | null);
145
+ /**
146
+ * @description フィルターのモードです。
147
+ * The mode for the filter.
148
+ *
149
+ * @member {string}
150
+ * @default DisplacementMapFilterMode.WRAP
151
+ * @public
152
+ */
153
+ get mode(): DisplacementMapFilterModeImpl;
154
+ set mode(mode: DisplacementMapFilterModeImpl);
155
+ /**
156
+ * @description マップ計算の x 置き換え結果を拡大 / 縮小する場合に使用する乗数です。
157
+ * The multiplier to use to scale the x displacement result from the map calculation.
158
+ *
159
+ * @member {number}
160
+ * @default 0
161
+ * @public
162
+ */
163
+ get scaleX(): number;
164
+ set scaleX(scale_x: number);
165
+ /**
166
+ * @description マップ計算の y 置き換え結果を拡大 / 縮小する場合に使用する乗数です。
167
+ * The multiplier to use to scale the y displacement result from the map calculation.
168
+ *
169
+ * @member {number}
170
+ * @default 0
171
+ * @public
172
+ */
173
+ get scaleY(): number;
174
+ set scaleY(scale_y: number);
175
+ /**
176
+ * @description オブジェクトのコピーを返します。
177
+ * Returns a copy of this filter object.
178
+ *
179
+ * @return {DisplacementMapFilter}
180
+ * @method
181
+ * @public
182
+ */
183
+ clone(): DisplacementMapFilter;
184
+ /**
185
+ * @return {array}
186
+ * @method
187
+ * @public
188
+ */
189
+ _$toArray(): any[];
190
+ /**
191
+ * @param {object} bounds
192
+ * @return {object}
193
+ * @method
194
+ * @private
195
+ */
196
+ _$generateFilterRect(bounds: BoundsImpl): BoundsImpl;
197
+ /**
198
+ * @return {boolean}
199
+ * @method
200
+ * @private
201
+ */
202
+ _$canApply(): boolean;
203
+ /**
204
+ * @param {CanvasToWebGLContext} context
205
+ * @param {Float32Array} matrix
206
+ * @return {WebGLTexture}
207
+ * @method
208
+ * @private
209
+ */
210
+ _$applyFilter(context: CanvasToWebGLContext, matrix: Float32Array): WebGLTexture;
211
+ }