@aurigma/design-atoms-model
Version:
Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.
48 lines • 1.68 kB
JavaScript
import { equals } from "../../Utils/Utils";
import { Size } from "./Size";
export class ImageMetaData {
constructor(rawData) {
this.storageId = null;
this.size = new Size();
this.name = null;
this.isUserImage = false;
this.isVector = false;
this.pageIndex = 0;
if (rawData == null)
return;
if (typeof rawData === "string") {
try {
rawData = JSON.parse(rawData);
}
catch (e) {
console.warn("Unable to parse ImageMetaData from string ", rawData, e);
rawData = null;
}
}
if (typeof rawData === "object") {
//TODO Add a validation of raw objects.
Object.assign(this, rawData);
}
}
static fromInterface(value, name) {
const convertedData = new ImageMetaData();
convertedData.storageId = value.id;
convertedData.size = new Size(value.width, value.height);
convertedData.name = name !== undefined ? name : null;
if (value.isVector != null)
convertedData.isVector = value.isVector;
return convertedData;
}
clone() {
return new ImageMetaData(this);
}
equals(other) {
return this.storageId === other.storageId &&
equals(this.size, other.size) &&
equals(this.name, other.name) &&
equals(this.isUserImage, other.isUserImage) &&
equals(this.isVector, other.isVector) &&
equals(this.pageIndex, other.pageIndex);
}
}
//# sourceMappingURL=ImageMetaData.js.map