@next2d/geom 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Next2D
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ @next2d/geom
2
+ =============
3
+
4
+ ## Installation
5
+
6
+ ```
7
+ npm install @next2d/geom
8
+ ```
9
+
10
+ ## License
11
+ This project is licensed under the [MIT License](https://opensource.org/licenses/MIT) - see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,201 @@
1
+ /**
2
+ * ColorTransform クラスを使用すると、表示オブジェクトのカラー値を調整することができます。
3
+ * カラー調整、つまり "カラー変換" は、赤、緑、青、アルファ透明度の 4 つのチャンネルすべてに適用できます。
4
+ * <ul>
5
+ * <li>新しい red 値 = (古い red 値 * redMultiplier ) + redOffset</li>
6
+ * <li>新しい green 値 = (古い green 値 * greenMultiplier ) + greenOffset</li>
7
+ * <li>新しい blue 値 = (古い blue 値 * blueMultiplier ) + blueOffset</li>
8
+ * <li>新しい alpha 値 = (古い alpha 値 * alphaMultiplier ) + alphaOffset</li>
9
+ * </ul>
10
+ * 算出後、カラーチャンネル値が 255 よりも大きい場合は 255 に設定されます。
11
+ * 0 より小さい場合は 0 に設定されます。
12
+ *
13
+ * The ColorTransform class lets you adjust the color values in a display object.
14
+ * The color adjustment or color transformation can be applied
15
+ * to all four channels: red, green, blue, and alpha transparency.
16
+ * <ul>
17
+ * <li>New red value = (old red value * redMultiplier) + redOffset</li>
18
+ * <li>New green value = (old green value * greenMultiplier) + greenOffset</li>
19
+ * <li>New blue value = (old blue value * blueMultiplier) + blueOffset</li>
20
+ * <li>New alpha value = (old alpha value * alphaMultiplier) + alphaOffset</li>
21
+ * </ul>
22
+ * If any of the color channel values is greater than 255 after the calculation,
23
+ * it is set to 255. If it is less than 0, it is set to 0.
24
+ *
25
+ * @class
26
+ * @memberOf next2d.geom
27
+ */
28
+ export declare class ColorTransform {
29
+ readonly _$colorTransform: Float32Array;
30
+ /**
31
+ * @param {number} [red_multiplier=1]
32
+ * @param {number} [green_multiplier=1]
33
+ * @param {number} [blue_multiplier=1]
34
+ * @param {number} [alpha_multiplier=1]
35
+ * @param {number} [red_offset=0]
36
+ * @param {number} [green_offset=0]
37
+ * @param {number} [blue_offset=0]
38
+ * @param {number} [alpha_offset=0]
39
+ *
40
+ * @example <caption>Example usage of ColorTransform.</caption>
41
+ * // new ColorTransform
42
+ * const {ColorTransform} = next2d.geom;
43
+ * const colorTransform = new ColorTransform();
44
+ * // set new ColorTransform
45
+ * const {MovieClip} = next2d.display;
46
+ * const movieClip = new MovieClip();
47
+ * movieClip.transform.colorTransform = colorTransform;
48
+ *
49
+ * @constructor
50
+ * @public
51
+ */
52
+ constructor(red_multiplier?: number, green_multiplier?: number, blue_multiplier?: number, alpha_multiplier?: number, red_offset?: number, green_offset?: number, blue_offset?: number, alpha_offset?: number);
53
+ /**
54
+ * 指定されたクラスのストリングを返します。
55
+ * Returns the string representation of the specified class.
56
+ *
57
+ * @return {string}
58
+ * @default [class ColorTransform]
59
+ * @method
60
+ * @static
61
+ */
62
+ static toString(): string;
63
+ /**
64
+ * @description 指定されたクラスの空間名を返します。
65
+ * Returns the space name of the specified class.
66
+ *
67
+ * @member {string}
68
+ * @default next2d.geom.ColorTransform
69
+ * @const
70
+ * @static
71
+ */
72
+ static get namespace(): string;
73
+ /**
74
+ * @description 指定されたオブジェクトのストリングを返します。
75
+ * Returns the string representation of the specified object.
76
+ *
77
+ * @return {string}
78
+ * @method
79
+ * @public
80
+ */
81
+ toString(): string;
82
+ /**
83
+ * @description 指定されたオブジェクトの空間名を返します。
84
+ * Returns the space name of the specified object.
85
+ *
86
+ * @member {string}
87
+ * @default next2d.geom.ColorTransform
88
+ * @const
89
+ * @public
90
+ */
91
+ get namespace(): string;
92
+ /**
93
+ * @description アルファ透明度チャンネル値に乗算する 10 進数値です。
94
+ * A decimal value that is multiplied with the alpha transparency channel value.
95
+ *
96
+ * @member {number}
97
+ * @default 1
98
+ * @public
99
+ */
100
+ get alphaMultiplier(): number;
101
+ set alphaMultiplier(alpha_multiplier: number);
102
+ /**
103
+ * @description アルファ透明度チャンネル値に alphaMultiplier 値を乗算した後に加算する数値です。
104
+ * 数値の範囲は -255 ~ 255 です。
105
+ * A number from -255 to 255 that is added to the alpha transparency channel value after
106
+ * it has been multiplied by the alphaMultiplier value.
107
+ *
108
+ * @member {number}
109
+ * @default 0
110
+ * @public
111
+ */
112
+ get alphaOffset(): number;
113
+ set alphaOffset(alpha_offset: number);
114
+ /**
115
+ * @description 青チャンネル値に乗算する 10 進数値です。
116
+ * A decimal value that is multiplied with the blue channel value.
117
+ *
118
+ * @member {number}
119
+ * @default 1
120
+ * @public
121
+ */
122
+ get blueMultiplier(): number;
123
+ set blueMultiplier(blue_multiplier: number);
124
+ /**
125
+ * @description 青チャンネル値に blueMultiplier 値を乗算した後に加算する数値です。
126
+ * 数値の範囲は -255 ~ 255 です。
127
+ * A number from -255 to 255 that is added to the blue channel value after
128
+ * it has been multiplied by the blueMultiplier value.
129
+ *
130
+ * @member {number}
131
+ * @default 0
132
+ * @public
133
+ */
134
+ get blueOffset(): number;
135
+ set blueOffset(blue_offset: number);
136
+ /**
137
+ * @description 緑チャンネル値に乗算する 10 進数値です。
138
+ * A decimal value that is multiplied with the green channel value.
139
+ *
140
+ * @member {number}
141
+ * @default 1
142
+ * @public
143
+ */
144
+ get greenMultiplier(): number;
145
+ set greenMultiplier(green_multiplier: number);
146
+ /**
147
+ * @description 緑チャンネル値に greenMultiplier 値を乗算した後に加算する数値です。
148
+ * 数値の範囲は -255 ~ 255 です。
149
+ * A number from -255 to 255 that is added to the green channel value after
150
+ * it has been multiplied by the greenMultiplier value.
151
+ *
152
+ * @member {number}
153
+ * @default 0
154
+ * @public
155
+ */
156
+ get greenOffset(): number;
157
+ set greenOffset(green_offset: number);
158
+ /**
159
+ * @description 赤チャンネル値に乗算する 10 進数値です。
160
+ * A decimal value that is multiplied with the red channel value.
161
+ *
162
+ * @member {number}
163
+ * @default 1
164
+ * @public
165
+ */
166
+ get redMultiplier(): number;
167
+ set redMultiplier(red_multiplier: number);
168
+ /**
169
+ * @description 赤チャンネル値に redMultiplier 値を乗算した後に加算する数値です。
170
+ * 数値の範囲は -255 ~ 255 です。
171
+ * A number from -255 to 255 that is added to the red channel value after
172
+ * it has been multiplied by the redMultiplier value.
173
+ *
174
+ * @member {number}
175
+ * @default 0
176
+ * @public
177
+ */
178
+ get redOffset(): number;
179
+ set redOffset(red_offset: number);
180
+ /**
181
+ * @description 2 番目のパラメーターで指定された ColorTransform オブジェクトと
182
+ * 現在の ColorTransform オブジェクトを連結し
183
+ * 2 つのカラー変換を加算的に組み合わせた結果を現在のオブジェクトに設定します。
184
+ * Concatenates the ColorTransform object specified
185
+ * by the second parameter with the current ColorTransform object
186
+ * and sets the current object as the result,
187
+ * which is an additive combination of the two color transformations.
188
+ *
189
+ * @param {ColorTransform} second - ColorTransformオブジェクト
190
+ * @return {void}
191
+ * @method
192
+ * @public
193
+ */
194
+ concat(second: ColorTransform): void;
195
+ /**
196
+ * @return {ColorTransform}
197
+ * @method
198
+ * @private
199
+ */
200
+ _$clone(): ColorTransform;
201
+ }
@@ -0,0 +1,278 @@
1
+ import { $getColorTransform } from "@next2d/util";
2
+ import { $getFloat32Array8, $clamp, $multiplicationColor, $poolFloat32Array8 } from "@next2d/share";
3
+ /**
4
+ * ColorTransform クラスを使用すると、表示オブジェクトのカラー値を調整することができます。
5
+ * カラー調整、つまり "カラー変換" は、赤、緑、青、アルファ透明度の 4 つのチャンネルすべてに適用できます。
6
+ * <ul>
7
+ * <li>新しい red 値 = (古い red 値 * redMultiplier ) + redOffset</li>
8
+ * <li>新しい green 値 = (古い green 値 * greenMultiplier ) + greenOffset</li>
9
+ * <li>新しい blue 値 = (古い blue 値 * blueMultiplier ) + blueOffset</li>
10
+ * <li>新しい alpha 値 = (古い alpha 値 * alphaMultiplier ) + alphaOffset</li>
11
+ * </ul>
12
+ * 算出後、カラーチャンネル値が 255 よりも大きい場合は 255 に設定されます。
13
+ * 0 より小さい場合は 0 に設定されます。
14
+ *
15
+ * The ColorTransform class lets you adjust the color values in a display object.
16
+ * The color adjustment or color transformation can be applied
17
+ * to all four channels: red, green, blue, and alpha transparency.
18
+ * <ul>
19
+ * <li>New red value = (old red value * redMultiplier) + redOffset</li>
20
+ * <li>New green value = (old green value * greenMultiplier) + greenOffset</li>
21
+ * <li>New blue value = (old blue value * blueMultiplier) + blueOffset</li>
22
+ * <li>New alpha value = (old alpha value * alphaMultiplier) + alphaOffset</li>
23
+ * </ul>
24
+ * If any of the color channel values is greater than 255 after the calculation,
25
+ * it is set to 255. If it is less than 0, it is set to 0.
26
+ *
27
+ * @class
28
+ * @memberOf next2d.geom
29
+ */
30
+ export class ColorTransform {
31
+ /**
32
+ * @param {number} [red_multiplier=1]
33
+ * @param {number} [green_multiplier=1]
34
+ * @param {number} [blue_multiplier=1]
35
+ * @param {number} [alpha_multiplier=1]
36
+ * @param {number} [red_offset=0]
37
+ * @param {number} [green_offset=0]
38
+ * @param {number} [blue_offset=0]
39
+ * @param {number} [alpha_offset=0]
40
+ *
41
+ * @example <caption>Example usage of ColorTransform.</caption>
42
+ * // new ColorTransform
43
+ * const {ColorTransform} = next2d.geom;
44
+ * const colorTransform = new ColorTransform();
45
+ * // set new ColorTransform
46
+ * const {MovieClip} = next2d.display;
47
+ * const movieClip = new MovieClip();
48
+ * movieClip.transform.colorTransform = colorTransform;
49
+ *
50
+ * @constructor
51
+ * @public
52
+ */
53
+ constructor(red_multiplier = 1, green_multiplier = 1, blue_multiplier = 1, alpha_multiplier = 1, red_offset = 0, green_offset = 0, blue_offset = 0, alpha_offset = 0) {
54
+ /**
55
+ * @type {Float32Array}
56
+ * @private
57
+ */
58
+ this._$colorTransform = $getFloat32Array8();
59
+ // setup
60
+ this.redMultiplier = red_multiplier;
61
+ this.greenMultiplier = green_multiplier;
62
+ this.blueMultiplier = blue_multiplier;
63
+ this.alphaMultiplier = alpha_multiplier;
64
+ this.redOffset = red_offset;
65
+ this.greenOffset = green_offset;
66
+ this.blueOffset = blue_offset;
67
+ this.alphaOffset = alpha_offset;
68
+ }
69
+ /**
70
+ * 指定されたクラスのストリングを返します。
71
+ * Returns the string representation of the specified class.
72
+ *
73
+ * @return {string}
74
+ * @default [class ColorTransform]
75
+ * @method
76
+ * @static
77
+ */
78
+ static toString() {
79
+ return "[class ColorTransform]";
80
+ }
81
+ /**
82
+ * @description 指定されたクラスの空間名を返します。
83
+ * Returns the space name of the specified class.
84
+ *
85
+ * @member {string}
86
+ * @default next2d.geom.ColorTransform
87
+ * @const
88
+ * @static
89
+ */
90
+ static get namespace() {
91
+ return "next2d.geom.ColorTransform";
92
+ }
93
+ /**
94
+ * @description 指定されたオブジェクトのストリングを返します。
95
+ * Returns the string representation of the specified object.
96
+ *
97
+ * @return {string}
98
+ * @method
99
+ * @public
100
+ */
101
+ toString() {
102
+ return "(redMultiplier=" + this._$colorTransform[0] + ", " +
103
+ "greenMultiplier=" + this._$colorTransform[1] + ", " +
104
+ "blueMultiplier=" + this._$colorTransform[2] + ", " +
105
+ "alphaMultiplier=" + this._$colorTransform[3] + ", " +
106
+ "redOffset=" + this._$colorTransform[4] + ", " +
107
+ "greenOffset=" + this._$colorTransform[5] + ", " +
108
+ "blueOffset=" + this._$colorTransform[6] + ", " +
109
+ "alphaOffset=" + this._$colorTransform[7] + ")";
110
+ }
111
+ /**
112
+ * @description 指定されたオブジェクトの空間名を返します。
113
+ * Returns the space name of the specified object.
114
+ *
115
+ * @member {string}
116
+ * @default next2d.geom.ColorTransform
117
+ * @const
118
+ * @public
119
+ */
120
+ get namespace() {
121
+ return "next2d.geom.ColorTransform";
122
+ }
123
+ /**
124
+ * @description アルファ透明度チャンネル値に乗算する 10 進数値です。
125
+ * A decimal value that is multiplied with the alpha transparency channel value.
126
+ *
127
+ * @member {number}
128
+ * @default 1
129
+ * @public
130
+ */
131
+ get alphaMultiplier() {
132
+ return this._$colorTransform[3];
133
+ }
134
+ set alphaMultiplier(alpha_multiplier) {
135
+ this._$colorTransform[3] = $clamp(+alpha_multiplier, 0, 1, 0);
136
+ }
137
+ /**
138
+ * @description アルファ透明度チャンネル値に alphaMultiplier 値を乗算した後に加算する数値です。
139
+ * 数値の範囲は -255 ~ 255 です。
140
+ * A number from -255 to 255 that is added to the alpha transparency channel value after
141
+ * it has been multiplied by the alphaMultiplier value.
142
+ *
143
+ * @member {number}
144
+ * @default 0
145
+ * @public
146
+ */
147
+ get alphaOffset() {
148
+ return this._$colorTransform[7];
149
+ }
150
+ set alphaOffset(alpha_offset) {
151
+ this._$colorTransform[7] = $clamp(alpha_offset | 0, -255, 255, 0);
152
+ }
153
+ /**
154
+ * @description 青チャンネル値に乗算する 10 進数値です。
155
+ * A decimal value that is multiplied with the blue channel value.
156
+ *
157
+ * @member {number}
158
+ * @default 1
159
+ * @public
160
+ */
161
+ get blueMultiplier() {
162
+ return this._$colorTransform[2];
163
+ }
164
+ set blueMultiplier(blue_multiplier) {
165
+ this._$colorTransform[2] = $clamp(+blue_multiplier, 0, 1, 0);
166
+ }
167
+ /**
168
+ * @description 青チャンネル値に blueMultiplier 値を乗算した後に加算する数値です。
169
+ * 数値の範囲は -255 ~ 255 です。
170
+ * A number from -255 to 255 that is added to the blue channel value after
171
+ * it has been multiplied by the blueMultiplier value.
172
+ *
173
+ * @member {number}
174
+ * @default 0
175
+ * @public
176
+ */
177
+ get blueOffset() {
178
+ return this._$colorTransform[6];
179
+ }
180
+ set blueOffset(blue_offset) {
181
+ this._$colorTransform[6] = $clamp(blue_offset | 0, -255, 255, 0);
182
+ }
183
+ /**
184
+ * @description 緑チャンネル値に乗算する 10 進数値です。
185
+ * A decimal value that is multiplied with the green channel value.
186
+ *
187
+ * @member {number}
188
+ * @default 1
189
+ * @public
190
+ */
191
+ get greenMultiplier() {
192
+ return this._$colorTransform[1];
193
+ }
194
+ set greenMultiplier(green_multiplier) {
195
+ this._$colorTransform[1] = $clamp(+green_multiplier, 0, 1, 0);
196
+ }
197
+ /**
198
+ * @description 緑チャンネル値に greenMultiplier 値を乗算した後に加算する数値です。
199
+ * 数値の範囲は -255 ~ 255 です。
200
+ * A number from -255 to 255 that is added to the green channel value after
201
+ * it has been multiplied by the greenMultiplier value.
202
+ *
203
+ * @member {number}
204
+ * @default 0
205
+ * @public
206
+ */
207
+ get greenOffset() {
208
+ return this._$colorTransform[5];
209
+ }
210
+ set greenOffset(green_offset) {
211
+ this._$colorTransform[5] = $clamp(green_offset | 0, -255, 255, 0);
212
+ }
213
+ /**
214
+ * @description 赤チャンネル値に乗算する 10 進数値です。
215
+ * A decimal value that is multiplied with the red channel value.
216
+ *
217
+ * @member {number}
218
+ * @default 1
219
+ * @public
220
+ */
221
+ get redMultiplier() {
222
+ return this._$colorTransform[0];
223
+ }
224
+ set redMultiplier(red_multiplier) {
225
+ this._$colorTransform[0] = $clamp(+red_multiplier, 0, 1, 0);
226
+ }
227
+ /**
228
+ * @description 赤チャンネル値に redMultiplier 値を乗算した後に加算する数値です。
229
+ * 数値の範囲は -255 ~ 255 です。
230
+ * A number from -255 to 255 that is added to the red channel value after
231
+ * it has been multiplied by the redMultiplier value.
232
+ *
233
+ * @member {number}
234
+ * @default 0
235
+ * @public
236
+ */
237
+ get redOffset() {
238
+ return this._$colorTransform[4];
239
+ }
240
+ set redOffset(red_offset) {
241
+ this._$colorTransform[4] = $clamp(red_offset | 0, -255, 255, 0);
242
+ }
243
+ /**
244
+ * @description 2 番目のパラメーターで指定された ColorTransform オブジェクトと
245
+ * 現在の ColorTransform オブジェクトを連結し
246
+ * 2 つのカラー変換を加算的に組み合わせた結果を現在のオブジェクトに設定します。
247
+ * Concatenates the ColorTransform object specified
248
+ * by the second parameter with the current ColorTransform object
249
+ * and sets the current object as the result,
250
+ * which is an additive combination of the two color transformations.
251
+ *
252
+ * @param {ColorTransform} second - ColorTransformオブジェクト
253
+ * @return {void}
254
+ * @method
255
+ * @public
256
+ */
257
+ concat(second) {
258
+ const multiColor = $multiplicationColor(this._$colorTransform, second._$colorTransform);
259
+ // update
260
+ this.redMultiplier = multiColor[0];
261
+ this.greenMultiplier = multiColor[1];
262
+ this.blueMultiplier = multiColor[2];
263
+ this.alphaMultiplier = multiColor[3];
264
+ this.redOffset = multiColor[4];
265
+ this.greenOffset = multiColor[5];
266
+ this.blueOffset = multiColor[6];
267
+ this.alphaOffset = multiColor[7];
268
+ $poolFloat32Array8(multiColor);
269
+ }
270
+ /**
271
+ * @return {ColorTransform}
272
+ * @method
273
+ * @private
274
+ */
275
+ _$clone() {
276
+ return $getColorTransform(this._$colorTransform[0], this._$colorTransform[1], this._$colorTransform[2], this._$colorTransform[3], this._$colorTransform[4], this._$colorTransform[5], this._$colorTransform[6], this._$colorTransform[7]);
277
+ }
278
+ }