@xviewer.js/debug 1.0.0-alpha.21 → 1.0.0-alpha.22
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/dist/main.js +25 -58
- package/dist/main.js.map +1 -1
- package/dist/module.js +25 -58
- package/dist/module.js.map +1 -1
- package/package.json +2 -2
package/dist/main.js
CHANGED
|
@@ -931,67 +931,34 @@ class ColorController extends Controller {
|
|
|
931
931
|
}
|
|
932
932
|
}
|
|
933
933
|
|
|
934
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
935
|
-
try {
|
|
936
|
-
var info = gen[key](arg);
|
|
937
|
-
var value = info.value;
|
|
938
|
-
} catch (error) {
|
|
939
|
-
reject(error);
|
|
940
|
-
return;
|
|
941
|
-
}
|
|
942
|
-
if (info.done) resolve(value);
|
|
943
|
-
else Promise.resolve(value).then(_next, _throw);
|
|
944
|
-
}
|
|
945
|
-
function _async_to_generator(fn) {
|
|
946
|
-
return function() {
|
|
947
|
-
var self = this, args = arguments;
|
|
948
|
-
|
|
949
|
-
return new Promise(function(resolve, reject) {
|
|
950
|
-
var gen = fn.apply(self, args);
|
|
951
|
-
|
|
952
|
-
function _next(value) {
|
|
953
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
function _throw(err) {
|
|
957
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
958
|
-
}
|
|
959
|
-
|
|
960
|
-
_next(undefined);
|
|
961
|
-
});
|
|
962
|
-
};
|
|
963
|
-
}
|
|
964
|
-
|
|
965
934
|
class ImageController extends Controller {
|
|
966
|
-
static toDataURL(img) {
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
return url;
|
|
990
|
-
}
|
|
935
|
+
static async toDataURL(img) {
|
|
936
|
+
if (img instanceof HTMLImageElement) {
|
|
937
|
+
return img.src;
|
|
938
|
+
} else {
|
|
939
|
+
if (img) {
|
|
940
|
+
let url = ImageController._imageMap.get(img);
|
|
941
|
+
if (url) return url;
|
|
942
|
+
const w = Math.min(img.width, 256);
|
|
943
|
+
const h = Math.min(img.height, 256);
|
|
944
|
+
if (ImageController._context == null) {
|
|
945
|
+
ImageController._context = document.createElement('canvas').getContext("2d");
|
|
946
|
+
}
|
|
947
|
+
ImageController._context.canvas.width = w;
|
|
948
|
+
ImageController._context.canvas.height = h;
|
|
949
|
+
if (img.data) {
|
|
950
|
+
let imageData = ImageController._context.createImageData(img.width, img.height);
|
|
951
|
+
imageData.data.set(img.data);
|
|
952
|
+
img = await createImageBitmap(imageData);
|
|
953
|
+
}
|
|
954
|
+
if (img instanceof ImageBitmap) {
|
|
955
|
+
ImageController._context.drawImage(img, 0, 0, img.width, img.height, 0, 0, w, h);
|
|
956
|
+
ImageController._imageMap.set(img, url = ImageController._context.canvas.toDataURL());
|
|
957
|
+
return url;
|
|
991
958
|
}
|
|
992
|
-
return "";
|
|
993
959
|
}
|
|
994
|
-
|
|
960
|
+
return "";
|
|
961
|
+
}
|
|
995
962
|
}
|
|
996
963
|
updateDisplay() {
|
|
997
964
|
ImageController.toDataURL(this.getValue()).then((url)=>this.$img.src = url);
|