@thi.ng/canvas
Advanced tools
Comparing version 0.3.0 to 0.4.0
# Change Log | ||
- **Last updated**: 2024-08-01T16:32:31Z | ||
- **Last updated**: 2024-08-01T17:11:25Z | ||
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub) | ||
@@ -12,2 +12,8 @@ | ||
## [0.4.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/canvas@0.4.0) (2024-08-01) | ||
#### 🚀 Features | ||
- add offscreenCanvas2d() & OffscreenCanvasContext ([ec59f5c](https://github.com/thi-ng/umbrella/commit/ec59f5c)) | ||
## [0.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/canvas@0.3.0) (2024-08-01) | ||
@@ -14,0 +20,0 @@ |
@@ -25,5 +25,14 @@ export interface Canvas2DOpts { | ||
export interface CanvasContext { | ||
canvas: HTMLCanvasElement | OffscreenCanvas; | ||
ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D; | ||
canvas: HTMLCanvasElement; | ||
ctx: CanvasRenderingContext2D; | ||
} | ||
export interface OffscreenCanvasContext { | ||
canvas: OffscreenCanvas; | ||
ctx: OffscreenCanvasRenderingContext2D; | ||
} | ||
export interface OffscreenCtxOpts { | ||
alpha: boolean; | ||
willReadFrequently: boolean; | ||
storage: string; | ||
} | ||
/** | ||
@@ -66,2 +75,3 @@ * Creates a canvas element of given size, obtains its 2D drawing context and | ||
export declare const pixelCanvas2d: (width: number, height?: number, parent?: HTMLElement | null, opts?: Partial<Canvas2DOpts>) => CanvasContext; | ||
export declare const offscreenCanvas2d: (width: number, height?: number, opts?: Partial<OffscreenCtxOpts>) => OffscreenCanvasContext; | ||
/** | ||
@@ -68,0 +78,0 @@ * Creates a canvas and draws given image into it. The `width` and `height` |
@@ -17,2 +17,6 @@ const adaptiveCanvas2d = (width, height = width, parent, opts = {}) => { | ||
}); | ||
const offscreenCanvas2d = (width, height = width, opts) => { | ||
const canvas = new OffscreenCanvas(width, height); | ||
return { canvas, ctx: canvas.getContext("2d", opts) }; | ||
}; | ||
const imageCanvas = (img, width = img.width, height = img.height, parent, opts) => { | ||
@@ -39,3 +43,4 @@ const res = canvas2d(width, height, parent, opts); | ||
isHighDPI, | ||
offscreenCanvas2d, | ||
pixelCanvas2d | ||
}; |
{ | ||
"name": "@thi.ng/canvas", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Canvas creation & HDPI support helpers", | ||
@@ -78,3 +78,3 @@ "type": "module", | ||
}, | ||
"gitHead": "5b6de5f99277b244646722a40ea787971c6ffd05\n" | ||
"gitHead": "74b023c95ab8219fd4192ef2a02962b2e2038563\n" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33545
158
1
40