Skip to content

Commit 5229aef

Browse files
committed
Prepare new release
1 parent 673b145 commit 5229aef

File tree

4 files changed

+99
-75
lines changed

4 files changed

+99
-75
lines changed

package-lock.json

Lines changed: 73 additions & 73 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hdr-canvas",
3-
"version": "0.0.5",
3+
"version": "0.0.6",
44
"description": "HDR capable HTML canvas",
55
"main": "dist/hdr-canvas.js",
66
"files": [

src/@types/HDRCanvas.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ type HDRHTMLCanvasOptions = { [key in HDRHTMLCanvasOptionsType]?: string };
55

66
interface HDRHTMLCanvasElement extends HTMLCanvasElement {
77
configureHighDynamicRange(options: HDRHTMLCanvasOptions): void;
8+
_getContext(contextId: string, options?: object): RenderingContext | null;
89
}
910

1011
interface HDRImageData {

src/hdr-canvas.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,30 @@
11
import {Uint16Image} from './Uint16Image'
22

3+
const hdr_options = {colorSpace: Uint16Image.DEFAULT_COLORSPACE, pixelFormat: 'float16'}
4+
35
export function initHDRCanvas(canvas : HDRHTMLCanvasElement) : RenderingContext | null {
46
canvas.configureHighDynamicRange({mode: 'extended'});
5-
const ctx = canvas.getContext("2d", {colorSpace: Uint16Image.DEFAULT_COLORSPACE, pixelFormat: 'float16'});
7+
const ctx = canvas.getContext("2d", hdr_options);
68
return ctx;
79
}
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+
}

0 commit comments

Comments
 (0)