diff --git a/types/signature_pad/index.d.ts b/types/signature_pad/index.d.ts index 6dd86fb20e..cd0a96b7ec 100644 --- a/types/signature_pad/index.d.ts +++ b/types/signature_pad/index.d.ts @@ -7,6 +7,95 @@ // Project by: Szymon Nowak // TypeScript Version: 2.8 +declare namespace SignaturePad { + class Point { + x: number; + y: number; + time: number; + color?: string; + + constructor(x: number, y: number, time: number); + + velocityFrom(start: Point): number; + + distanceTo(start: Point): number; + } + + class CurveControl { + c1: Point; + c2: Point; + + constructor(c1: Point, c2: Point); + } + + class Bezier { + startPoint: Point; + control1: CurveControl; + control2: CurveControl; + endPoint: Point; + startWidth: number; + endWidth: number; + + constructor(startPoint: Point, control1: Point, control2: Point, endPoint: Point); + + length(): number; + + _point(t: number, start: number, c1: number, c2: number, end: number): number; + } + + interface SignaturePadOptions { + /* + * (float or function) Radius of a single dot. + */ + dotSize?: number | (() => number) + + /* + * (float) Minimum width of a line. Defaults to 0.5. + */ + minWidth?: number + + /* + * (float) Maximum width of a line. Defaults to 2.5. + */ + maxWidth?: number + + /* + * (integer) Draw the next point at most once per every x milliseconds. Set it to 0 to turn off throttling. Defaults to 16. + */ + throttle?: number + + /* + * (integer) Add the next point only if the previous one is farther than x pixels. Defaults to 5. + */ + minDistance?: number + + /* + * (string) Color used to clear the background. Can be any color format accepted by context.fillStyle. Defaults to "rgba(0,0,0,0)" (transparent black). Use a non-transparent color e.g. "rgb(255,255,255)" (opaque white) if you'd like to save signatures as JPEG images. + */ + backgroundColor?: string + + /* + * (string) Color used to draw the lines. Can be any color format accepted by context.fillStyle. Defaults to "black". + */ + penColor?: string + + /* + * (float) Weight used to modify new velocity based on the previous velocity. Defaults to 0.7. + */ + velocityFilterWeight?: number + + /* + * (function) Callback when stroke begin. + */ + onBegin?: (event: MouseEvent) => void + + /* + * (function) Callback when stroke end. + */ + onEnd?: (event: MouseEvent) => void + } +} + declare class SignaturePad { backgroundColor: string; canvas: HTMLCanvasElement; @@ -98,95 +187,6 @@ declare class SignaturePad { constructor(canvas: HTMLCanvasElement, options?: SignaturePad.SignaturePadOptions); } -declare namespace SignaturePad { - class Point { - x: number; - y: number; - time: number; - color?: string; - - constructor(x: number, y: number, time: number); - - velocityFrom(start: Point): number; - - distanceTo(start: Point): number; - } - - class CurveControl { - c1: Point; - c2: Point; - - constructor(c1: Point, c2: Point); - } - - class Bezier { - startPoint: Point; - control1: CurveControl; - control2: CurveControl; - endPoint: Point; - startWidth: number; - endWidth: number; - - constructor(startPoint: Point, control1: Point, control2: Point, endPoint: Point); - - length(): number; - - _point(t: number, start: number, c1: number, c2: number, end: number): number; - } - - interface SignaturePadOptions { - /* - * (float or function) Radius of a single dot. - */ - dotSize?: number | (() => number) - - /* - * (float) Minimum width of a line. Defaults to 0.5. - */ - minWidth?: number - - /* - * (float) Maximum width of a line. Defaults to 2.5. - */ - maxWidth?: number - - /* - * (integer) Draw the next point at most once per every x milliseconds. Set it to 0 to turn off throttling. Defaults to 16. - */ - throttle?: number - - /* - * (integer) Add the next point only if the previous one is farther than x pixels. Defaults to 5. - */ - minDistance?: number - - /* - * (string) Color used to clear the background. Can be any color format accepted by context.fillStyle. Defaults to "rgba(0,0,0,0)" (transparent black). Use a non-transparent color e.g. "rgb(255,255,255)" (opaque white) if you'd like to save signatures as JPEG images. - */ - backgroundColor?: string - - /* - * (string) Color used to draw the lines. Can be any color format accepted by context.fillStyle. Defaults to "black". - */ - penColor?: string - - /* - * (float) Weight used to modify new velocity based on the previous velocity. Defaults to 0.7. - */ - velocityFilterWeight?: number - - /* - * (function) Callback when stroke begin. - */ - onBegin?: (event: MouseEvent) => void - - /* - * (function) Callback when stroke end. - */ - onEnd?: (event: MouseEvent) => void - } -} - export default SignaturePad; export as namespace SignaturePad;