@xort/cga 0.0.84 → 0.0.85
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/build/@xort_cga.js +290 -754
- package/dist/math/Color.d.ts +1 -0
- package/dist/math/Color.js +10 -0
- package/package.json +1 -1
- package/src/math/Color.ts +14 -1
package/dist/math/Color.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export declare class Color {
|
|
|
21
21
|
copy(color: this): this;
|
|
22
22
|
equals(c: this): boolean;
|
|
23
23
|
toArray(array?: number[], offset?: number): number[];
|
|
24
|
+
fromArray(array?: number[], offset?: number): number[];
|
|
24
25
|
private byteToFloat;
|
|
25
26
|
private floatToByte;
|
|
26
27
|
getHexCssString(): string;
|
package/dist/math/Color.js
CHANGED
|
@@ -163,6 +163,16 @@ var Color = /** @class */ (function () {
|
|
|
163
163
|
array[offset + 3] = this.a;
|
|
164
164
|
return array;
|
|
165
165
|
};
|
|
166
|
+
Color.prototype.fromArray = function (array, offset) {
|
|
167
|
+
if (array === void 0) { array = []; }
|
|
168
|
+
if (offset === void 0) { offset = 0; }
|
|
169
|
+
this.r = array[offset];
|
|
170
|
+
this.g = array[offset + 1];
|
|
171
|
+
this.b = array[offset + 2];
|
|
172
|
+
if (array.length >= 4 + offset)
|
|
173
|
+
this.a = array[offset + 3];
|
|
174
|
+
return array;
|
|
175
|
+
};
|
|
166
176
|
Color.prototype.byteToFloat = function (val) {
|
|
167
177
|
return val / 255.0;
|
|
168
178
|
};
|
package/package.json
CHANGED
package/src/math/Color.ts
CHANGED
|
@@ -5,7 +5,7 @@ export class Color {
|
|
|
5
5
|
_b: number = 0.0;
|
|
6
6
|
_a: number = 1.0;
|
|
7
7
|
|
|
8
|
-
constructor(r: number = 0, g: number = 0, b: number = 0, a: number = 1) {
|
|
8
|
+
constructor(r: number = 0, g: number = 0, b: number = 0, a: number = 1) {
|
|
9
9
|
this._r = r;
|
|
10
10
|
this._g = g;
|
|
11
11
|
this._b = b;
|
|
@@ -168,6 +168,19 @@ export class Color {
|
|
|
168
168
|
|
|
169
169
|
return array;
|
|
170
170
|
}
|
|
171
|
+
|
|
172
|
+
fromArray(array: number[] = [], offset = 0) {
|
|
173
|
+
|
|
174
|
+
this.r = array[offset];
|
|
175
|
+
this.g = array[offset + 1];
|
|
176
|
+
this.b = array[offset + 2];
|
|
177
|
+
|
|
178
|
+
if (array.length >= 4 + offset)
|
|
179
|
+
this.a = array[offset + 3];
|
|
180
|
+
|
|
181
|
+
return array;
|
|
182
|
+
}
|
|
183
|
+
|
|
171
184
|
private byteToFloat(val: number) {
|
|
172
185
|
return val / 255.0;
|
|
173
186
|
};
|