22736238c1
As described on https://github.com/fabricjs/fabric.js/issues/6420#issuecomment-650747872 Fixes rotation marker appearing when selecting, and when ungrouping
33 lines
884 B
TypeScript
33 lines
884 B
TypeScript
// Copyright: Ankitects Pty Ltd and contributors
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
import { fabric } from "fabric";
|
|
import type { Shape } from "image-occlusion/shapes";
|
|
|
|
import { addBorder, enableUniformScaling } from "./lib";
|
|
|
|
export const addShape = (
|
|
canvas: fabric.Canvas,
|
|
shape: Shape,
|
|
): void => {
|
|
const fabricShape = shape.toFabric(canvas);
|
|
addBorder(fabricShape);
|
|
if (fabricShape.type === "i-text") {
|
|
enableUniformScaling(canvas, fabricShape);
|
|
}
|
|
canvas.add(fabricShape);
|
|
};
|
|
|
|
export const addShapeGroup = (
|
|
canvas: fabric.Canvas,
|
|
shapes: Shape[],
|
|
): void => {
|
|
const group = new fabric.Group();
|
|
shapes.map((shape) => {
|
|
const fabricShape = shape.toFabric(canvas);
|
|
addBorder(fabricShape);
|
|
group.addWithUpdate(fabricShape);
|
|
});
|
|
canvas.add(group);
|
|
};
|