Skip to content

Commit

Permalink
Prepare new release
Browse files Browse the repository at this point in the history
  • Loading branch information
cmahnke committed Aug 19, 2024
1 parent 673b145 commit 5229aef
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 75 deletions.
146 changes: 73 additions & 73 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hdr-canvas",
"version": "0.0.5",
"version": "0.0.6",
"description": "HDR capable HTML canvas",
"main": "dist/hdr-canvas.js",
"files": [
Expand Down
1 change: 1 addition & 0 deletions src/@types/HDRCanvas.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type HDRHTMLCanvasOptions = { [key in HDRHTMLCanvasOptionsType]?: string };

interface HDRHTMLCanvasElement extends HTMLCanvasElement {
configureHighDynamicRange(options: HDRHTMLCanvasOptions): void;

Check warning on line 7 in src/@types/HDRCanvas.d.ts

View workflow job for this annotation

GitHub Actions / lint

'options' is defined but never used
_getContext(contextId: string, options?: object): RenderingContext | null;

Check warning on line 8 in src/@types/HDRCanvas.d.ts

View workflow job for this annotation

GitHub Actions / lint

'contextId' is defined but never used

Check warning on line 8 in src/@types/HDRCanvas.d.ts

View workflow job for this annotation

GitHub Actions / lint

'options' is defined but never used
}

interface HDRImageData {
Expand Down
25 changes: 24 additions & 1 deletion src/hdr-canvas.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
import {Uint16Image} from './Uint16Image'

const hdr_options = {colorSpace: Uint16Image.DEFAULT_COLORSPACE, pixelFormat: 'float16'}

export function initHDRCanvas(canvas : HDRHTMLCanvasElement) : RenderingContext | null {
canvas.configureHighDynamicRange({mode: 'extended'});
const ctx = canvas.getContext("2d", {colorSpace: Uint16Image.DEFAULT_COLORSPACE, pixelFormat: 'float16'});
const ctx = canvas.getContext("2d", hdr_options);
return ctx;
}

/* eslint-disable @typescript-eslint/no-explicit-any */
export function defaultGetContextHDR() {
(HTMLCanvasElement.prototype as HDRHTMLCanvasElement)._getContext = HTMLCanvasElement.prototype.getContext;
(HTMLCanvasElement.prototype as any).getContext = function(type: string, options: object) {

if (options !== undefined) {
options = Object.assign({}, options, hdr_options);
} else {
options = hdr_options;
}
return (this as HDRHTMLCanvasElement)._getContext(type, options);
}
}

/* eslint-disable @typescript-eslint/no-explicit-any */
export function resetGetContext() {
if (typeof (HTMLCanvasElement.prototype as HDRHTMLCanvasElement)._getContext === "function") {
HTMLCanvasElement.prototype.getContext = (HTMLCanvasElement.prototype as any)._getContext;
}
}

0 comments on commit 5229aef

Please sign in to comment.