hdr-canvas 0.0.10 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/@types/hdr-canvas.d.ts +57 -0
- package/dist/hdr-canvas.cjs +2 -2
- package/dist/hdr-canvas.cjs.map +1 -1
- package/dist/hdr-canvas.d.ts +4 -57
- package/dist/hdr-canvas.js +2 -2
- package/dist/hdr-canvas.js.map +1 -1
- package/dist/hdr-canvas.min.js.map +1 -1
- package/dist/hdr-canvas.umd.js +5978 -0
- package/dist/hdr-canvas.umd.js.map +1 -0
- package/dist/index.d.ts +57 -0
- package/package.json +23 -9
- package/src/hdr-canvas.ts +7 -8
package/dist/index.d.ts
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
import { ColorTypes } from 'colorjs.io';
|
2
|
+
|
3
|
+
// See https://github.com/microsoft/TypeScript/blob/main/src/lib/dom.generated.d.ts
|
4
|
+
/// <reference lib="dom" />
|
5
|
+
|
6
|
+
type HDRHTMLCanvasOptionsType = "mode";
|
7
|
+
type HDRHTMLCanvasOptions = { [key in HDRHTMLCanvasOptionsType]?: string };
|
8
|
+
|
9
|
+
interface HDRHTMLCanvasElement extends HTMLCanvasElement {
|
10
|
+
configureHighDynamicRange(options: HDRHTMLCanvasOptions): void;
|
11
|
+
_getContext(contextId: string, options?: object): RenderingContext | null;
|
12
|
+
}
|
13
|
+
|
14
|
+
interface HDRImageData {
|
15
|
+
readonly colorSpace: PredefinedColorSpace;
|
16
|
+
readonly data: Uint8ClampedArray | Uint16Array;
|
17
|
+
readonly height: number;
|
18
|
+
readonly width: number;
|
19
|
+
}
|
20
|
+
|
21
|
+
// See https://github.com/w3c/ColorWeb-CG/blob/main/hdr_html_canvas_element.md
|
22
|
+
// "rec2100-display-linear" is left out beacause of mapping issues
|
23
|
+
type HDRPredefinedColorSpace = "display-p3" | "srgb" | "rec2100-hlg" | "rec2100-pq";
|
24
|
+
|
25
|
+
type Uint16ImagePixelCallback = (red: number, green: number, blue: number, alpha: number) => Uint16Array;
|
26
|
+
declare class Uint16Image {
|
27
|
+
height: number;
|
28
|
+
width: number;
|
29
|
+
data: Uint16Array;
|
30
|
+
static DEFAULT_COLORSPACE: HDRPredefinedColorSpace;
|
31
|
+
static SDR_MULTIPLIER: number;
|
32
|
+
static COLORSPACES: Record<HDRPredefinedColorSpace, ColorTypes>;
|
33
|
+
colorSpace: HDRPredefinedColorSpace;
|
34
|
+
constructor(width: number, height: number, colorspace?: string);
|
35
|
+
fill(color: number[]): Uint16Image | undefined;
|
36
|
+
getPixel(w: number, h: number): Uint16Array;
|
37
|
+
setPixel(w: number, h: number, px: number[]): void;
|
38
|
+
static scaleUint8ToUint16(val: number): number;
|
39
|
+
getImageData(): ImageData | null;
|
40
|
+
static convertPixelToRec2100_hlg(pixel: Uint8ClampedArray): Uint16Array;
|
41
|
+
static convertArrayToRec2100_hlg(data: Uint8ClampedArray): Uint16Array;
|
42
|
+
pixelCallback(fn: Uint16ImagePixelCallback): void;
|
43
|
+
static loadSDRImageData(url: URL): Promise<HDRImageData | undefined>;
|
44
|
+
static fromImageData(imageData: HDRImageData): Uint16Image;
|
45
|
+
static fromURL(url: URL): Promise<Uint16Image | undefined>;
|
46
|
+
setImageData(imageData: HDRImageData): void;
|
47
|
+
clone(): Uint16Image;
|
48
|
+
}
|
49
|
+
|
50
|
+
declare function checkHDR(): boolean;
|
51
|
+
declare function checkHDRCanvas(): boolean;
|
52
|
+
|
53
|
+
declare function initHDRCanvas(canvas: HDRHTMLCanvasElement): RenderingContext | null;
|
54
|
+
declare function defaultGetContextHDR(): void;
|
55
|
+
declare function resetGetContext(): void;
|
56
|
+
|
57
|
+
export { Uint16Image, checkHDR, checkHDRCanvas, defaultGetContextHDR, initHDRCanvas, resetGetContext };
|
package/package.json
CHANGED
@@ -1,8 +1,17 @@
|
|
1
1
|
{
|
2
2
|
"name": "hdr-canvas",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.12",
|
4
4
|
"description": "HDR capable HTML canvas",
|
5
|
-
"main": "dist/hdr-canvas.
|
5
|
+
"main": "dist/hdr-canvas.cjs",
|
6
|
+
"module": "dist/hdr-canvas.js",
|
7
|
+
"type": "module",
|
8
|
+
"exports": {
|
9
|
+
".": {
|
10
|
+
"import": "./dist/hdr-canvas.js",
|
11
|
+
"require": "./dist/hdr-canvas.cjs"
|
12
|
+
},
|
13
|
+
"./three": "./three/*"
|
14
|
+
},
|
6
15
|
"files": [
|
7
16
|
"dist/hdr-canvas.d.ts",
|
8
17
|
"dist/hdr-canvas.js",
|
@@ -11,9 +20,14 @@
|
|
11
20
|
"dist/hdr-canvas.min.js.map",
|
12
21
|
"dist/hdr-canvas.cjs",
|
13
22
|
"dist/hdr-canvas.cjs.map",
|
23
|
+
"dist/hdr-canvas.umd.js",
|
24
|
+
"dist/hdr-canvas.umd.js.map",
|
25
|
+
"dist/index.d.ts",
|
26
|
+
"dist/@types",
|
14
27
|
"three",
|
15
28
|
"src"
|
16
29
|
],
|
30
|
+
"types": "dist/index.d.ts",
|
17
31
|
"scripts": {
|
18
32
|
"test": "echo \"Error: no test specified\" && exit 1",
|
19
33
|
"lint": "eslint . -c eslint.config.mjs --report-unused-disable-directives",
|
@@ -39,20 +53,20 @@
|
|
39
53
|
},
|
40
54
|
"homepage": "https://github.com/cmahnke/hdr-canvas#readme",
|
41
55
|
"devDependencies": {
|
42
|
-
"@eslint/js": "^9.
|
56
|
+
"@eslint/js": "^9.15.0",
|
43
57
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
44
58
|
"@rollup/plugin-terser": "^0.4.4",
|
45
|
-
"@rollup/plugin-typescript": "^
|
59
|
+
"@rollup/plugin-typescript": "^12.1.1",
|
46
60
|
"@types/eslint__js": "^8.42.3",
|
47
|
-
"eslint": "^9.
|
61
|
+
"eslint": "^9.15.0",
|
48
62
|
"prettier": "^3.3.3",
|
49
63
|
"rimraf": "^6.0.1",
|
50
|
-
"rollup": "^4.
|
64
|
+
"rollup": "^4.27.3",
|
51
65
|
"rollup-plugin-dts": "^6.1.1",
|
52
|
-
"three": "^0.
|
53
|
-
"tslib": "^2.8.
|
66
|
+
"three": "^0.170.0",
|
67
|
+
"tslib": "^2.8.1",
|
54
68
|
"typescript": "^5.6.3",
|
55
|
-
"typescript-eslint": "^8.
|
69
|
+
"typescript-eslint": "^8.15.0"
|
56
70
|
},
|
57
71
|
"dependencies": {
|
58
72
|
"colorjs.io": "^0.5.2"
|
package/src/hdr-canvas.ts
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
import {Uint16Image} from
|
1
|
+
import { Uint16Image } from "./Uint16Image";
|
2
2
|
|
3
|
-
import type {HDRHTMLCanvasElement} from
|
3
|
+
import type { HDRHTMLCanvasElement } from "./types/HDRCanvas.d.ts";
|
4
4
|
|
5
|
-
const hdr_options = {colorSpace: Uint16Image.DEFAULT_COLORSPACE, pixelFormat:
|
5
|
+
const hdr_options = { colorSpace: Uint16Image.DEFAULT_COLORSPACE, pixelFormat: "float16" };
|
6
6
|
|
7
|
-
export function initHDRCanvas(canvas
|
8
|
-
canvas.configureHighDynamicRange({mode:
|
7
|
+
export function initHDRCanvas(canvas: HDRHTMLCanvasElement): RenderingContext | null {
|
8
|
+
canvas.configureHighDynamicRange({ mode: "extended" });
|
9
9
|
const ctx = canvas.getContext("2d", hdr_options);
|
10
10
|
return ctx;
|
11
11
|
}
|
@@ -13,15 +13,14 @@ export function initHDRCanvas(canvas : HDRHTMLCanvasElement) : RenderingContext
|
|
13
13
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
14
14
|
export function defaultGetContextHDR() {
|
15
15
|
(HTMLCanvasElement.prototype as HDRHTMLCanvasElement)._getContext = HTMLCanvasElement.prototype.getContext;
|
16
|
-
(HTMLCanvasElement.prototype as any).getContext = function(type: string, options: object) {
|
17
|
-
|
16
|
+
(HTMLCanvasElement.prototype as any).getContext = function (type: string, options: object) {
|
18
17
|
if (options !== undefined) {
|
19
18
|
options = Object.assign({}, options, hdr_options);
|
20
19
|
} else {
|
21
20
|
options = hdr_options;
|
22
21
|
}
|
23
22
|
return (this as HDRHTMLCanvasElement)._getContext(type, options);
|
24
|
-
}
|
23
|
+
};
|
25
24
|
}
|
26
25
|
|
27
26
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|