mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 23:12:21 -04:00

* Fix occlusion drift * Fix image editor occasionally not loading fully * Fix occlusion disassociation when browsing * Address oversights * Fix translucent modifier applies to newly created shapes incorrectly * Fix i-text turns yellow upon immediate note change * Fix image occlusion hot keys not disabled when typing * Improve text label creation experience * Remove redundant functions * Fix error when adding occlusion (dae)
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
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 "../shapes";
|
|
import { addBorder, enableUniformScaling } from "./lib";
|
|
|
|
export const addShape = (
|
|
canvas: fabric.Canvas,
|
|
boundingBox: fabric.Rect,
|
|
shape: Shape,
|
|
): void => {
|
|
const fabricShape = shape.toFabric(boundingBox.getBoundingRect(true));
|
|
if (fabricShape.type === "i-text") {
|
|
enableUniformScaling(canvas, fabricShape);
|
|
} else {
|
|
// No border around i-text shapes since it will be interpretted
|
|
// as character stroke, this is supposed to create an outline
|
|
// around the entire shape.
|
|
addBorder(fabricShape);
|
|
}
|
|
canvas.add(fabricShape);
|
|
};
|
|
|
|
export const addShapeGroup = (
|
|
canvas: fabric.Canvas,
|
|
boundingBox: fabric.Rect,
|
|
shapes: Shape[],
|
|
): void => {
|
|
const group = new fabric.Group();
|
|
shapes.map((shape) => {
|
|
const fabricShape = shape.toFabric(boundingBox.getBoundingRect(true));
|
|
addBorder(fabricShape);
|
|
group.addWithUpdate(fabricShape);
|
|
});
|
|
canvas.add(group);
|
|
};
|