@obliczeniowo/elementary
Version:
Library made in Angular version 19
159 lines (158 loc) • 5.64 kB
TypeScript
import { jsPDF } from 'jspdf';
import { DrawingContextInterface, LinePattern, LinePatternDef, TextAlign, TextBaseline, Rect } from '@obliczeniowo/elementary/drawing';
import { Point2D, ColorType } from '@obliczeniowo/elementary/classes';
declare class Point {
protected _x: number;
protected _y: number;
protected _type: string;
constructor(x: number, y: number);
get x(): number;
set x(value: string | number);
get y(): number;
set y(value: number | string);
get type(): string;
set type(value: any);
}
declare class Rectangle extends Point {
protected _w: number;
protected _h: number;
constructor(x: number, y: number, w: number, h: number);
get w(): number;
set w(value: number | string);
get h(): number;
set h(value: number | string);
}
/**
* A matrix object for 2D homogenous transformations: <br>
* | a b 0 | <br>
* | c d 0 | <br>
* | e f 1 | <br>
* pdf multiplies matrices right hand: v' = v x m1 x m2 x ...
*
*/
declare class Matrix {
protected matrix: number[];
precision: number;
constructor(sx: number, shy: number, shx: number, sy: number, tx: number, ty: number);
get sx(): number;
set sx(value: number);
get shy(): number;
set shy(value: number);
get shx(): number;
set shx(value: number);
get sy(): number;
set sy(value: number);
get tx(): number;
set tx(value: number);
get ty(): number;
set ty(value: number);
get a(): number;
set a(value: number);
get b(): number;
set b(value: number);
get c(): number;
set c(value: number);
get d(): number;
set d(value: number);
get e(): number;
set e(value: number);
get f(): number;
set f(value: number);
get rotation(): number;
get scaleX(): number;
get scaleY(): number;
get isIdentity(): boolean;
join(parm1: string): string;
multiply(matrix: Matrix): Matrix;
decompose(): {
scale: Matrix;
translate: Matrix;
rotate: Matrix;
skew: Matrix;
};
reverse(): Matrix;
toString(parmPrecision: number): string;
inverted(): Matrix;
applyToPoint(pt: Point): Point;
applyToRectangle(rect: Rectangle): Rectangle;
clone(): Matrix;
}
export declare class DrawingPdfInterface extends DrawingContextInterface {
doc: jsPDF;
fontSize: number;
protected textAlign: 'left' | 'center' | 'right';
protected textBaseline: TextBaseline;
protected lineWidth: number;
protected groups: any[];
protected matrix: Matrix;
protected k: number;
protected areaRect: Rect;
protected options: {
orientation?: 'landscape' | 'portrait';
format?: [number, number];
unit?: 'pt' | 'px' | 'in' | 'mm' | 'cm' | 'ex' | 'em' | 'pc';
};
constructor(areaRect: Rect, options?: {
orientation?: 'landscape' | 'portrait';
format?: [number, number];
unit?: 'pt' | 'px' | 'in' | 'mm' | 'cm' | 'ex' | 'em' | 'pc';
});
protected stringToColor(color: string): number[];
protected setDrawColor(color: string): void;
protected setTextColor(color: string): void;
protected setLineWidth(width: number): void;
createSmallArc(rx: number, ry: number, a1: number, a2: number, center: Point2D): [
number,
number,
number,
number,
number,
number,
number,
number
];
createArc(rx: number, ry: number, startAngle: number, endAngle: number, center: Point2D, anticlockwise?: -1 | 1): [number, number, number, number, number, number, number, number][];
setTextAlign(align: TextAlign): this;
setTextBaseline(textBaseline: TextBaseline): this;
setLinePattern(linePattern: LinePattern | string | undefined, linePatternDef?: LinePatternDef): this;
lineTo(point: Point2D, stroke: number, color: ColorType): this;
addPage(): this;
drawLine(startPoint: Point2D, endPoint: Point2D, stroke: number, color: ColorType, options?: any): this;
drawCircle(point: Point2D, ray: number, stroke: number, strokeColor?: ColorType, fillColor?: ColorType, options?: any): this;
drawPie(center: Point2D, rx: number, ry: number, start: number, end: number, stroke: number, strokeColor?: ColorType, fillColor?: ColorType, options?: any): this;
drawEllipse(point: Point2D, xRay: number, yRay: number, stroke: number, strokeColor: ColorType, fillColor: ColorType, options?: any): this;
drawRect(x: number, y: number, width: number, height: number, stroke: number, strokeColor: ColorType, fillColor: ColorType, options?: any): this;
clear(): this;
getTextWidth(text: string): number;
getTextDimension(text: string): {
width: number;
height: number;
};
drawText(text: string, handlePosition: Point2D, color: string, angle?: number, options?: {
maxWidth?: number;
withLink?: string;
}): this;
drawPolyline(points: Point2D[], stroke: number, color?: ColorType, options?: {
close?: boolean;
[key: string]: any;
}): this;
drawPolygon(points: Point2D[], stroke: number, color: ColorType | 'none', fill: ColorType | 'none', options?: {
close?: boolean;
[key: string]: any;
}): this;
setFontSize(size: number): this;
getFontSize(): number;
save(fileName: string): this;
getAsBlob(): Blob;
group(options?: {
clipRect?: {
pos: Point2D;
width: number;
height: number;
};
}): this;
endGroup(): this;
getLineStrokeSize(size?: number): number;
protected color(color: ColorType): string;
}
export {};