mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-03-29 17:08:21 +08:00
Updated signature_pad.d.ts file
This commit is contained in:
138
signature_pad/signature_pad.d.ts
vendored
138
signature_pad/signature_pad.d.ts
vendored
@@ -4,71 +4,73 @@
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
// Project by: Szymon Nowak <https://github.com/szimek>
|
||||
|
||||
declare class Point {
|
||||
x: number;
|
||||
y: number;
|
||||
time: number;
|
||||
constructor(x: number, y: number, time: number);
|
||||
velocityFrom(start: Point): number;
|
||||
distanceTo(start: Point): number;
|
||||
}
|
||||
declare module SignaturePad {
|
||||
class Point {
|
||||
x: number;
|
||||
y: number;
|
||||
time: number;
|
||||
constructor(x: number, y: number, time: number);
|
||||
velocityFrom(start: Point): number;
|
||||
distanceTo(start: Point): number;
|
||||
}
|
||||
|
||||
declare class CurveControl {
|
||||
c1: Point;
|
||||
c2: Point;
|
||||
constructor(c1: Point, c2: Point);
|
||||
}
|
||||
class CurveControl {
|
||||
c1: Point;
|
||||
c2: Point;
|
||||
constructor(c1: Point, c2: Point);
|
||||
}
|
||||
|
||||
declare class Bezier {
|
||||
startPoint: Point;
|
||||
control1: CurveControl;
|
||||
control2: CurveControl;
|
||||
endPoint: Point;
|
||||
constructor(startPoint, control1, control2, endPoint);
|
||||
length(): number;
|
||||
_point(t: number, start: number, c1: number, c2: number, end: number): number;
|
||||
}
|
||||
class Bezier {
|
||||
startPoint: Point;
|
||||
control1: CurveControl;
|
||||
control2: CurveControl;
|
||||
endPoint: Point;
|
||||
constructor(startPoint: Point, control1: Point, control2: Point, endPoint: Point);
|
||||
length(): number;
|
||||
_point(t: number, start: number, c1: number, c2: number, end: number): number;
|
||||
}
|
||||
|
||||
declare class SignaturePadOptions {
|
||||
/**
|
||||
* (float) Weight used to modify new velocity based on the previous velocity. Defaults to 0.7.
|
||||
*/
|
||||
velocityFilterWeight: 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;
|
||||
/**
|
||||
* (float or function) Radius of a single dot.
|
||||
*/
|
||||
dotSize: Function;
|
||||
/**
|
||||
* (string) Color used to draw the lines. Can be any color format accepted by context.fillStyle.
|
||||
* Defaults to "black".
|
||||
*/
|
||||
penColor: string;
|
||||
/**
|
||||
* (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;
|
||||
/**
|
||||
* (function) Callback when stroke begin.
|
||||
*/
|
||||
onEnd: Function;
|
||||
/**
|
||||
* (function) Callback when stroke end.
|
||||
*/
|
||||
onBegin: Function;
|
||||
interface SignaturePadOptions {
|
||||
/**
|
||||
* (float) Weight used to modify new velocity based on the previous velocity. Defaults to 0.7.
|
||||
*/
|
||||
velocityFilterWeight?: 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;
|
||||
/**
|
||||
* (float or function) Radius of a single dot.
|
||||
*/
|
||||
dotSize?: Function;
|
||||
/**
|
||||
* (string) Color used to draw the lines. Can be any color format accepted by context.fillStyle.
|
||||
* Defaults to "black".
|
||||
*/
|
||||
penColor?: string;
|
||||
/**
|
||||
* (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;
|
||||
/**
|
||||
* (function) Callback when stroke begin.
|
||||
*/
|
||||
onEnd?: Function;
|
||||
/**
|
||||
* (function) Callback when stroke end.
|
||||
*/
|
||||
onBegin?: Function;
|
||||
}
|
||||
}
|
||||
|
||||
declare class SignaturePad {
|
||||
points: Array<Point>;
|
||||
points: Array<SignaturePad.Point>;
|
||||
_lastVelocity: number;
|
||||
_lastWidth: number;
|
||||
_isEmpty: boolean;
|
||||
@@ -84,7 +86,7 @@ declare class SignaturePad {
|
||||
onEnd: Function;
|
||||
onBegin: Function;
|
||||
|
||||
constructor(canvas: Element, options?: SignaturePadOptions);
|
||||
constructor(canvas: Element, options?: SignaturePad.SignaturePadOptions);
|
||||
/**
|
||||
* Clears the canvas
|
||||
*/
|
||||
@@ -96,7 +98,7 @@ declare class SignaturePad {
|
||||
/**
|
||||
* Draws signature image from data URL
|
||||
*/
|
||||
fromDataURL(dataUrl: string);
|
||||
fromDataURL(dataUrl: string): void;
|
||||
/**
|
||||
* Returns signature image as data URL
|
||||
*/
|
||||
@@ -104,17 +106,17 @@ declare class SignaturePad {
|
||||
|
||||
_strokeBegin(event: Event): void;
|
||||
_strokeUpdate(event: Event): void;
|
||||
_strokeDraw(point: Point): void;
|
||||
_strokeDraw(point: SignaturePad.Point): void;
|
||||
_strokeEnd(event: Event): void;
|
||||
_handleMouseEvents(): void;
|
||||
_handleTouchEvents(): void;
|
||||
_reset(): void;
|
||||
_createPoint(event: Event): Point;
|
||||
_addPoint(point: Point): void;
|
||||
_calculateCurveControlPoints(point1: Point, point2: Point, point3: Point): void;
|
||||
_createPoint(event: Event): SignaturePad.Point;
|
||||
_addPoint(point: SignaturePad.Point): void;
|
||||
_calculateCurveControlPoints(point1: SignaturePad.Point, point2: SignaturePad.Point, point3: SignaturePad.Point): void;
|
||||
|
||||
_addCurve(curve: Bezier): void;
|
||||
_addCurve(curve: SignaturePad.Bezier): void;
|
||||
_drawPoint(x: number, y: number, size: number): void;
|
||||
_drawCurve(curve: Bezier, startWidth: number, endWidth: number): void;
|
||||
_drawCurve(curve: SignaturePad.Bezier, startWidth: number, endWidth: number): void;
|
||||
_strokeWidth(velocity: number): void;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user