UNPKG

jointjs

Version:

JavaScript diagramming library

315 lines (202 loc) 9.02 kB
export function V( svg: SVGElement | Vectorizer | string, attrs?: { [key: string]: any }, children?: Vectorizer | Vectorizer[] | SVGElement | SVGElement[] ): Vectorizer; export namespace Vectorizer { interface RotateOptions { absolute?: boolean; } interface AnnotateStringOptions { includeAnnotationIndices?: boolean; offset?: number; } type TextVerticalAnchor = 'top' | 'bottom' | 'middle'; interface TextOptions { eol?: string; x?: number | string; textVerticalAnchor?: TextVerticalAnchor | number | string; lineHeight?: number | string; textPath?: string | { [key: string]: any }; annotations?: TextAnnotation[]; includeAnnotationIndices?: boolean; displayEmpty?: boolean; } interface GetBBoxOptions { target?: SVGElement | Vectorizer; recursive?: boolean; } interface TransformOptions { absolute?: boolean; } interface ParseXMLOptions { async?: boolean; } interface TextAnnotation { start: number; end: number; attrs: { [key: string]: any }; } // modifiable Matrix. SVGMatrix doesn't allow set on properties or a constructor. interface Matrix { a: number; b: number; c: number; d: number; e: number; f: number; } interface Sample { x: number; y: number; distance: number; } interface DecomposedTransformation { translateX: number; translateY: number; scaleX: number; scaleY: number; skewX: number; skewY: number; rotation: number; } interface RoundedRect extends g.PlainRect { 'rx'?: number; 'ry'?: number; 'top-rx'?: number; 'top-ry'?: number; 'bottom-rx'?: number; 'bottom-ry'?: number; } interface Rotation { angle: number; cx?: number; cy?: number; } interface Translation { tx: number; ty: number; } interface Scale { sx: number; sy: number; } interface Transform { value: string; translate: Translation; rotate: Rotation; scale: Scale; } interface QualifiedAttribute { ns: string | null; local: string; } } export class Vectorizer { id: string; node: SVGElement; constructor( el: string | SVGElement, attrs?: { [key: string]: any }, children?: Vectorizer | Vectorizer[] | SVGElement | SVGElement[] ); getTransformToElement(toElem: SVGGElement | Vectorizer): SVGMatrix; transform(): SVGMatrix; transform(matrix: SVGMatrix | Vectorizer.Matrix, opt?: Vectorizer.TransformOptions): this; translate(): Vectorizer.Translation; translate(tx: number, ty?: number, opt?: Vectorizer.TransformOptions): this; rotate(): Vectorizer.Rotation; rotate(angle: number, cx?: number, cy?: number, opt?: Vectorizer.RotateOptions): this; scale(): Vectorizer.Scale; scale(sx: number, sy?: number): this; bbox(withoutTransformations?: boolean, target?: SVGElement | Vectorizer): g.Rect; getBBox(opt?: Vectorizer.GetBBoxOptions) : g.Rect; text(content: string, opt?: Vectorizer.TextOptions): this; removeAttr(name: string): this; attr(): { [key: string]: string }; attr(name: string): string | null; attr(name: string, value: any): this; attr(attrs: { [key: string]: any }): this; normalizePath(): this; remove(): this; empty(): this; append(els: Vectorizer | Vectorizer[] | SVGElement | SVGElement[]): this; prepend(els: Vectorizer | Vectorizer[] | SVGElement | SVGElement[]): this; before(els: Vectorizer | Vectorizer[] | SVGElement | SVGElement[]): this; appendTo(el: SVGElement | Vectorizer) : this; parent(): Vectorizer | null; // returns either this or Vectorizer, no point in specifying this. svg(): Vectorizer; tagName(): string; defs(): Vectorizer | undefined; clone(): Vectorizer; findOne(selector: string): Vectorizer | undefined; find(selector: string): Vectorizer[]; children(): Vectorizer[]; index(): number; findParentByClass(className: string, terminator?: SVGElement): Vectorizer | null; contains(el: SVGElement | Vectorizer): boolean; toLocalPoint(x: number, y: number): SVGPoint; translateCenterToPoint(p: g.PlainPoint): this; translateAndAutoOrient(position: g.PlainPoint, reference: g.PlainPoint, target?: SVGElement | Vectorizer): this; animateAlongPath(attrs: { [key: string]: any }, path: SVGElement | Vectorizer): void; hasClass(className: string): boolean; addClass(className: string): Vectorizer; removeClass(className: string): this; toggleClass(className: string, switchArg?: boolean): this; sample(interval?: number): Vectorizer.Sample[]; convertToPath(): Vectorizer; convertToPathData(): string; findIntersection(ref: g.PlainPoint, target: SVGElement | Vectorizer): g.PlainPoint | undefined; toGeometryShape(): g.Shape; private setAttributes(attrs: { [key: string]: any }): this; private setAttribute(name: string, value: string): this; static createSVGDocument(content: string): Document; static createSVGStyle(stylesheet: string): SVGStyleElement; static createCDATASection(data: string): CDATASection; static uniqueId(): string; static ensureId(node: SVGElement | Vectorizer): string; static sanitizeText(text: string): string; static isUndefined(value: any): boolean; static isString(value: any): boolean; static isObject(value: any): boolean; static isArray(value: any): boolean; static parseXML(data: string, opt?: Vectorizer.ParseXMLOptions): XMLDocument; static qualifyAttr(name: string): Vectorizer.QualifiedAttribute; static transformStringToMatrix(transform: string): SVGMatrix; static matrixToTransformString(matrix: SVGMatrix | Vectorizer.Matrix): string; static parseTransformString(transform: string): Vectorizer.Transform; static deltaTransformPoint(matrix: SVGMatrix | Vectorizer.Matrix, point: SVGPoint | g.PlainPoint): g.PlainPoint; static decomposeMatrix(matrix: SVGMatrix | Vectorizer.Matrix): Vectorizer.DecomposedTransformation; static matrixToScale(matrix: SVGMatrix | Vectorizer.Matrix): Vectorizer.Scale; static matrixToRotate(matrix: SVGMatrix | Vectorizer.Matrix): Vectorizer.Rotation; static matrixToTranslate(matrix: SVGMatrix | Vectorizer.Matrix): Vectorizer.Translation; static isV(value: any): boolean; static isVElement(value: any): boolean; static isSVGGraphicsElement(value: any): boolean; static createSVGMatrix(matrix: SVGMatrix | Vectorizer.Matrix): SVGMatrix; static createSVGTransform(matrix?: SVGMatrix | Vectorizer.Matrix): SVGTransform; static createSVGPoint(x: number, y: number): SVGPoint; static transformRect(r: g.PlainRect, matrix: SVGMatrix): g.Rect; static transformPoint(p: g.PlainPoint, matrix: SVGMatrix): g.Point; static transformLine(p: g.Line, matrix: SVGMatrix): g.Line; static transformPolyline(p: g.Polyline | g.PlainPoint[], matrix: SVGMatrix): g.Polyline; static styleToObject(styleString: string): { [key: string]: string }; static createSlicePathData(innerRadius: number, outRadius: number, startAngle: number, endAngle: number): string; static mergeAttrs(a: any, b: any): any; static annotateString(t: string, annotations: Vectorizer.TextAnnotation[], opt?: Vectorizer.AnnotateStringOptions): Array< string | { [key: string]: any }> ; static findAnnotationsAtIndex(annotations: Vectorizer.TextAnnotation[], index: number): Vectorizer.TextAnnotation[]; static findAnnotationsBetweenIndexes(annotations: Vectorizer.TextAnnotation[], start: number, end: number): Vectorizer.TextAnnotation[]; static shiftAnnotations(annotations: Vectorizer.TextAnnotation[], index: number, offset: number): Vectorizer.TextAnnotation[]; static convertLineToPathData(line: string | SVGElement | Vectorizer): string; static convertPolygonToPathData(line: string | SVGElement | Vectorizer): string; static convertPolylineToPathData(line: string | SVGElement | Vectorizer): string; static svgPointsToPath(points: g.PlainPoint[] | SVGPoint[]): string; static getPointsFromSvgNode(node: SVGElement | Vectorizer): SVGPoint[]; static convertCircleToPathData(circle: string | SVGElement | Vectorizer): string; static convertEllipseToPathData(ellipse: string | SVGElement | Vectorizer): string; static convertRectToPathData(rect: string | SVGElement | Vectorizer): string; static rectToPath(r: Vectorizer.RoundedRect): string; static normalizePathData(path: string): string; static toNode(el: SVGElement | Vectorizer | SVGElement[]): SVGElement; }