Skip to content

Commit

Permalink
Updating Types (#1509)
Browse files Browse the repository at this point in the history
* Updating Types

There are two missing types that I am requesting to add. `jpg` support and on the NodeCanvasRenderingContext2D

* Update CHANGELOG.md

* fix(typings): Updating available types on construction, update addPage comments
  • Loading branch information
jpinkster authored and zbjornson committed Jan 9, 2020
1 parent 98a5141 commit c025143
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ project adheres to [Semantic Versioning](http://semver.org/).
### Added
### Fixed
* Fix BMP issues. (#1497)
* Update typings to support jpg and addPage on NodeCanvasRenderingContext2D (#1509)

2.6.1
==================
Expand Down
14 changes: 7 additions & 7 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class Canvas {
/** Constant used in PNG encoding methods. */
readonly PNG_FILTER_PAETH: number

constructor(width: number, height: number, type?: 'pdf'|'svg')
constructor(width: number, height: number, type?: 'image'|'pdf'|'svg')

getContext(contextId: '2d', contextAttributes?: NodeCanvasRenderingContext2DSettings): NodeCanvasRenderingContext2D

Expand Down Expand Up @@ -126,12 +126,6 @@ export class Canvas {
toDataURL(mimeType: 'image/jpeg', config: JpegConfig, cb: (err: Error|null, result: string) => void): void
/** _Non-standard._ */
toDataURL(mimeType: 'image/jpeg', quality: number, cb: (err: Error|null, result: string) => void): void

/**
* For PDF canvases, adds another page. If width and/or height are omitted,
* the canvas's initial size is used.
*/
addPage(width?: number, height?: number): void
}

declare class NodeCanvasRenderingContext2D extends CanvasRenderingContext2D {
Expand Down Expand Up @@ -212,6 +206,12 @@ declare class NodeCanvasRenderingContext2D extends CanvasRenderingContext2D {
createPattern(...args: any[]): NodeCanvasCanvasPattern
createLinearGradient(x0: number, y0: number, x1: number, y1: number): NodeCanvasCanvasGradient;
createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): NodeCanvasCanvasGradient;

/**
* For PDF canvases, adds another page. If width and/or height are omitted,
* the canvas's initial size is used.
*/
addPage(width?: number, height?: number): void
}
export { NodeCanvasRenderingContext2D as CanvasRenderingContext2D }

Expand Down

0 comments on commit c025143

Please sign in to comment.