sendObjectToPlane
sendObjectToPlane(
object,from?,to?):TMat2D
Defined in: util/misc/planeChange.ts:81
A util that abstracts applying transform to objects.
Sends object to the destination coordinate plane by applying the relevant transformations.
Changes the space/plane where object is drawn.
From the canvas/viewer’s perspective object remains unchanged.
Parameters
Section titled “Parameters”object
Section titled “object”plane matrix containing object. Passing undefined is equivalent to passing the identity matrix, which means object is a direct child of canvas.
destination plane matrix to contain object. Passing undefined means object should be sent to the canvas coordinate plane.
Returns
Section titled “Returns”the transform matrix that was applied to object
Examples
Section titled “Examples”Move clip path from one object to another while preserving it’s appearance as viewed by canvas/viewer
let obj, obj2;let clipPath = new Circle({ radius: 50 });obj.clipPath = clipPath;// rendersendObjectToPlane(clipPath, obj.calcTransformMatrix(), obj2.calcTransformMatrix());obj.clipPath = undefined;obj2.clipPath = clipPath;// render, clipPath now clips obj2 but seems unchanged from the eyes of the viewerClip an object’s clip path with an existing object
let obj, existingObj;let clipPath = new Circle({ radius: 50 });obj.clipPath = clipPath;let transformTo = multiplyTransformMatrices(obj.calcTransformMatrix(), clipPath.calcTransformMatrix());sendObjectToPlane(existingObj, existingObj.group?.calcTransformMatrix(), transformTo);clipPath.clipPath = existingObj;