2017-12-30 21:18:55 +00:00
|
|
|
import { IMediaData } from "file/media";
|
2017-12-30 20:59:05 +00:00
|
|
|
import { XmlComponent } from "file/xml-components";
|
2018-06-08 16:03:04 +02:00
|
|
|
import { Anchor } from "./anchor";
|
2018-06-09 23:49:01 +01:00
|
|
|
import { IFloating } from "./floating";
|
|
|
|
import { Inline } from "./inline";
|
2018-06-08 16:03:04 +02:00
|
|
|
|
2018-06-09 23:49:01 +01:00
|
|
|
export interface IDistance {
|
2018-11-02 02:51:57 +00:00
|
|
|
readonly distT?: number;
|
|
|
|
readonly distB?: number;
|
|
|
|
readonly distL?: number;
|
|
|
|
readonly distR?: number;
|
2018-06-08 16:03:04 +02:00
|
|
|
}
|
|
|
|
|
2018-06-09 23:49:01 +01:00
|
|
|
export interface IDrawingOptions {
|
2018-11-02 02:51:57 +00:00
|
|
|
readonly floating?: IFloating;
|
2018-06-08 16:03:04 +02:00
|
|
|
}
|
|
|
|
|
2017-12-30 20:59:05 +00:00
|
|
|
export class Drawing extends XmlComponent {
|
2018-08-07 01:38:15 +01:00
|
|
|
private readonly inline: Inline;
|
2018-06-09 23:33:52 +01:00
|
|
|
|
2019-01-09 01:16:47 +00:00
|
|
|
constructor(imageData: IMediaData, drawingOptions: IDrawingOptions = {}) {
|
2017-12-30 20:59:05 +00:00
|
|
|
super("w:drawing");
|
|
|
|
|
2019-01-09 01:16:47 +00:00
|
|
|
if (!drawingOptions.floating) {
|
2018-12-21 01:39:20 +00:00
|
|
|
this.inline = new Inline(imageData, imageData.dimensions);
|
2018-06-09 23:33:52 +01:00
|
|
|
this.root.push(this.inline);
|
2019-01-09 01:16:47 +00:00
|
|
|
} else {
|
2019-01-09 02:04:06 +00:00
|
|
|
this.root.push(new Anchor(imageData, imageData.dimensions, drawingOptions));
|
2018-06-08 16:03:04 +02:00
|
|
|
}
|
2017-12-30 20:59:05 +00:00
|
|
|
}
|
2018-06-09 23:33:52 +01:00
|
|
|
|
|
|
|
public scale(factorX: number, factorY: number): void {
|
|
|
|
this.inline.scale(factorX, factorY);
|
|
|
|
}
|
2017-12-30 20:59:05 +00:00
|
|
|
}
|