export function distort()

in packages/maker.js/src/core/model.ts [466:506]


    export function distort(modelToDistort: IModel, scaleX: number, scaleY: number, scaleOrigin = false, bezierAccuracy?: number) {
        const distorted: IModel = {};
        if (modelToDistort.layer) {
            distorted.layer = modelToDistort.layer;
        }

        if (scaleOrigin && modelToDistort.origin) {
            distorted.origin = point.distort(modelToDistort.origin, scaleX, scaleY);
        }

        if (modelToDistort.type === models.BezierCurve.typeName) {
            const b = modelToDistort as models.BezierCurve;
            const bezierPartsByLayer = models.BezierCurve.getBezierSeeds(b, { byLayers: true });
            for (let layer in bezierPartsByLayer) {
                let pathArray = bezierPartsByLayer[layer]
                pathArray.forEach((p, i) => {
                    addDistortedPath(distorted, p, i.toString(), layer, scaleX, scaleY, bezierAccuracy);
                })
            }
        } else if (modelToDistort.paths) {
            for (let pathId in modelToDistort.paths) {
                let pathToDistort = modelToDistort.paths[pathId];
                addDistortedPath(distorted, pathToDistort, pathId, null, scaleX, scaleY, bezierAccuracy);
            }
        }

        if (modelToDistort.models) {
            for (let childId in modelToDistort.models) {
                let childModel = modelToDistort.models[childId];
                let distortedChild = distort(childModel, scaleX, scaleY, true, bezierAccuracy);
                addModel(distorted, distortedChild, childId);
            }
        }

        if (modelToDistort.caption) {
            distorted.caption = cloneObject(modelToDistort.caption);
            distorted.caption.anchor = path.distort(modelToDistort.caption.anchor, scaleX, scaleY) as IPathLine;
        }

        return distorted;
    }