anki/ts/image-occlusion/tools/from-shapes.ts
Damien Elmes 22736238c1 Disable rotation globally
As described on https://github.com/fabricjs/fabric.js/issues/6420#issuecomment-650747872

Fixes rotation marker appearing when selecting, and when ungrouping
2023-10-25 09:23:47 +10:00

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);
};