diff options
author | kabentley <33296803+kabentley@users.noreply.github.com> | 2019-02-11 15:32:08 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-11 15:32:08 -0500 |
commit | 3a13639fcb79e2a425a2327c249bfcf96ba3dff1 (patch) | |
tree | 1dc182b49a9557bf5d029ddcb242117b4ea6be8a | |
parent | ecd4d0d1ca82bbaa3a3990feac3eabaeb9e6fd43 (diff) | |
parent | 4f638ff57f2775d282ef46345d6eb19e13dfd7a3 (diff) | |
download | svg.js-3a13639fcb79e2a425a2327c249bfcf96ba3dff1.tar.gz svg.js-3a13639fcb79e2a425a2327c249bfcf96ba3dff1.zip |
Merge pull request #1 from svgdotjs/master
sync
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | svg.js.d.ts | 841 |
2 files changed, 319 insertions, 524 deletions
diff --git a/package.json b/package.json index 7f25d33..b4bd2f1 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "main": "dist/svg.node.js", "unpkg": "dist/svg.min.js", "jsdelivr": "dist/svg.min.js", - "browser": "dist/svg.min.js", + "browser": "src/main.js", "module": "src/main.js", "maintainers": [ { diff --git a/svg.js.d.ts b/svg.js.d.ts index 05206b3..96df068 100644 --- a/svg.js.d.ts +++ b/svg.js.d.ts @@ -1,52 +1,93 @@ -export = svgjs;
-export as namespace svgjs;
-
-declare var svgjs: svgjs.Library;
-
-// todo add SVG.FX
-declare namespace svgjs {
- export interface Library {
- (id: string): Doc;
- (domElement: HTMLElement): Doc;
- ns: string;
- xmlns: string;
- xlink: string;
- svgjs: string;
- supported: boolean;
-
- did: number;
- eid(name: string): string;
-
- create(name: string): any;
- extend(parent: Object, obj: Object): void;
- invent(config: Object): any;
- adopt(node: HTMLElement): Element;
- prepare(element: HTMLElement): void;
+declare module "@svgdotjs/svg.js" {
+
+ function SVG(): Svg;
+ function SVG(id: string): Svg;
+ function SVG(domElement: HTMLElement): Svg;
+
+ let ns: string;
+ let xmlns: string;
+ let xlink: string;
+ let svgjs: string;
+
+ let did: number;
+ function eid(name: string): string;
+ function get(id: string): Element;
+
+ function create(name: string): any;
+ function extend(parent: Object, obj: Object): void;
+ function invent(config: Object): any;
+ function adopt(node: HTMLElement): Element;
+ function prepare(element: HTMLElement): void;
+ let utils: {
+ map(array: any[], block: Function): any;
+ filter(array: any[], block: Function): any;
+ radians(d: number): number;
+ degrees(r: number): number;
+ filterSVGElements: HTMLElement[]
+ }
+ let defaults: {
+ attrs: {
+ 'fill-opacity': number;
+ 'stroke-opacity': number;
+ 'stroke-width': number;
+ 'stroke-linejoin': string;
+ 'stroke-linecap': string;
+ 'fill': string;
+ 'stroke': string;
+ 'opacity': number;
+ 'x': number;
+ 'y': number;
+ 'cx': number;
+ 'cy': number;
+ 'width': number;
+ 'height': number;
+ 'r': number;
+ 'rx': number;
+ 'ry': number;
+ 'offset': number;
+ 'stop-opacity': number;
+ 'stop-color': string;
+ 'font-size': number;
+ 'font-family': string;
+ 'text-anchor': string;
+ }
}
- interface LinkedHTMLElement extends HTMLElement {
- instance: Element;
+ let easing: {
+ '-'(pos: number): number;
+ '<>'(pos: number): number;
+ '>'(pos: number): number;
+ '<'(pos: number): number;
+ }
+ let regex: {
+ numberAndUnit: RegExp;
+ hex: RegExp;
+ rgb: RegExp;
+ reference: RegExp;
+ transforms: RegExp;
+ whitespace: RegExp;
+ isHex: RegExp;
+ isRgb: RegExp;
+ isCss: RegExp;
+ isBlank: RegExp;
+ isNumber: RegExp;
+ isPercent: RegExp;
+ isImage: RegExp;
+ delimiter: RegExp;
+ hyphen: RegExp;
+ pathLetters: RegExp;
+ isPathLetter: RegExp;
+ dots: RegExp;
}
- // arrange.js
- interface Element {
- front(): this;
- back(): this;
- forward(): this;
- backward(): this;
-
- siblings(): Element[];
- position(): number;
- next(): Element;
- previous(): Element;
- before(element: Element): Element;
- after(element: Element): Element;
+ interface LinkedHTMLElement extends HTMLElement {
+ instance: Element;
}
// array.js
type ArrayAlias = _Array | number[] | string;
- interface _Array {
- new (array?: ArrayAlias, fallback?: number[]): _Array;
+ class _Array {
+ constructor(array?: ArrayAlias, fallback?: number[]): _Array;
value: number[];
morph(array: number[]): this;
settle(): number[];
@@ -54,29 +95,28 @@ declare namespace svgjs { toString(): string;
valueOf(): number[];
parse(array: ArrayAlias): number[];
- split(string: string): number[];
reverse(): this;
clone(): _Array;
}
- interface Library { Array: _Array }
-
- // attr.js
- interface Element {
- attr(): object;
- attr(name: string): any;
- attr(obj: Object): this;
- attr(name: string, value: any, namespace?: string): this;
- }
- // bare.js
- export interface Bare extends Element {
- new (element: string, inherit?: any): Bare;
+ class Dom {
+ constructor(element: string, inherit?: any): Dom;
words(text: string): this;
+ element(element: string, inherit?: Object): Dom;
+ addTo(parent: Dom): this;
+ putIn(parent: Dom): Dom;
+ children(): Element[];
+ add(element: Element, i?: number): Element;
+ put(element: Element, i?: number): Element;
+ has(element: Element): boolean;
+ index(element: Element): number;
+ get(i: number): Element;
+ first(): Element;
+ last(): Element;
+ each(block: (index: number, children: Element[]) => void, deep?: boolean): this;
+ removeElement(element: Element): this;
+ clear(): this;
}
- interface Parent {
- element(element: string, inherit?: Object): Bare;
- }
- interface Library { Bare: Bare; }
// boxes.js
interface Box {
@@ -94,41 +134,25 @@ declare namespace svgjs { transform(m: Matrix): Box
}
- export interface BBox extends Box {
- new (element?: Element): BBox;
+ class BBox extends Box {
+ constructor(element?: Element): BBox;
}
- export interface RBox extends Box {
- new (element?: Element): RBox;
+ class RBox extends Box {
+ constructor(element?: Element): RBox;
}
- export interface TBox extends Box {
- new (element?: Element): TBox;
- }
- interface Element {
- bbox(): BBox;
- rbox(element?: Element): RBox;
- tbox(): TBox;
- }
- interface Library {
- BBox: BBox;
- RBox: RBox;
- TBox: TBox;
+ class TBox extends Box {
+ constructor(element?: Element): TBox;
}
// clip.js
- export interface ClipPath extends Container {
- new (): ClipPath;
+ class ClipPath extends Container {
+ constructor(): ClipPath;
targets: Element[];
remove(): this;
}
interface Container {
clip(): ClipPath;
}
- interface Element {
- clipWith(element: Element): this;
- clipper: ClipPath;
- unclip(): this;
- }
- interface Library { ClipPath: ClipPath; }
// color.js
interface ColorLike {
@@ -139,9 +163,9 @@ declare namespace svgjs { type ColorAlias = string | ColorLike;
- export interface Color extends ColorLike{
- new (): Color;
- new (color: ColorAlias): Color;
+ class Color extends ColorLike {
+ constructor(): Color;
+ constructor(color: ColorAlias): Color;
toString(): string;
toHex(): string;
@@ -150,145 +174,173 @@ declare namespace svgjs { morph(color: ColorAlias): Color;
at(pos: number): Color;
}
- interface Library { Color: Color; }
// container.js
interface ViewBoxLike {
x: number;
y: number;
width: number;
- height:number;
- }
-
- export interface Container extends Parent {
- new (): Container;
+ height: number;
}
- interface Library { Container: Container }
- // data.js
- interface Element {
- data(name: string): any;
- data(name: string, value: any, sustain?: boolean): this;
- }
+ class Container extends Element { }
- // default.js
- interface Library {
- defaults: {
- attrs: {
- 'fill-opacity': number;
- 'stroke-opacity': number;
- 'stroke-width': number;
- 'stroke-linejoin': string;
- 'stroke-linecap': string;
- 'fill': string;
- 'stroke': string;
- 'opacity': number;
- 'x': number;
- 'y': number;
- 'cx': number;
- 'cy': number;
- 'width': number;
- 'height': number;
- 'r': number;
- 'rx': number;
- 'ry': number;
- 'offset': number;
- 'stop-opacity': number;
- 'stop-color': string;
- 'font-size': number;
- 'font-family': string;
- 'text-anchor': string;
- }
- }
- }
-
- // defs.js
- export interface Defs extends Container {
- new (): Defs;
- }
- interface Library { Defs: Defs }
+ class Defs extends Container { }
- // doc.js
- export interface Doc extends Container {
- new (): Doc;
- new (id: string): Doc;
- new (domElement: HTMLElement): Doc;
+ class Svg extends Container {
+ constructor(): Svg;
+ constructor(id: string): Svg;
+ constructor(domElement: HTMLElement): Doc;
namespace(): this;
defs(): Defs;
parent(): HTMLElement;
spof(): this;
remove(): this;
+ isRoot(): boolean;
}
- interface Library { Doc: Doc; }
- type ParentTypeAlias = string | Doc | Nested | G;
- // element.js
- export interface Element {
- new (): Element;
+ type ParentTypeAlias = string | Svg | G;
+ class Element extends Dom {
node: LinkedHTMLElement;
type: string;
- x(x: NumberAlias): this;
- x(): number;
- y(y: NumberAlias): this;
- y(): number;
- //cx(x: number, anchor?: boolean): this;
- cx(x: number): this;
+ addClass(name: string): this;
+ after(element: Element): Element;
+ animate(duration?: number, ease?: string, delay?: number): Animation;
+ animate(info: { ease?: string; duration?: number; delay?: number }): Animation;
+ attr(): object;
+ attr(name: string, value: any, namespace?: string): this;
+ attr(name: string): any;
+ attr(obj: Object): this;
+ attr(obj: Object[]): Object;
+ back(): this;
+ backward(): this;
+ bbox(): BBox;
+ before(element: Element): Element;
+ center(x: number, y: number): this;
+ classes(): string[];
+ click(cb: Function): this;
+ clipper: ClipPath;
+ clipWith(element: Element): this;
+ clone(): this;
+ css(): Object;
+ css(style: Object[]): Object;
+ css(style: string, value: any): this;
+ css(style: string): any;
+ css(styles: Object): this;
+ ctm(): Matrix;
cx(): number;
- //cy(y: number, anchor?: boolean): this;
- cy(y: number): this;
+ cx(x: number): this;
cy(): number;
- move(x: NumberAlias, y: NumberAlias): this;
- center(x: number, y: number): this;
-
- width(width: NumberAlias): this;
- width(): number;
- height(height: NumberAlias): this;
+ cy(y: number): this;
+ data(name: string, value: any, sustain?: boolean): this;
+ data(name: string): any;
+ dblclick(cb: Function): this;
+ defs(): Defs;
+ dmove(x: NumberAlias, y: NumberAlias): this;
+ dx(x: NumberAlias): this;
+ dy(y: NumberAlias): this;
+ event(): Event | CustomEvent;
+ fill(color: string): this;
+ fill(fill: { color?: string; opacity?: number, rule?: string }): this;
+ fill(image: Image): this;
+ fill(pattern: Element): this;
+ fire(event: Event): this;
+ fire(event: string, data?: any): this;
+ flip(a: string, offset?: number): this;
+ flip(offset?: number): this;
+ forget(...keys: string[]): this;
+ forget(): this;
+ forward(): this;
+ front(): this;
+ hasClass(name: string): boolean;
height(): number;
- size(width?: NumberAlias, height?: NumberAlias): this;
-
- clone(): Element;
- remove(): this;
- replace(element: Element): Element;
-
- addTo(parent: Parent): this;
- putIn(parent: Parent): Parent;
-
+ height(height: NumberAlias): this;
+ hide(): this;
+ hide(): this;
id(): string;
id(id: string): this;
-
inside(x: number, y: number): boolean;
-
- show(): this;
- hide(): this;
- visible(): boolean;
-
- toString(): string;
-
- classes(): string[];
- hasClass(name: string): boolean;
- addClass(name: string): this;
- removeClass(name: string): this;
- toggleClass(name: string): this;
-
- reference(type: string): Element;
- // Add HTMLElement for Doc inheritance
- parent(type?: ParentTypeAlias): Parent | HTMLElement;
- doc(): Parent;
- parents(): Parent[];
-
+ is(cls: any): boolean;
+ linkTo(url: (link: A) => void): A;
+ linkTo(url: string): A;
+ masker: Mask;
+ maskWith(element: Element): this;
+ maskWith(mask: Mask): this;
matches(selector: string): boolean;
+ matrix(a: number, b: number, c: number, d: number, e: number, f: number): this;
+ matrix(m: MatrixAlias): this;
+ matrixify(): Matrix;
+ memory(): Object;
+ mousedown(cb: Function): this;
+ mousemove(cb: Function): this;
+ mouseout(cb: Function): this;
+ mouseover(cb: Function): this;
+ mouseup(cb: Function): this;
+ move(x: NumberAlias, y: NumberAlias): this;
native(): LinkedHTMLElement;
-
- svg(svg: string): this;
+ next(): Element;
+ off(event: string, cb?: Function, context?: Object): this;
+ on(event: string, cb: Function, context?: Object): this;
+ opacity(): number;
+ opacity(o: number): this;
+ parent(type?: ParentTypeAlias): Dom | HTMLElement;
+ parents(): Dom[];
+ point(): Point;
+ point(position: { x: number, y: number }): Point;
+ point(position: ArrayPoint): Point;
+ point(x: number, y: number): Point;
+ position(): number;
+ prev(): Element;
+ rbox(element?: Element): RBox;
+ reference(type: string): Element;
+ remember(name: string, value: any): this;
+ remember(name: string): any;
+ remember(obj: Object): this;
+ remove(): this;
+ removeClass(name: string): this;
+ replace(element: Element): Element;
+ root(): Svg;
+ rotate(d: number, cx?: number, cy?: number): this;
+ scale(x: number, y?: number, cx?: number, cy?: number): this;
+ screenCTM(): Matrix;
+ setData(data: object): this;
+ show(): this;
+ show(): this;
+ siblings(): Element[];
+ size(width?: NumberAlias, height?: NumberAlias): this;
+ skew(x: number, y?: number, cx?: number, cy?: number): this;
+ stop(jumpToEnd: boolean, clearQueue: boolean): Animation;
+ stroke(color: string): this;
+ stroke(stroke: StrokeData): this;
svg(): string;
-
+ svg(svg: string): this;
+ tbox(): TBox;
+ toggleClass(name: string): this;
+ toParent(parent: Dom): this;
+ toString(): string;
+ toSvg(): this;
+ touchcancel(cb: Function): this;
+ touchend(cb: Function): this;
+ touchleave(cb: Function): this;
+ touchmove(cb: Function): this;
+ touchstart(cb: Function): this;
+ transform(): Transform;
+ transform(t: Transform, relative?: boolean): Element;
+ translate(x: number, y: number): this;
+ unclip(): this;
+ unmask(): this;
+ untransform(): this;
+ visible(): boolean;
+ visible(): boolean;
+ width(): number;
+ width(width: NumberAlias): this;
writeDataToDom(): this;
- setData(data: object): this;
-
- is(cls: any): boolean;
+ x(): number;
+ x(x: NumberAlias): this;
+ y(): number;
+ y(y: NumberAlias): this;
}
- interface Library { Element: Element; }
// ellipse.js
interface CircleMethods extends Shape {
@@ -296,60 +348,15 @@ declare namespace svgjs { rx(): this;
ry(ry: number): this;
ry(): this;
-
radius(x: number, y?: number): this;
}
- export interface Circle extends CircleMethods {
- new (): Circle;
- }
- export interface Ellipse extends CircleMethods {
- new (): Ellipse;
- }
+ class Circle extends CircleMethods { }
+ class Ellipse extends CircleMethods { }
interface Container {
circle(size?: number): Circle;
ellipse(width?: number, height?: number): Ellipse;
}
- interface Library {
- Circle: Circle;
- Ellipse: Ellipse;
- }
- // event.js
- interface Element {
- on(event: string, cb: Function, context?: Object): this;
- off(event: string, cb?: Function, context?: Object): this;
- fire(event: string, data?: any): this;
- fire(event: Event): this;
- event(): Event | CustomEvent;
-
- click(cb: Function): this;
- dblclick(cb: Function): this;
- mousedown(cb: Function): this;
- mouseup(cb: Function): this;
- mouseover(cb: Function): this;
- mouseout(cb: Function): this;
- mousemove(cb: Function): this;
- touchstart(cb: Function): this;
- touchmove(cb: Function): this;
- touchleave(cb: Function): this;
- touchend(cb: Function): this;
- touchcancel(cb: Function): this;
- }
-
- //fx.js
- interface Library {
- easing: {
- '-'(pos: number): number;
- '<>'(pos: number): number;
- '>'(pos: number): number;
- '<'(pos: number): number;
- }
- }
- interface Element {
- animate(duration?: number, ease?: string, delay?: number): Animation;
- animate(info: { ease?: string; duration?: number; delay?: number }): Animation;
- stop(jumpToEnd:boolean,clearQueue:boolean): Animation;
- }
// TODO finishs FX
interface StopProperties {
color?: ColorAlias;
@@ -358,18 +365,17 @@ declare namespace svgjs { }
// gradient.js
- export interface Stop extends Element {
- new (): Stop;
+ class Stop extends Element {
update(offset?: number, color?: ColorAlias, opacity?: number): this;
update(opts: StopProperties): this;
}
- export interface Gradient extends Container {
- new (type: string): Gradient;
+ class Gradient extends Container {
+ constructor(type: string): Gradient;
at(offset?: number, color?: ColorAlias, opacity?: number): Stop;
at(opts: StopProperties): Stop;
update(block?: Function): this;
- fill(): string;
- fill(...params: any[]): never;
+ url(): string;
+ url(...params: any[]): never;
toString(): string;
from(x: number, y: number): this;
to(x: number, y: number): this;
@@ -378,59 +384,39 @@ declare namespace svgjs { interface Container {
gradient(type: string, block?: (stop: Gradient) => void): Gradient;
}
- interface Library {
- Gradient: Gradient;
- Stop: Stop;
- }
// group.js
- export interface G extends Container {
- new (): G;
+ class G extends Container {
gbox(): BBox;
}
interface Container { group(): G; }
- interface Library { G: G; }
// hyperlink.js
- export interface A extends Container {
- new (): A;
+ class A extends Container {
to(url: string): this;
to(): string;
- show(target: string): this;
- show(): string;
- show(...params: any[]): never;
target(target: string): this;
target(): string;
}
interface Container {
link(url: string): A;
}
- interface Element {
- linkTo(url: string): A;
- linkTo(url: (link: A) => void): A;
- }
- interface Library { A: A; }
// image.js
- export interface Image extends Shape {
- new (): Image;
+ class Image extends Shape {
load(url?: string): this;
- loaded(cb: (info: { width: number, height: number, ratio: number, url: string }) => void): this;
- error(cb: (event: Event) => void): this;
}
interface Container {
image(): Image;
image(href: string, size?: number): Image;
image(href: string, width?: number, height?: number): Image;
}
- interface Library { Image: Image; }
// line.js
interface ArrayPoint extends Array<number> { }
type PointArrayAlias = ArrayPoint[] | number[] | PointArray | string;
- export interface Line extends Shape {
- new (): Line;
+ class Line extends Shape {
array(): PointArray;
plot(points: PointArrayAlias): this;
plot(x1: number, y1: number, x2: number, y2: number): this;
@@ -441,11 +427,9 @@ declare namespace svgjs { line(points: PointArrayAlias): Line;
line(x1: number, y1: number, x2: number, y2: number): Line;
}
- interface Library { Line: Line; }
// marker.js
- export interface Marker extends Container {
- new (): Marker;
+ class Marker extends Container {
ref(x: string | number, y: string | number): this;
update(block: (marker: Marker) => void): this;
toString(): string;
@@ -472,23 +456,12 @@ declare namespace svgjs { marker(position: string, width?: number, height?: number, block?: (marker: Marker) => void): Marker;
marker(position: string, marker: Marker): Marker;
}
- interface Library {
- Marker: Marker;
- }
// mask.js
- export interface Mask extends Container {
- new (): Mask;
+ class Mask extends Container {
targets: Element[];
}
interface Container { mask(): Mask; }
- interface Element {
- maskWith(mask: Mask): this;
- maskWith(element: Element): this;
- masker: Mask;
- unmask(): this;
- }
- interface Library { Mask: Mask; }
// matrix.js
interface MatrixExtract {
@@ -521,10 +494,10 @@ declare namespace svgjs { type MatrixAlias = MatrixLike | number[] | Element | string;
- export interface Matrix {
- new (): Matrix;
- new (source: MatrixAlias): Matrix;
- new (a: number, b: number, c: number, d: number, e: number, f: number): Matrix;
+ class Matrix {
+ constructor();
+ constructor(source: MatrixAlias): Matrix;
+ constructor(a: number, b: number, c: number, d: number, e: number, f: number): Matrix;
a: number;
b: number;
c: number;
@@ -549,35 +522,13 @@ declare namespace svgjs { native(): SVGMatrix;
toString(): string;
}
- interface Element {
- ctm(): Matrix;
- screenCTM(): Matrix;
- }
- interface Library { Matrix: Matrix }
-
- // memory.js
- interface Element {
- remember(name: string, value: any): this;
- remember(name: string): any;
- remember(obj: Object): this;
- forget(...keys: string[]): this;
- forget(): this;
- memory(): Object;
- }
-
- // nested.js
- export interface Nested extends Container {
- new (): Nested;
- }
- interface Container { nested(): Nested; }
- interface Library { Nested: Nested; }
// number.js
- interface _Number {
- new (): _Number;
- new (value: _Number): _Number;
- new (value: string): _Number;
- new (value: number, unit?: any): _Number;
+ class _Number {
+ constructor(): _Number;
+ constructor(value: _Number): _Number;
+ constructor(value: string): _Number;
+ constructor(value: number, unit?: any): _Number;
toString(): string;
toJSON(): Object;
valueOf(): number;
@@ -589,34 +540,14 @@ declare namespace svgjs { morph(number: any): this;
at(pos: number): _Number;
}
- interface Library { Number: _Number; }
type NumberAlias = _Number | number | string;
- // parent.js
- export interface Parent extends Element {
- new (): Parent;
- children(): Element[];
- add(element: Element, i?: number): this;
- put(element: Element, i?: number): Element;
- has(element: Element): boolean;
- index(element: Element): number;
- get(i: number): Element;
- first(): Element;
- last(): Element;
- each(block: (index: number, children: Element[]) => void, deep?: boolean): this;
- removeElement(element: Element): this;
- clear(): this;
- defs(): Defs;
- }
- interface Library{ Parent: Parent }
-
// path.js
interface PathArrayPoint extends Array<number | string> { }
type PathArrayAlias = PathArray | (string | number)[] | PathArrayPoint[] | string;
- export interface Path extends Shape {
- new (): Path;
+ class Path extends Shape {
morphArray: PathArray;
array(): PathArray;
plot(d: PathArrayAlias): this;
@@ -625,41 +556,37 @@ declare namespace svgjs { path(): Path;
path(d: PathArrayAlias): Path;
}
- interface Library{ Path: Path }
// pathArray.js
- export interface PathArray extends _Array {
- new (): PathArray;
- new (d: PathArrayAlias): PathArray;
+ class PathArray extends _Array {
+ constructor();
+ constructor(d: PathArrayAlias): PathArray;
move(x: number, y: number): this;
size(width?: number, height?: number): this;
parse(array: PathArrayAlias): PathArrayPoint[];
parse(array: ArrayAlias): never;
bbox(): BBox;
}
- interface Library { PathArray: PathArray; }
// pattern.js
- export interface Pattern extends Container {
- new (): Pattern;
- fill(): string;
- fill(...rest: any[]): never;
+ class Pattern extends Container {
+ url(): string;
+ url(...rest: any[]): never;
update(block: (pattern: Pattern) => void): this;
toString(): string;
}
interface Container {
pattern(width?: number, height?: number, block?: (pattern: Pattern) => void): Pattern
}
- interface Library { Pattern: Pattern }
// point.js
- export interface Point {
- new (): Point;
- new (position: ArrayPoint): Point;
- new (point: Point): Point;
- new (position: { x: number, y: number }): Point;
- new (x: number, y: number): Point;
-
+ class Point {
+ constructor(): Point;
+ constructor(position: ArrayPoint): Point;
+ constructor(point: Point): Point;
+ constructor(position: { x: number, y: number }): Point;
+ constructor(x: number, y: number): Point;
+
x: number;
y: number;
@@ -669,18 +596,11 @@ declare namespace svgjs { native(): SVGPoint;
transform(matrix: Matrix): Point;
}
- interface Library { Point: Point; }
- interface Element {
- point(): Point;
- point(position: ArrayPoint): Point;
- point(position: { x: number, y: number }): Point;
- point(x: number, y: number): Point;
- }
// pointArray.js
- export interface PointArray extends _Array {
- new (): PointArray;
- new (points: PointArrayAlias): PointArray;
+ class PointArray extends _Array {
+ constructor(): PointArray;
+ constructor(points: PointArrayAlias): PointArray;
toString(): string;
toLine(): {
x1: number;
@@ -694,7 +614,6 @@ declare namespace svgjs { size(width?: number, height?: number): this;
bbox(): BBox;
}
- interface Library { PointArray: PointArray }
// poly.js
interface poly extends Shape {
@@ -703,96 +622,36 @@ declare namespace svgjs { move(x: number, y: number): this;
size(width: number, height: number): this;
}
- export interface PolyLine extends poly {
- new (): PolyLine;
+ class PolyLine extends poly {
}
- interface Library { PolyLine: PolyLine; }
interface Container {
polyline(points: PointArrayAlias): PolyLine;
}
- export interface Polygon extends poly {
- new (): Polygon;
+ class Polygon extends poly {
}
- interface Library { Polygon: Polygon; }
interface Container {
polygon(points: PointArrayAlias): Polygon;
}
// rect.js
- export interface Rect extends Shape {
- new (): Rect;
+ class Rect extends Shape {
radius(x: number, y?: number): this;
}
- interface Library { Rect: Rect; }
interface Container {
rect(width?: number, height?: number): Rect;
}
- // regex.js
- interface Library {
- regex: {
- numberAndUnit: RegExp;
- hex: RegExp;
- rgb: RegExp;
- reference: RegExp;
- transforms: RegExp;
- whitespace: RegExp;
- isHex: RegExp;
- isRgb: RegExp;
- isCss: RegExp;
- isBlank: RegExp;
- isNumber: RegExp;
- isPercent: RegExp;
- isImage: RegExp;
- delimiter: RegExp;
- hyphen: RegExp;
- pathLetters: RegExp;
- isPathLetter: RegExp;
- dots: RegExp;
- }
- }
-
- // selector.js
- interface Library {
- get(id: string): Element;
- select(query: string, parent?: HTMLElement): Set;
- }
- interface Parent {
- select(query: string): Set;
- }
-
// set.js
- export interface Set {
- new (members?: Element[]): Set;
- add(...elments: Element[]): this;
- remove(element: Element): this;
+ class List extends _Array {
+ constructor(members?: Element[]): Set;
each(block: (index: number, members: Element[]) => void): this;
- clear(): this;
- length(): number;
- has(element: Element): this;
- index(element: Element): number;
- get(i: number): Element;
- first(): Element;
- last(): Element;
- valueOf(): Element[];
- bbox(): BBox;
- click(cb: Function): Set;
}
interface Container { set(members?: Element[]): Set; }
- interface Library { Set: Set; }
// shape.js
- export interface Shape extends Element {
- new (): Shape;
+ class Shape extends Element {
}
- interface Library { Shape: Shape; }
- // style.js
- interface Element {
- style(styles: Object): this;
- style(style: string): any;
- style(style: string, value: any): this;
- }
// sugar.js
interface StrokeData {
@@ -805,27 +664,6 @@ declare namespace svgjs { dasharray?: string;
dashoffset?: number;
}
- interface Element {
- fill(fill: { color?: string; opacity?: number, rule?: string }): this;
- fill(color: string): this;
- fill(pattern: Element): this;
- fill(image: Image): this;
- stroke(stroke: StrokeData): this;
- stroke(color: string): this;
- rotate(d: number, cx?: number, cy?: number): this;
- skew(x: number, y?: number, cx?: number, cy?: number): this;
- scale(x: number, y?: number, cx?: number, cy?: number): this;
- translate(x: number, y: number): this;
- flip(a: string, offset?: number): this;
- flip(offset?: number): this;
- matrix(m: MatrixAlias): this;
- matrix(a: number, b: number, c: number, d: number, e: number, f: number): this;
- opacity(o: number): this;
- opacity(): number;
- dx(x: NumberAlias): this;
- dy(y: NumberAlias): this;
- dmove(x: NumberAlias, y: NumberAlias): this;
- }
interface Path {
length(): number;
pointAt(length: number): { x: number, y: number };
@@ -838,21 +676,15 @@ declare namespace svgjs { weight?: string;
style?: string
}
- interface Parent {
- font(font: FontData): this;
- }
- interface Text {
- font(font: FontData): this;
- }
// text.js
- export interface Text extends Shape {
- new (): Text;
+ class Text extends Shape {
+ constructor(): Text;
+ font(font: FontData): this;
clone(): Text;
text(): string;
text(text: string): this;
text(block: (text: Text) => void): this;
- size(fontSize: NumberAlias): this;
leading(): number;
leading(leading: NumberAlias): this;
lines(): Set;
@@ -863,15 +695,18 @@ declare namespace svgjs { tspan(block: (tspan: Tspan) => void): this;
clear(): this;
length(): number;
+ path(d: PathArrayAlias): this;
+ track(): Element;
+ textPath(): Element;
}
+
interface Container {
text(text: string): Text;
text(block: (tspan: Tspan) => void): Text;
plain(text: string): Text;
}
- interface Library { Text: Text; }
- export interface Tspan extends Shape {
- new (): Tspan;
+ class Tspan extends Shape {
+ constructor(): Tspan;
text(): string;
text(text: string): Tspan;
text(block: (tspan: Tspan) => void): this;
@@ -884,28 +719,10 @@ declare namespace svgjs { clear(): this;
length(): number;
}
- interface Library { Tspan: Tspan; }
// textpath.js
- export interface TextPath extends Parent {
- new (): TextPath;
- }
- interface Text {
- path(d: PathArrayAlias): this;
- track(): Element;
- textPath(): Element;
- }
- interface Library { TextPath: TextPath; }
+ class TextPath extends Text { }
- // transform.js
- interface Element {
- transform(t: Transform, relative?: boolean): Element;
- transform(): Transform;
- untransform(): this;
- matrixify(): Matrix;
- toParent(parent: Parent): this;
- toDoc(): this;
- }
interface Transform {
x?: number;
y?: number;
@@ -925,57 +742,36 @@ declare namespace svgjs { f?: number;
scale?: number;
}
- export interface Transformation {
- new (...transform: Transform[]): Transformation;
- new (source: Transform, inversed?: boolean): Transformation;
+ class Transformation {
+ constructor(...transform: Transform[]): Transformation;
+ constructor(source: Transform, inversed?: boolean): Transformation;
at(pos: number): Matrix;
undo(transform: Transform): this
}
- export interface Translate extends Transformation {new (): Translate}
- export interface Rotate extends Transformation {new (): Rotate}
- export interface Scale extends Transformation {new (): Scale}
- export interface Skew extends Transformation {new (): Skew}
- interface Library {
- Transformation: Transformation;
- Translate: Translate;
- Rotate: Rotate;
- Scale: Scale;
- Skew: Skew;
- }
+ class Translate extends Transformation { constructor(): Translate }
+ class Rotate extends Transformation { constructor(): Rotate }
+ class Scale extends Transformation { constructor(): Scale }
+ class Skew extends Transformation { constructor(): Skew }
- // ungroup.js
- interface Parent {
- ungroup(parent: Parent, depth?: number): this;
- flatten(parent: Parent, depth?: number): this;
+ interface Container {
+ ungroup(parent: Dom, depth?: number): this;
+ flatten(parent: Dom, depth?: number): this;
}
// use.js
- export interface Use extends Shape {
- new (): Use;
+ class Use extends Shape {
element(element: Element, file?: string): this;
}
interface Container {
use(element: Element | string, file?: string): Use;
}
- interface Library { Use: Use; }
-
- // utilities.js
- interface Library {
- utils: {
- map(array: any[], block: Function): any;
- filter(array: any[], block: Function): any;
- radians(d: number): number;
- degrees(r: number): number;
- filterSVGElements: HTMLElement[]
- }
- }
// viewbox.js
type ViewBoxAlias = ViewBoxLike | number[] | string | Element;
- interface ViewBox {
- new (source: ViewBoxAlias): ViewBox;
- new (x: number, y: number, width: number, height: number): ViewBox;
+ class ViewBox {
+ constructor(source: ViewBoxAlias): ViewBox;
+ constructor(x: number, y: number, width: number, height: number): ViewBox;
x: number;
y: number;
width: number;
@@ -984,16 +780,15 @@ declare namespace svgjs { toString(): string;
morph(source: ViewBoxAlias): ViewBox;
morph(x: number, y: number, width: number, height: number): ViewBox;
- at(pos:number): ViewBox;
+ at(pos: number): ViewBox;
}
interface Container {
viewbox(): ViewBox;
viewbox(x: number, y: number, width: number, height: number): this;
viewbox(viewbox: ViewBoxLike): this;
}
- interface Library { ViewBox: ViewBox; }
- export interface Animation {
+ interface Animation {
stop(): Animation;
finish(): Animation;
pause(): Animation;
@@ -1020,11 +815,11 @@ declare namespace svgjs { during(cb: (pos: number) => void): Animation;
to(value: number): Animation;
after(cb: () => void): Animation;
-
+
delay(delayMS: number): Animation;
rotate(degrees: number, cx?: number, cy?: number): Animation;
- skew(skewX: number, skewY?: number, cx?: number, cy?: number): Animation;
+ skew(skewX: number, skewY?: number, cx?: number, cy?: number): Animation;
scale(scaleX: number, scaleY?: number, cx?: number, cy?: number): Animation;
translate(x: number, y: number): Animation;
transform(t: Transform, relative?: boolean): Animation;
|