@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,356 @@
1
+ import { BitmapFilter } from "./BitmapFilter";
2
+ import { BlurFilter } from "./BlurFilter";
3
+ import { $intToB, $intToG, $intToR, $clamp, $toColorInt, $getArray, $getBoundsObject } from "@next2d/share";
4
+ /**
5
+ * GlowFilter クラスを使用すると、表示オブジェクトにグロー効果を適用できます。
6
+ * グローのスタイルには複数のオプションがあり、内側グロー、外側グロー、ノックアウトモードなどがあります。
7
+ * グローフィルターは、distance プロパティと angle プロパティを 0 に設定したドロップシャドウフィルターによく似ています。
8
+ *
9
+ * The GlowFilter class lets you apply a glow effect to display objects.
10
+ * You have several options for the style of the glow, including inner or outer glow and knockout mode.
11
+ * The glow filter is similar to the drop shadow filter with the distance
12
+ * and angle properties of the drop shadow filter set to 0.
13
+ *
14
+ * @class
15
+ * @memberOf next2d.filters
16
+ * @extends BitmapFilter
17
+ */
18
+ export class GlowFilter extends BitmapFilter {
19
+ /**
20
+ * @param {number} [color=0xFF0000]
21
+ * @param {number} [alpha=1]
22
+ * @param {number} [blur_x=6]
23
+ * @param {number} [blur_y=6]
24
+ * @param {number} [strength=2]
25
+ * @param {int} [quality=1]
26
+ * @param {boolean} [inner=false]
27
+ * @param {boolean} [knockout=false]
28
+ *
29
+ * @constructor
30
+ * @public
31
+ */
32
+ constructor(color = 0, alpha = 1, blur_x = 4, blur_y = 4, strength = 1, quality = 1, inner = false, knockout = false) {
33
+ super();
34
+ /**
35
+ * @type {BlurFilter}
36
+ * @default BlurFilter
37
+ * @private
38
+ */
39
+ this._$blurFilter = new BlurFilter(blur_x, blur_y, quality);
40
+ /**
41
+ * @type {number}
42
+ * @default 0
43
+ * @private
44
+ */
45
+ this._$color = 0;
46
+ /**
47
+ * @type {number}
48
+ * @default 1
49
+ * @private
50
+ */
51
+ this._$alpha = 1;
52
+ /**
53
+ * @type {number}
54
+ * @default 1
55
+ * @private
56
+ */
57
+ this._$strength = 1;
58
+ /**
59
+ * @type {boolean}
60
+ * @default false
61
+ * @private
62
+ */
63
+ this._$inner = false;
64
+ /**
65
+ * @type {boolean}
66
+ * @default false
67
+ * @private
68
+ */
69
+ this._$knockout = false;
70
+ // setup
71
+ this.color = color;
72
+ this.alpha = alpha;
73
+ this.strength = strength;
74
+ this.inner = inner;
75
+ this.knockout = knockout;
76
+ }
77
+ /**
78
+ * @description 指定されたクラスのストリングを返します。
79
+ * Returns the string representation of the specified class.
80
+ *
81
+ * @return {string}
82
+ * @default [class GlowFilter]
83
+ * @method
84
+ * @static
85
+ */
86
+ static toString() {
87
+ return "[class GlowFilter]";
88
+ }
89
+ /**
90
+ * @description 指定されたクラスの空間名を返します。
91
+ * Returns the space name of the specified class.
92
+ *
93
+ * @return {string}
94
+ * @default next2d.filters.GlowFilter
95
+ * @const
96
+ * @static
97
+ */
98
+ static get namespace() {
99
+ return "next2d.filters.GlowFilter";
100
+ }
101
+ /**
102
+ * @description 指定されたオブジェクトのストリングを返します。
103
+ * Returns the string representation of the specified object.
104
+ *
105
+ * @return {string}
106
+ * @default [object GlowFilter]
107
+ * @method
108
+ * @public
109
+ */
110
+ toString() {
111
+ return "[object GlowFilter]";
112
+ }
113
+ /**
114
+ * @description 指定されたオブジェクトの空間名を返します。
115
+ * Returns the space name of the specified object.
116
+ *
117
+ * @return {string}
118
+ * @default next2d.filters.GlowFilter
119
+ * @const
120
+ * @public
121
+ */
122
+ get namespace() {
123
+ return "next2d.filters.GlowFilter";
124
+ }
125
+ /**
126
+ * @description アルファ透明度の値です。
127
+ * The alpha transparency value for the color.
128
+ *
129
+ * @member {number}
130
+ * @default 1
131
+ * @public
132
+ */
133
+ get alpha() {
134
+ return this._$alpha;
135
+ }
136
+ set alpha(alpha) {
137
+ alpha = $clamp(+alpha, 0, 1, 0);
138
+ if (alpha !== this._$alpha) {
139
+ this._$alpha = alpha;
140
+ this._$doChanged();
141
+ }
142
+ }
143
+ /**
144
+ * @description 水平方向のぼかし量。
145
+ * The amount of horizontal blur.
146
+ *
147
+ * @member {number}
148
+ * @default 4
149
+ * @public
150
+ */
151
+ get blurX() {
152
+ return this._$blurFilter.blurX;
153
+ }
154
+ set blurX(blur_x) {
155
+ this._$blurFilter.blurX = blur_x;
156
+ }
157
+ /**
158
+ * @description 垂直方向のぼかし量。
159
+ * The amount of vertical blur.
160
+ *
161
+ * @member {number}
162
+ * @default 4
163
+ * @public
164
+ */
165
+ get blurY() {
166
+ return this._$blurFilter.blurY;
167
+ }
168
+ set blurY(blur_y) {
169
+ this._$blurFilter.blurY = blur_y;
170
+ }
171
+ /**
172
+ * @description グローのカラー
173
+ * The color of the glow.
174
+ *
175
+ * @member {number}
176
+ * @default 4
177
+ * @public
178
+ */
179
+ get color() {
180
+ return this._$color;
181
+ }
182
+ set color(color) {
183
+ color = $clamp($toColorInt(color), 0, 0xffffff, 4);
184
+ if (color !== this._$color) {
185
+ this._$color = color;
186
+ this._$doChanged();
187
+ }
188
+ }
189
+ /**
190
+ * @description グローが内側グローであるかどうか
191
+ * Specifies whether the glow is an inner glow.
192
+ *
193
+ * @member {boolean}
194
+ * @default true
195
+ * @public
196
+ */
197
+ get inner() {
198
+ return this._$inner;
199
+ }
200
+ set inner(inner) {
201
+ if (inner !== this._$inner) {
202
+ this._$inner = !!inner;
203
+ this._$doChanged();
204
+ }
205
+ }
206
+ /**
207
+ * @description オブジェクトにノックアウト効果を適用するかどうか
208
+ * Specifies whether the object has a knockout effect.
209
+ *
210
+ * @member {boolean}
211
+ * @default true
212
+ * @public
213
+ */
214
+ get knockout() {
215
+ return this._$knockout;
216
+ }
217
+ set knockout(knockout) {
218
+ if (knockout !== this._$knockout) {
219
+ this._$knockout = !!knockout;
220
+ this._$doChanged();
221
+ }
222
+ }
223
+ /**
224
+ * @description ぼかしの実行回数です。
225
+ * The number of times to perform the blur.
226
+ *
227
+ * @member {number}
228
+ * @default 1
229
+ * @public
230
+ */
231
+ get quality() {
232
+ return this._$blurFilter.quality;
233
+ }
234
+ set quality(quality) {
235
+ this._$blurFilter.quality = quality;
236
+ }
237
+ /**
238
+ * @description インプリントの強さまたは広がりです。
239
+ * The strength of the imprint or spread.
240
+ *
241
+ * @member {number}
242
+ * @default 1
243
+ * @public
244
+ */
245
+ get strength() {
246
+ return this._$strength;
247
+ }
248
+ set strength(strength) {
249
+ strength = $clamp(strength | 0, 0, 255, 0);
250
+ if (strength !== this._$strength) {
251
+ this._$strength = strength;
252
+ this._$doChanged();
253
+ }
254
+ }
255
+ /**
256
+ * @description オブジェクトのコピーを返します。
257
+ * Returns a copy of this filter object.
258
+ *
259
+ * @return {GlowFilter}
260
+ * @method
261
+ * @public
262
+ */
263
+ clone() {
264
+ return new GlowFilter(this._$color, this._$alpha, this._$blurFilter.blurX, this._$blurFilter.blurY, this._$strength, this._$blurFilter.quality, this._$inner, this._$knockout);
265
+ }
266
+ /**
267
+ * @return {array}
268
+ * @method
269
+ * @public
270
+ */
271
+ _$toArray() {
272
+ return $getArray(6, this._$color, this._$alpha, this._$blurFilter.blurX, this._$blurFilter.blurY, this._$strength, this._$blurFilter.quality, this._$inner, this._$knockout);
273
+ }
274
+ /**
275
+ * @return {boolean}
276
+ * @method
277
+ * @public
278
+ */
279
+ _$isUpdated() {
280
+ return this._$updated || this._$blurFilter._$isUpdated();
281
+ }
282
+ /**
283
+ * @param {object} bounds
284
+ * @param {number} [x_scale=0]
285
+ * @param {number} [y_scale=0]
286
+ * @return {object}
287
+ * @method
288
+ * @private
289
+ */
290
+ _$generateFilterRect(bounds, x_scale = 0, y_scale = 0) {
291
+ const clone = $getBoundsObject(bounds.xMin, bounds.xMax, bounds.yMin, bounds.yMax);
292
+ if (!this._$canApply()) {
293
+ return clone;
294
+ }
295
+ return this
296
+ ._$blurFilter
297
+ ._$generateFilterRect(clone, x_scale, y_scale);
298
+ }
299
+ /**
300
+ * @return {boolean}
301
+ * @method
302
+ * @private
303
+ */
304
+ _$canApply() {
305
+ return this._$alpha > 0
306
+ && this._$strength > 0
307
+ && this._$blurFilter._$canApply();
308
+ }
309
+ /**
310
+ * @param {CanvasToWebGLContext} context
311
+ * @param {array} matrix
312
+ * @return {WebGLTexture}
313
+ * @method
314
+ * @private
315
+ */
316
+ _$applyFilter(context, matrix) {
317
+ const manager = context.frameBuffer;
318
+ const currentAttachment = manager.currentAttachment;
319
+ if (!currentAttachment) {
320
+ throw new Error("the current attachment is null.");
321
+ }
322
+ this._$updated = false;
323
+ // reset
324
+ context.setTransform(1, 0, 0, 1, 0, 0);
325
+ if (!this._$canApply()) {
326
+ return manager
327
+ .getTextureFromCurrentAttachment();
328
+ }
329
+ const baseWidth = currentAttachment.width;
330
+ const baseHeight = currentAttachment.height;
331
+ const baseOffsetX = context._$offsetX;
332
+ const baseOffsetY = context._$offsetY;
333
+ const blurTexture = this
334
+ ._$blurFilter
335
+ ._$applyFilter(context, matrix, false);
336
+ const blurWidth = blurTexture.width;
337
+ const blurHeight = blurTexture.height;
338
+ const blurOffsetX = context._$offsetX;
339
+ const blurOffsetY = context._$offsetY;
340
+ const width = this._$inner ? baseWidth : blurWidth;
341
+ const height = this._$inner ? baseHeight : blurHeight;
342
+ const baseTextureX = this._$inner ? 0 : blurOffsetX - baseOffsetX;
343
+ const baseTextureY = this._$inner ? 0 : blurOffsetY - baseOffsetY;
344
+ const blurTextureX = this._$inner ? -blurOffsetX : 0;
345
+ const blurTextureY = this._$inner ? -blurOffsetY : 0;
346
+ const type = this._$inner
347
+ ? "inner"
348
+ : "outer";
349
+ context._$bind(currentAttachment);
350
+ context._$applyBitmapFilter(blurTexture, width, height, baseWidth, baseHeight, baseTextureX, baseTextureY, blurWidth, blurHeight, blurTextureX, blurTextureY, true, type, this._$knockout, this._$strength, null, null, null, $intToR(this._$color, this._$alpha, true), $intToG(this._$color, this._$alpha, true), $intToB(this._$color, this._$alpha, true), this._$alpha, 0, 0, 0, 0);
351
+ context._$offsetX = baseOffsetX + baseTextureX;
352
+ context._$offsetY = baseOffsetY + baseTextureY;
353
+ manager.releaseTexture(blurTexture);
354
+ return manager.getTextureFromCurrentAttachment();
355
+ }
356
+ }
@@ -0,0 +1,243 @@
1
+ import { BitmapFilter } from "./BitmapFilter";
2
+ import type { CanvasToWebGLContext } from "@next2d/webgl";
3
+ import type { FilterQualityImpl } from "./interface/FilterQualityImpl";
4
+ import type { BitmapFilterTypeImpl } from "./interface/BitmapFilterTypeImpl";
5
+ import type { BoundsImpl } from "./interface/BoundsImpl";
6
+ /**
7
+ * GradientBevelFilter クラスを使用すると、オブジェクトにグラデーションベベル効果を適用し、表示できます。
8
+ * グラデーションベベルは、オブジェクトの外側、内側、または上側が斜めになったエッジであり、グラデーションカラーで強調されます。
9
+ * 斜めのエッジによってオブジェクトが 3 次元に見えます。
10
+ *
11
+ * The GradientBevelFilter class lets you apply a gradient bevel effect to display objects.
12
+ * A gradient bevel is a beveled edge, enhanced with gradient color,
13
+ * on the outside, inside, or top of an object.
14
+ * Beveled edges make objects look three-dimensional.
15
+ *
16
+ * @class
17
+ * @memberOf next2d.filters
18
+ * @extends BitmapFilter
19
+ */
20
+ export declare class GradientBevelFilter extends BitmapFilter {
21
+ private _$blurFilter;
22
+ private _$distance;
23
+ private _$angle;
24
+ private _$colors;
25
+ private _$alphas;
26
+ private _$ratios;
27
+ private _$strength;
28
+ private _$type;
29
+ private _$knockout;
30
+ /**
31
+ * @param {number} [distance=4.0]
32
+ * @param {number} [angle=45]
33
+ * @param {array} [colors=null]
34
+ * @param {array} [alphas=null]
35
+ * @param {array} [ratios=null]
36
+ * @param {number} [blur_x=4.0]
37
+ * @param {number} [blur_y=4.0]
38
+ * @param {number} [strength=1]
39
+ * @param {number} [quality=1]
40
+ * @param {string} [type=BitmapFilterType.INNER]
41
+ * @param {boolean} [knockout=false]
42
+ *
43
+ * @constructor
44
+ * @public
45
+ */
46
+ constructor(distance?: number, angle?: number, colors?: number[] | null, alphas?: number[] | null, ratios?: number[] | null, blur_x?: number, blur_y?: number, strength?: number, quality?: FilterQualityImpl, type?: BitmapFilterTypeImpl, knockout?: boolean);
47
+ /**
48
+ * @description 指定されたクラスのストリングを返します。
49
+ * Returns the string representation of the specified class.
50
+ *
51
+ * @return {string}
52
+ * @default [class GradientBevelFilter]
53
+ * @method
54
+ * @static
55
+ */
56
+ static toString(): string;
57
+ /**
58
+ * @description 指定されたクラスの空間名を返します。
59
+ * Returns the space name of the specified class.
60
+ *
61
+ * @return {string}
62
+ * @default next2d.filters.GradientBevelFilter
63
+ * @const
64
+ * @static
65
+ */
66
+ static get namespace(): string;
67
+ /**
68
+ * @description 指定されたオブジェクトのストリングを返します。
69
+ * Returns the string representation of the specified object.
70
+ *
71
+ * @return {string}
72
+ * @default [object GradientBevelFilter]
73
+ * @method
74
+ * @public
75
+ */
76
+ toString(): string;
77
+ /**
78
+ * @description 指定されたオブジェクトの空間名を返します。
79
+ * Returns the space name of the specified object.
80
+ *
81
+ * @return {string}
82
+ * @default next2d.filters.GradientBevelFilter
83
+ * @const
84
+ * @public
85
+ */
86
+ get namespace(): string;
87
+ /**
88
+ * @description カラー配列内の各色に対応するアルファ透明度の値の配列です。
89
+ * An array of alpha transparency values
90
+ * for the corresponding colors in the colors array.
91
+ *
92
+ * @member {array}
93
+ * @default null
94
+ * @public
95
+ */
96
+ get alphas(): number[] | null;
97
+ set alphas(alphas: number[] | null);
98
+ /**
99
+ * @description シャドウの角度
100
+ * The angle of the shadow.
101
+ *
102
+ * @member {number}
103
+ * @default 45
104
+ * @public
105
+ */
106
+ get angle(): number;
107
+ set angle(angle: number);
108
+ /**
109
+ * @description 水平方向のぼかし量。
110
+ * The amount of horizontal blur.
111
+ *
112
+ * @member {number}
113
+ * @default 4
114
+ * @public
115
+ */
116
+ get blurX(): number;
117
+ set blurX(blur_x: number);
118
+ /**
119
+ * @description 垂直方向のぼかし量。
120
+ * The amount of vertical blur.
121
+ *
122
+ * @member {number}
123
+ * @default 4
124
+ * @public
125
+ */
126
+ get blurY(): number;
127
+ set blurY(blur_y: number);
128
+ /**
129
+ * @description グラデーションで使用する RGB 16 進数カラー値の配列です。
130
+ * An array of RGB hexadecimal color values to use in the gradient.
131
+ *
132
+ * @member {array}
133
+ * @default null
134
+ * @public
135
+ */
136
+ get colors(): number[] | null;
137
+ set colors(colors: number[] | null);
138
+ /**
139
+ * @description シャドウのオフセット距離です。
140
+ * The offset distance for the shadow, in pixels.
141
+ *
142
+ * @member {number}
143
+ * @default 4
144
+ * @public
145
+ */
146
+ get distance(): number;
147
+ set distance(distance: number);
148
+ /**
149
+ * @description オブジェクトにノックアウト効果を適用するかどうか
150
+ * Specifies whether the object has a knockout effect.
151
+ *
152
+ * @member {boolean}
153
+ * @default false
154
+ * @public
155
+ */
156
+ get knockout(): boolean;
157
+ set knockout(knockout: boolean);
158
+ /**
159
+ * @description ぼかしの実行回数です。
160
+ * The number of times to perform the blur.
161
+ *
162
+ * @member {number}
163
+ * @default 1
164
+ * @public
165
+ */
166
+ get quality(): FilterQualityImpl;
167
+ set quality(quality: FilterQualityImpl);
168
+ /**
169
+ * @description カラー配列内の対応するカラーの色分布比率の配列です。
170
+ * An array of color distribution ratios
171
+ * for the corresponding colors in the colors array.
172
+ *
173
+ * @member {array}
174
+ * @default null
175
+ * @public
176
+ */
177
+ get ratios(): number[] | null;
178
+ set ratios(ratios: number[] | null);
179
+ /**
180
+ * @description インプリントの強さまたは広がりです。
181
+ * The strength of the imprint or spread.
182
+ *
183
+ * @member {number}
184
+ * @default 1
185
+ * @public
186
+ */
187
+ get strength(): number;
188
+ set strength(strength: number);
189
+ /**
190
+ * @description オブジェクトでのベベルの配置
191
+ * The placement of the bevel on the object.
192
+ *
193
+ * @member {string}
194
+ * @default BitmapFilterType.INNER
195
+ * @public
196
+ */
197
+ get type(): BitmapFilterTypeImpl;
198
+ set type(type: BitmapFilterTypeImpl);
199
+ /**
200
+ * @description オブジェクトのコピーを返します。
201
+ * Returns a copy of this filter object.
202
+ *
203
+ * @return {GradientBevelFilter}
204
+ * @method
205
+ * @public
206
+ */
207
+ clone(): GradientBevelFilter;
208
+ /**
209
+ * @return {array}
210
+ * @method
211
+ * @public
212
+ */
213
+ _$toArray(): any[];
214
+ /**
215
+ * @return {boolean}
216
+ * @method
217
+ * @private
218
+ */
219
+ _$isUpdated(): boolean;
220
+ /**
221
+ * @param {object} bounds
222
+ * @param {number} [x_scale=0]
223
+ * @param {number} [y_scale=0]
224
+ * @return {object}
225
+ * @method
226
+ * @private
227
+ */
228
+ _$generateFilterRect(bounds: BoundsImpl, x_scale?: number, y_scale?: number): BoundsImpl;
229
+ /**
230
+ * @return {boolean}
231
+ * @method
232
+ * @private
233
+ */
234
+ _$canApply(): boolean;
235
+ /**
236
+ * @param {CanvasToWebGLContext} context
237
+ * @param {Float32Array} matrix
238
+ * @return {WebGLTexture}
239
+ * @method
240
+ * @private
241
+ */
242
+ _$applyFilter(context: CanvasToWebGLContext, matrix: Float32Array): WebGLTexture;
243
+ }