[opentype.js] add annotations for BoundingBox and some tests, finish prev todo

This commit is contained in:
hikerpig
2019-01-04 14:09:05 +08:00
parent 34b631c678
commit d2926ee528
2 changed files with 15 additions and 2 deletions
+13 -2
View File
@@ -367,8 +367,19 @@ export interface PathCommand {
* UTIL CLASSES
******************************************/
export type BoundingBox = () => any;
// TODO add methods
export class BoundingBox {
x1: number;
y1: number;
x2: number;
y2: number;
isEmpty(): boolean;
addPoint(x: number, y: number): void;
addX(x: number): void;
addY(y: number): void;
addBezier(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x: number, y: number): void;
addQuad(x0: number, y0: number, x1: number, y1: number, x: number, y: number): void;
}
export interface Encoding {
charset: string;
+2
View File
@@ -113,6 +113,8 @@ aPath.extend(aPath);
aPath.extend(aPath.commands);
aPath.extend(aPath.getBoundingBox());
const pathBBox: opentype.BoundingBox = aPath.getBoundingBox();
pathBBox.addQuad(1, 1, 1, 1, 1, 1);
const yDist = pathBBox.y2 - pathBBox.y1;
aPath.draw(ctx);
const pathData: string = aPath.toPathData(7);
const pathSvg: string = aPath.toSVG(7);