hdr-canvas 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +12 -3
- package/dist/hdr-canvas.cjs +2 -1
- package/dist/hdr-canvas.cjs.map +1 -1
- package/dist/hdr-canvas.js +2 -1
- package/dist/hdr-canvas.js.map +1 -1
- package/dist/hdr-canvas.min.js +1 -1
- package/dist/hdr-canvas.min.js.map +1 -1
- package/package.json +2 -2
- package/src/@types/HDRCanvas.d.ts +1 -0
- package/src/hdr-canvas.ts +24 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "hdr-canvas",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.6",
|
4
4
|
"description": "HDR capable HTML canvas",
|
5
5
|
"main": "dist/hdr-canvas.js",
|
6
6
|
"files": [
|
@@ -49,7 +49,7 @@
|
|
49
49
|
"rimraf": "^6.0.0",
|
50
50
|
"rollup": "^4.18.1",
|
51
51
|
"rollup-plugin-dts": "^6.1.1",
|
52
|
-
"three": "^0.
|
52
|
+
"three": "^0.167.0",
|
53
53
|
"tslib": "^2.6.3",
|
54
54
|
"typescript": "^5.5.3",
|
55
55
|
"typescript-eslint": "^8.0.0-alpha.10"
|
@@ -5,6 +5,7 @@ type HDRHTMLCanvasOptions = { [key in HDRHTMLCanvasOptionsType]?: string };
|
|
5
5
|
|
6
6
|
interface HDRHTMLCanvasElement extends HTMLCanvasElement {
|
7
7
|
configureHighDynamicRange(options: HDRHTMLCanvasOptions): void;
|
8
|
+
_getContext(contextId: string, options?: object): RenderingContext | null;
|
8
9
|
}
|
9
10
|
|
10
11
|
interface HDRImageData {
|
package/src/hdr-canvas.ts
CHANGED
@@ -1,7 +1,30 @@
|
|
1
1
|
import {Uint16Image} from './Uint16Image'
|
2
2
|
|
3
|
+
const hdr_options = {colorSpace: Uint16Image.DEFAULT_COLORSPACE, pixelFormat: 'float16'}
|
4
|
+
|
3
5
|
export function initHDRCanvas(canvas : HDRHTMLCanvasElement) : RenderingContext | null {
|
4
6
|
canvas.configureHighDynamicRange({mode: 'extended'});
|
5
|
-
const ctx = canvas.getContext("2d",
|
7
|
+
const ctx = canvas.getContext("2d", hdr_options);
|
6
8
|
return ctx;
|
7
9
|
}
|
10
|
+
|
11
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
12
|
+
export function defaultGetContextHDR() {
|
13
|
+
(HTMLCanvasElement.prototype as HDRHTMLCanvasElement)._getContext = HTMLCanvasElement.prototype.getContext;
|
14
|
+
(HTMLCanvasElement.prototype as any).getContext = function(type: string, options: object) {
|
15
|
+
|
16
|
+
if (options !== undefined) {
|
17
|
+
options = Object.assign({}, options, hdr_options);
|
18
|
+
} else {
|
19
|
+
options = hdr_options;
|
20
|
+
}
|
21
|
+
return (this as HDRHTMLCanvasElement)._getContext(type, options);
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
26
|
+
export function resetGetContext() {
|
27
|
+
if (typeof (HTMLCanvasElement.prototype as HDRHTMLCanvasElement)._getContext === "function") {
|
28
|
+
HTMLCanvasElement.prototype.getContext = (HTMLCanvasElement.prototype as any)._getContext;
|
29
|
+
}
|
30
|
+
}
|